OpenSDN source code
policy_graph.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
3  */
4 
5 #ifndef ctrlplane_policy_graph_h
6 #define ctrlplane_policy_graph_h
7 
8 #include <boost/function.hpp>
9 #include <boost/intrusive/list.hpp>
10 
13 
14 class PolicyGraphEdge;
15 class PolicyGraphVertex;
16 
17 class PolicyGraph : public PolicyGraphBase {
18 public:
21  typedef boost::intrusive::member_hook<PolicyGraphVertex,
22  boost::intrusive::list_member_hook<>,
24  typedef boost::intrusive::list<PolicyGraphVertex,
26  typedef OpenVertexList::iterator OpenVertexIterator;
27 
28  void AddNode(PolicyGraphVertex *entry);
29 
30  void RemoveNode(PolicyGraphVertex *entry);
31 
33 
35 
36  void SetEdgeProperty(PolicyGraphEdge *edge);
37 
39  const PolicyGraphVertex *tgt);
40 
41  const graph_t *graph() const { return &root_; }
42 
44  return root_[vertex].entry;
45  }
46 
48  return root_[edge].edge;
49  }
50 
51  void clear();
52 
53  size_t vertex_count() const;
54  size_t edge_count() const;
55 
56  void WriteDot(const std::string &fname) const;
57 
59 
61 
62  void AddOpenVertex(PolicyGraphVertex *vertex);
63 
64  void RemoveOpenVertex(PolicyGraphVertex *vertex);
65 
66  typedef std::pair<PolicyGraphVertex *,
68  class open_vertex_reverse_iterator : public boost::iterator_facade<
69  open_vertex_reverse_iterator, OpenVertexPathPair,
70  boost::forward_traversal_tag, OpenVertexPathPair> {
71  public:
73  : graph_(NULL), open_(NULL) {
74  }
75 
77  PolicyGraphVertex *start)
78  : graph_(graph), open_(start) {
79  }
80 
81  private:
83 
84  void increment();
85 
86  bool equal(const open_vertex_reverse_iterator &rhs) const;
87 
89 
92  };
93 
95  return open_vertex_reverse_iterator(this, open);
96  }
97 
100  }
101 
102  PolicyGraphVertex *GetRoot() const;
103 private:
106 };
107 
108 #endif // ctrlplane_policy_graph_h
boost::graph_traits< graph_t >::vertex_descriptor vertex_descriptor
boost::graph_traits< graph_t >::edge_descriptor edge_descriptor
boost::adjacency_list< boost::setS, boost::listS, boost::bidirectionalS, VertexProperties, EdgeProperties > graph_t
boost::intrusive::list_member_hook open_vertex_
Definition: policy_vertex.h:33
open_vertex_reverse_iterator(PolicyGraph *graph, PolicyGraphVertex *start)
Definition: policy_graph.h:76
OpenVertexPathPair dereference() const
bool equal(const open_vertex_reverse_iterator &rhs) const
OpenVertexIterator open_vertex_begin()
Definition: policy_graph.cc:74
PolicyGraphEdge * GetEdge(const PolicyGraphVertex *src, const PolicyGraphVertex *tgt)
Definition: policy_graph.cc:51
void WriteDot(const std::string &fname) const
Definition: policy_graph.cc:15
PolicyGraphVertex * GetRoot() const
Definition: policy_graph.cc:91
void AddNode(PolicyGraphVertex *entry)
Definition: policy_graph.cc:23
OpenVertexList open_vertex_list_
Definition: policy_graph.h:105
graph_t root_
Definition: policy_graph.h:104
void clear()
Definition: policy_graph.cc:62
size_t edge_count() const
Definition: policy_graph.cc:70
OpenVertexList::iterator OpenVertexIterator
Definition: policy_graph.h:26
PolicyGraphBase::edge_descriptor Edge
Definition: policy_graph.h:19
void Unlink(PolicyGraphVertex *lhs, PolicyGraphVertex *rhs)
Definition: policy_graph.cc:42
OpenVertexIterator open_vertex_end()
Definition: policy_graph.cc:78
boost::intrusive::list< PolicyGraphVertex, OpenVertexListMember > OpenVertexList
Definition: policy_graph.h:25
const graph_t * graph() const
Definition: policy_graph.h:41
void RemoveOpenVertex(PolicyGraphVertex *vertex)
Definition: policy_graph.cc:86
PolicyGraphEdge * edge_data(PolicyGraph::Edge edge) const
Definition: policy_graph.h:47
PolicyGraphBase::vertex_descriptor Vertex
Definition: policy_graph.h:20
Edge Link(PolicyGraphVertex *lhs, PolicyGraphVertex *rhs)
Definition: policy_graph.cc:34
void RemoveNode(PolicyGraphVertex *entry)
Definition: policy_graph.cc:29
void AddOpenVertex(PolicyGraphVertex *vertex)
Definition: policy_graph.cc:82
size_t vertex_count() const
Definition: policy_graph.cc:66
std::pair< PolicyGraphVertex *, PolicyGraphEdge * > OpenVertexPathPair
Definition: policy_graph.h:67
open_vertex_reverse_iterator begin(PolicyGraphVertex *open)
Definition: policy_graph.h:94
PolicyGraphVertex * vertex_data(Vertex vertex) const
Definition: policy_graph.h:43
void SetEdgeProperty(PolicyGraphEdge *edge)
Definition: policy_graph.cc:46
boost::intrusive::member_hook< PolicyGraphVertex, boost::intrusive::list_member_hook<>, &PolicyGraphVertex::open_vertex_ > OpenVertexListMember
Definition: policy_graph.h:23
open_vertex_reverse_iterator end(PolicyGraphVertex *open)
Definition: policy_graph.h:98