OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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::intrusive::list_member_hook open_vertex_
Definition: policy_vertex.h:33
PolicyGraphBase::edge_descriptor Edge
Definition: policy_graph.h:19
PolicyGraphEdge * edge_data(PolicyGraph::Edge edge) const
Definition: policy_graph.h:47
boost::intrusive::member_hook< PolicyGraphVertex, boost::intrusive::list_member_hook<>,&PolicyGraphVertex::open_vertex_ > OpenVertexListMember
Definition: policy_graph.h:23
OpenVertexList open_vertex_list_
Definition: policy_graph.h:105
boost::intrusive::list< PolicyGraphVertex, OpenVertexListMember > OpenVertexList
Definition: policy_graph.h:25
boost::graph_traits< graph_t >::edge_descriptor edge_descriptor
void RemoveNode(PolicyGraphVertex *entry)
Definition: policy_graph.cc:29
OpenVertexList::iterator OpenVertexIterator
Definition: policy_graph.h:26
std::pair< PolicyGraphVertex *, PolicyGraphEdge * > OpenVertexPathPair
Definition: policy_graph.h:67
open_vertex_reverse_iterator begin(PolicyGraphVertex *open)
Definition: policy_graph.h:94
const graph_t * graph() const
Definition: policy_graph.h:41
PolicyGraphVertex * GetRoot() const
Definition: policy_graph.cc:91
OpenVertexIterator open_vertex_end()
Definition: policy_graph.cc:78
void AddNode(PolicyGraphVertex *entry)
Definition: policy_graph.cc:23
graph_t root_
Definition: policy_graph.h:104
void SetEdgeProperty(PolicyGraphEdge *edge)
Definition: policy_graph.cc:46
void WriteDot(const std::string &fname) const
Definition: policy_graph.cc:15
PolicyGraphBase::vertex_descriptor Vertex
Definition: policy_graph.h:20
bool equal(const open_vertex_reverse_iterator &rhs) const
Edge Link(PolicyGraphVertex *lhs, PolicyGraphVertex *rhs)
Definition: policy_graph.cc:34
void clear()
Definition: policy_graph.cc:62
void AddOpenVertex(PolicyGraphVertex *vertex)
Definition: policy_graph.cc:82
OpenVertexPathPair dereference() const
size_t edge_count() const
Definition: policy_graph.cc:70
boost::graph_traits< graph_t >::vertex_descriptor vertex_descriptor
void Unlink(PolicyGraphVertex *lhs, PolicyGraphVertex *rhs)
Definition: policy_graph.cc:42
size_t vertex_count() const
Definition: policy_graph.cc:66
void RemoveOpenVertex(PolicyGraphVertex *vertex)
Definition: policy_graph.cc:86
boost::adjacency_list< boost::setS, boost::listS, boost::bidirectionalS, VertexProperties, EdgeProperties > graph_t
open_vertex_reverse_iterator(PolicyGraph *graph, PolicyGraphVertex *start)
Definition: policy_graph.h:76
OpenVertexIterator open_vertex_begin()
Definition: policy_graph.cc:74
PolicyGraphEdge * GetEdge(const PolicyGraphVertex *src, const PolicyGraphVertex *tgt)
Definition: policy_graph.cc:51
open_vertex_reverse_iterator end(PolicyGraphVertex *open)
Definition: policy_graph.h:98
PolicyGraphVertex * vertex_data(Vertex vertex) const
Definition: policy_graph.h:43