OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
db_graph_base.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
3  */
4 
5 #ifndef ctrlplane_db_graph_base_h
6 #define ctrlplane_db_graph_base_h
7 
8 #include <boost/graph/graph_traits.hpp>
9 #include <boost/graph/adjacency_list.hpp>
10 #include <boost/graph/properties.hpp>
11 
12 class DBGraphVertex;
13 class DBGraphEdge;
14 
15 template <class StoredEdge>
16 struct order_by_name : public std::binary_function<StoredEdge, StoredEdge, bool>
17 {
18  bool operator()(const StoredEdge& e1, const StoredEdge& e2) const;
19 };
20 
22 
23 namespace boost {
24  template <class ValueType>
25  struct container_gen<ordered_set_by_nameS, ValueType> {
26  typedef std::multiset<ValueType, order_by_name<ValueType> > type;
27  };
28  template <>
29  struct parallel_edge_traits<ordered_set_by_nameS> {
30  typedef disallow_parallel_edge_tag type;
31  };
32 }
33 
34 class DBGraphBase {
35 public:
37  }
38 
40  VertexProperties() : entry(NULL) {
41  }
43  };
44 
45  struct EdgeProperties {
46  EdgeProperties(std::string name, DBGraphEdge *e) : name_(name), edge(e) {
47  }
48  const std::string &name() const {
49  return name_;
50  }
51  std::string name_;
53  };
54 
55  typedef boost::adjacency_list<
56  ordered_set_by_nameS, boost::listS, boost::undirectedS,
58  typedef boost::graph_traits<graph_t >::vertex_descriptor vertex_descriptor;
59  typedef boost::graph_traits<graph_t >::edge_descriptor edge_descriptor;
60  typedef boost::graph_traits<graph_t >::adjacency_iterator adjacency_iterator;
61  typedef boost::graph_traits<graph_t >::edge_iterator edge_iterator;
62  typedef boost::graph_traits<graph_t >::out_edge_iterator out_edge_iterator;
63 
64  typedef graph_t::StoredEdge StoredEdge;
65  typedef boost::container_gen<graph_t::out_edge_list_selector,
67  typedef OutEdgeListType::iterator OutEdgeIterator;
68 
69  typedef graph_t::EdgeContainer EdgeContainer;
70  typedef EdgeContainer::value_type EdgeType;
71 
72  uint64_t get_graph_walk_num() {
73  return ++graph_walk_num_;
74  }
75 
76 private:
77  uint64_t graph_walk_num_;
78 };
79 
80 #endif
boost::adjacency_list< ordered_set_by_nameS, boost::listS, boost::undirectedS, VertexProperties, EdgeProperties > graph_t
Definition: db_graph_base.h:57
boost::graph_traits< graph_t >::edge_iterator edge_iterator
Definition: db_graph_base.h:61
graph_t::StoredEdge StoredEdge
Definition: db_graph_base.h:64
std::multiset< ValueType, order_by_name< ValueType > > type
Definition: db_graph_base.h:26
const std::string & name() const
Definition: db_graph_base.h:48
boost::container_gen< graph_t::out_edge_list_selector, StoredEdge >::type OutEdgeListType
Definition: db_graph_base.h:66
EdgeProperties(std::string name, DBGraphEdge *e)
Definition: db_graph_base.h:46
boost::graph_traits< graph_t >::vertex_descriptor vertex_descriptor
Definition: db_graph_base.h:58
boost::graph_traits< graph_t >::out_edge_iterator out_edge_iterator
Definition: db_graph_base.h:62
boost::graph_traits< graph_t >::adjacency_iterator adjacency_iterator
Definition: db_graph_base.h:60
uint8_t type
Definition: load_balance.h:109
graph_t::EdgeContainer EdgeContainer
Definition: db_graph_base.h:69
bool operator()(const StoredEdge &e1, const StoredEdge &e2) const
Definition: db_graph.cc:314
boost::graph_traits< graph_t >::edge_descriptor edge_descriptor
Definition: db_graph_base.h:59
uint64_t graph_walk_num_
Definition: db_graph_base.h:77
OutEdgeListType::iterator OutEdgeIterator
Definition: db_graph_base.h:67
uint64_t get_graph_walk_num()
Definition: db_graph_base.h:72
EdgeContainer::value_type EdgeType
Definition: db_graph_base.h:70