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