GraphTool  1.0
Tool for analyzing and graphically visualizing code dependencies for Ericsson.
 All Classes Namespaces Functions Variables Typedefs Enumerations Pages
node_exclusion_filter.h
1 #ifndef NODE_EXCLUSION_FILTER_H_
2 #define NODE_EXCLUSION_FILTER_H_
3 
4 #include <string>
5 #include <set>
6 #include <vector>
7 #include <iterator>
8 
9 #include "graph_filter.h"
10 
11 
16 template<typename GraphType>
17 class NodeExclusionFilter : public GraphFilter<GraphType> {
18  public:
19  typedef typename GraphType::node_value_type V_type;
20  typedef typename GraphType::edge_value_type E_type;
21  typedef typename GraphType::index_type_t index_type_t;
22  typedef typename GraphType::comparator V_CompareFunctor;
23  typedef typename std::set<V_type, V_CompareFunctor> ExcludedNodeSet;
24  typedef typename ExcludedNodeSet::iterator iterator;
25  typedef typename ExcludedNodeSet::const_iterator const_iterator;
26 
27  NodeExclusionFilter(std::string filter_name = "node_exclusion_filter") :
28  GraphFilter<GraphType>(filter_name, "node_exclusion_filter", false, true, true, false) {
29  }
30 
31  NodeExclusionFilter(std::set<V_type, V_CompareFunctor>& nodes, std::string filter_name = "node_exclusion_filter") :
32  GraphFilter<GraphType>(filter_name, "node_exclusion_filter", false, true, true, false), excluded_nodes_(nodes) {
33  }
34 
38  return clone;
39  }
40 
42  void add_exclusion(V_type excluded) {
43  excluded_nodes_.insert(excluded);
44  }
45 
47  ExcludedNodeSet& excluded_nodes(){
48  return excluded_nodes_;
49  }
50 
52  iterator begin() { return excluded_nodes_.begin(); }
53 
55  iterator end() { return excluded_nodes_.end(); }
56 
58  void remove_exclusion(V_type excluded) {
59  excluded_nodes_.erase(excluded);
60  }
61 
63  void clear_filter() {
64  excluded_nodes_.clear();
65  }
66 
68  virtual bool operator() (E_type edge) {
69  return !(this->inverted_);
70  }
71 
73  virtual bool operator() (V_type m) {
74  if(this->enabled_) {
75  typename ExcludedNodeSet::iterator res = excluded_nodes_.find(m);
76  if(res != excluded_nodes_.end() && !this->inverted_) {
77  return false;
78  } else if(res == excluded_nodes_.end() && this->inverted_) {
79  return false;
80  }
81  }
82  return true;
83  }
84 
86  template<typename P1, typename P2>
87  bool operator() (std::pair<P1, P2>& m) {
88  return operator()(m.second);
89  }
90 
91  private:
92  ExcludedNodeSet excluded_nodes_;
93 };
94 
95 #endif
void clear_filter()
clears the set of filtered nodes
Definition: node_exclusion_filter.h:63
Definition: node_exclusion_filter.h:17
Functor for comparing names between SWUs.
Definition: defines.h:61
Forward declarations for functors.
Definition: defines.h:32
ExcludedNodeSet & excluded_nodes()
Retrieve the current set of excluded nodes.
Definition: node_exclusion_filter.h:47
virtual GraphFilter< GraphType > * clone()
Clone the filter.
Definition: node_exclusion_filter.h:36
iterator begin()
Returns an iterator to the beginning of the excluded nodes set.
Definition: node_exclusion_filter.h:52
Definition: graph_filter.h:15
iterator end()
Returns an iterator to the end of the excluded nodes set.
Definition: node_exclusion_filter.h:55
Definition: swu.h:27
virtual bool nodes() const
The nodes property tells us whether this filter operates on nodes.
Definition: graph_filter.h:80
void remove_exclusion(V_type excluded)
Removes a node from the exclusion list.
Definition: node_exclusion_filter.h:58
virtual bool operator()(E_type edge)
No action taken on edges.
Definition: node_exclusion_filter.h:68
void add_exclusion(V_type excluded)
Adds a node to the exclusion list.
Definition: node_exclusion_filter.h:42
unsigned int index_type_t
The type of index used for the nodes in the graph.
Definition: grapher.h:52