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