GraphTool  1.0
Tool for analyzing and graphically visualizing code dependencies for Ericsson.
 All Classes Namespaces Functions Variables Typedefs Enumerations Pages
graph_filter.h
1 #ifndef GRAPH_FILTER_H_
2 #define GRAPH_FILTER_H_
3 
4 #include <string>
5 #include <cstddef>
6 #include <typeinfo>
7 #include <iostream>
8 
14 template<typename GraphType>
15 class GraphFilter {
16  public:
17  typedef typename GraphType::node_value_type V_type;
18  typedef typename GraphType::edge_value_type E_type;
19 
20  GraphFilter() {
21  name_ = "";
22  type_ = "";
23  enabled_ = true;
24  inverted_ = false;
25  nodes_ = true;
26  edges_ = true;
27  }
28 
33  // @param nodes Whether the filter operates on nodes
34  // @param nodes Whether the filter operates on edges
35  GraphFilter(std::string filter_name = "",
36  std::string filter_type = "",
37  bool inverted = false,
38  bool enabled = true,
39  bool nodes = true,
40  bool edges = true) {
41  name_ = filter_name;
42  type_ = filter_type;
43  inverted_ = inverted;
44  enabled_ = enabled;
45  nodes_ = nodes;
46  edges_ = edges;
47  }
48 
49  virtual ~GraphFilter() {
50  }
51 
53  void set_inverted(bool status) {
54  inverted_ = status;
55  }
56 
58  void set_enabled(bool enabled) {
59  enabled_ = enabled;
60  }
61 
64  std::string name() const { return name_; }
65 
68  std::string type() const { return type_; }
69 
73  bool inverted() const { return inverted_; }
74 
77  virtual bool enabled() const { return enabled_; }
78 
80  virtual bool nodes() const { return nodes_; }
81 
83  virtual bool edges() const { return edges_; }
84 
87  virtual GraphFilter<GraphType>* clone() = 0;
88 
90  virtual bool operator() ( V_type m) = 0;
91 
93  virtual bool operator() (E_type e) = 0;
94 
100  template<typename P1, typename P2>
101  bool operator() (std::pair<P1, P2>& m) {
102  return operator()(m.second);
103  }
104 
105  private:
106  std::string name_;
107  std::string type_;
108 
109  protected:
110  bool inverted_;
111  bool enabled_;
112  bool nodes_;
113  bool edges_;
114 };
115 
116 
117 #endif
virtual bool operator()(V_type m)=0
Returns true if the given node should be included, or false if it is to be filtered out...
Forward declarations for functors.
Definition: defines.h:32
virtual GraphFilter< GraphType > * clone()=0
virtual bool enabled() const
Definition: graph_filter.h:77
std::string name() const
Definition: graph_filter.h:64
Definition: graph_filter.h:15
Definition: swu.h:27
virtual bool nodes() const
The nodes property tells us whether this filter operates on nodes.
Definition: graph_filter.h:80
std::string type() const
Definition: graph_filter.h:68
void set_inverted(bool status)
Sets the inverted status.
Definition: graph_filter.h:53
bool inverted() const
Definition: graph_filter.h:73
GraphFilter(std::string filter_name="", std::string filter_type="", bool inverted=false, bool enabled=true, bool nodes=true, bool edges=true)
Definition: graph_filter.h:35
void set_enabled(bool enabled)
Sets enabled.
Definition: graph_filter.h:58
virtual bool edges() const
The edgesproperty tells us whether this filter operates on nodes.
Definition: graph_filter.h:83