OpenSDN source code
ifmap_util.cc
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 #include "ifmap/ifmap_util.h"
7 
8 #include <boost/foreach.hpp>
9 #include <boost/tuple/tuple.hpp>
10 #include "ifmap/ifmap_link.h"
11 #include "ifmap/ifmap_log.h"
12 #include "ifmap/ifmap_log_types.h"
13 #include "ifmap/ifmap_node.h"
14 #include "ifmap/ifmap_table.h"
15 
16 using namespace std;
17 
19  const IFMapNode *node = static_cast<const IFMapNode *>(vertex);
20  if (exclude_vertex.find(node->table()->Typename()) != exclude_vertex.end()) {
21  return false;
22  } else {
23  return true;
24  }
25 }
26 
28  const DBGraphVertex *target,
29  const DBGraphEdge *edge) const {
30  const IFMapNode *node = static_cast<const IFMapNode *>(source);
31  VertexEdgeMap::const_iterator it = exclude_edge.find(node->table()->Typename());
32  if (it == exclude_edge.end()) return true;
33  const IFMapLink *link = static_cast<const IFMapLink *>(edge);
34  if (it->second.find(link->name()) != it->second.end()) {
35  return false;
36  } else {
37  return true;
38  }
39 }
40 
42  const DBGraphVertex *source) const {
43  return std::make_pair(true, DBGraph::VisitorFilter::AllowedEdgeSet());
44 }
45 
46 // Return true if the node-type is in the white list
48  const IFMapNode *node = static_cast<const IFMapNode *>(vertex);
49  if (include_vertex.find(node->table()->Typename()) != include_vertex.end()) {
50  return true;
51  } else {
52  return false;
53  }
54 }
55 
57  const DBGraphVertex *source) const {
58  const IFMapNode *node = static_cast<const IFMapNode *>(source);
59  VertexEdgeMap::const_iterator it = include_vertex.find(node->table()->Typename());
60  assert(it != include_vertex.end());
61  return std::make_pair(false, it->second);
62 }
63 
65  const DBGraphVertex *target,
66  const DBGraphEdge *edge) const {
67  const IFMapNode *node = static_cast<const IFMapNode *>(source);
68  VertexEdgeMap::const_iterator it = include_vertex.find(node->table()->Typename());
69  if (it == include_vertex.end()) {
70  IFMAP_WARN(IFMapIdentifierNotFound, "Cant find vertex",
71  node->table()->Typename());
72  return false;
73  }
74  const IFMapLink *link = static_cast<const IFMapLink *>(edge);
75  if (it->second.find(link->name()) != it->second.end()) {
76  return true;
77  } else {
78  return false;
79  }
80 }
IFMapTable * table()
Definition: ifmap_node.h:30
virtual const char * Typename() const =0
#define IFMAP_WARN(obj,...)
Definition: ifmap_log.h:73
std::set< std::string > AllowedEdgeSet
Definition: db_graph.h:28
std::pair< bool, AllowedEdgeSet > AllowedEdgeRetVal
Definition: db_graph.h:31
virtual AllowedEdgeRetVal AllowedEdges(const DBGraphVertex *source) const
Definition: ifmap_util.cc:41
virtual bool VertexFilter(const DBGraphVertex *vertex) const
Definition: ifmap_util.cc:18
virtual bool EdgeFilter(const DBGraphVertex *source, const DBGraphVertex *target, const DBGraphEdge *edge) const
Definition: ifmap_util.cc:27
virtual bool EdgeFilter(const DBGraphVertex *source, const DBGraphVertex *target, const DBGraphEdge *edge) const
Definition: ifmap_util.cc:64
virtual AllowedEdgeRetVal AllowedEdges(const DBGraphVertex *source) const
Definition: ifmap_util.cc:56
virtual bool VertexFilter(const DBGraphVertex *vertex) const
Definition: ifmap_util.cc:47