OpenSDN source code
ifmap_node.h
Go to the documentation of this file.
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<>,
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  IFMapTable *table() { return table_; }
31  const IFMapTable *table() const { return table_; }
32 
33  virtual KeyPtr GetDBRequestKey() const;
34 
35  virtual void SetKey(const DBRequestKey *genkey);
36 
37  virtual bool IsLess(const DBEntry &db_entry) const {
38  const IFMapNode &rhs = static_cast<const IFMapNode &>(db_entry);
39  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  const std::string &name() const { return name_; }
50 
51  IFMapObject *Find(IFMapOrigin origin);
52  void Insert(IFMapObject *obj);
53  void Remove(IFMapObject *obj);
54 
56  const IFMapObject *GetObject() const;
58  void PrintAllObjects();
59  int get_object_list_size() { return list_.size(); }
60 
61 private:
62  friend class IFMapNodeCopier;
64  std::string name_;
67 };
68 
69 
70 #endif /* defined(__ctrlplane__ifmap_node__) */
std::unique_ptr< DBRequestKey > KeyPtr
Definition: db_entry.h:25
Definition: db.h:25
IFMapTable * table()
Definition: ifmap_node.h:30
void Remove(IFMapObject *obj)
Definition: ifmap_node.cc:59
crc32type GetConfigCrc()
Definition: ifmap_node.cc:78
boost::intrusive::member_hook< IFMapObject, boost::intrusive::list_member_hook<>, &IFMapObject::node_ > MemberHook
Definition: ifmap_node.h:20
DISALLOW_COPY_AND_ASSIGN(IFMapNode)
const IFMapTable * table() const
Definition: ifmap_node.h:31
IFMapTable * table_
Definition: ifmap_node.h:63
const std::string & name() const
Definition: ifmap_node.h:49
static IFMapNode * DescriptorLookup(DB *db, const Descriptor &descriptor)
Definition: ifmap_node.cc:134
boost::intrusive::list< IFMapObject, MemberHook > ObjectList
Definition: ifmap_node.h:22
std::string name_
Definition: ifmap_node.h:64
virtual bool IsLess(const DBEntry &db_entry) const
Definition: ifmap_node.h:37
void PrintAllObjects()
Definition: ifmap_node.cc:91
boost::crc_32_type::value_type crc32type
Definition: ifmap_node.h:17
virtual void SetKey(const DBRequestKey *genkey)
Definition: ifmap_node.cc:128
virtual KeyPtr GetDBRequestKey() const
Definition: ifmap_node.cc:122
IFMapNode(IFMapTable *table)
Definition: ifmap_node.cc:18
virtual ~IFMapNode()
Definition: ifmap_node.cc:28
ObjectList list_
Definition: ifmap_node.h:65
int get_object_list_size()
Definition: ifmap_node.h:59
IFMapObject * GetObject()
Definition: ifmap_node.cc:64
std::pair< std::string, std::string > Descriptor
Definition: ifmap_node.h:23
void Insert(IFMapObject *obj)
Definition: ifmap_node.cc:50
void EncodeNodeDetail(pugi::xml_node *parent) const
Definition: ifmap_node.cc:100
void EncodeNode(pugi::xml_node *parent) const
IFMapObject * Find(IFMapOrigin origin)
Definition: ifmap_node.cc:39
virtual std::string ToString() const
Definition: ifmap_node.cc:32
static void EncodeNode(const Descriptor &descriptor, pugi::xml_node *parent)
boost::intrusive::list_member_hook node_
Definition: ifmap_object.h:52