Line data Source code
1 : /* 2 : * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved. 3 : * Copyright Contributors to the OpenSDN project 4 : */ 5 : 6 : #ifndef __ctrlplane__ifmap_node__ 7 : #define __ctrlplane__ifmap_node__ 8 : 9 : #include <boost/crc.hpp> // for boost::crc_32_type 10 : #include <boost/intrusive/list.hpp> 11 : 12 : #include "db/db_graph_vertex.h" 13 : #include "ifmap/ifmap_object.h" 14 : 15 : class IFMapNode : public DBGraphVertex { 16 : public: 17 : typedef boost::crc_32_type::value_type crc32type; 18 : typedef boost::intrusive::member_hook<IFMapObject, 19 : boost::intrusive::list_member_hook<>, 20 : &IFMapObject::node_> MemberHook; 21 : 22 : typedef boost::intrusive::list<IFMapObject, MemberHook> ObjectList; 23 : typedef std::pair<std::string, std::string> Descriptor; 24 : 25 : explicit IFMapNode(IFMapTable *table); 26 : virtual ~IFMapNode(); 27 : 28 : virtual std::string ToString() const; 29 : 30 3956996 : IFMapTable *table() { return table_; } 31 439097 : const IFMapTable *table() const { return table_; } 32 : 33 : virtual KeyPtr GetDBRequestKey() const; 34 : 35 : virtual void SetKey(const DBRequestKey *genkey); 36 : 37 5583726 : virtual bool IsLess(const DBEntry &db_entry) const { 38 5583726 : const IFMapNode &rhs = static_cast<const IFMapNode &>(db_entry); 39 5583726 : return name_ < rhs.name_; 40 : } 41 : 42 : void EncodeNodeDetail(pugi::xml_node *parent) const; 43 : void EncodeNode(pugi::xml_node *parent) const; 44 : static void EncodeNode(const Descriptor &descriptor, 45 : pugi::xml_node *parent); 46 : 47 : static IFMapNode *DescriptorLookup(DB *db, const Descriptor &descriptor); 48 : 49 1634601 : const std::string &name() const { return name_; } 50 : 51 : IFMapObject *Find(IFMapOrigin origin); 52 : void Insert(IFMapObject *obj); 53 : void Remove(IFMapObject *obj); 54 : 55 : IFMapObject *GetObject(); 56 : const IFMapObject *GetObject() const; 57 : crc32type GetConfigCrc(); 58 : void PrintAllObjects(); 59 : int get_object_list_size() { return list_.size(); } 60 : 61 : private: 62 : friend class IFMapNodeCopier; 63 : IFMapTable *table_; 64 : std::string name_; 65 : ObjectList list_; 66 : DISALLOW_COPY_AND_ASSIGN(IFMapNode); 67 : }; 68 : 69 : 70 : #endif /* defined(__ctrlplane__ifmap_node__) */