GraphTool  1.0
Tool for analyzing and graphically visualizing code dependencies for Ericsson.
 All Classes Namespaces Functions Variables Typedefs Enumerations Pages
run_block_filter.h
1 #ifndef RUN_BLOCK_FILTER_H_
2 #define RUN_BLOCK_FILTER_H_
3 
4 #include <string>
5 #include <vector>
6 
7 #include "graph_filter.h"
8 
9 
14 template<typename GraphType>
15 class RunBlockFilter : public GraphFilter<GraphType> {
16  public:
17  typedef typename GraphType::node_value_type V_type;
18  typedef typename GraphType::edge_value_type E_type;
19 
24  RunBlockFilter(std::string filter_name,
25  std::string executable_name,
26  Linkler* l) :
27  GraphFilter<GraphType>(filter_name, "run_block", false, true, true, false) {
28  executable_name_ = executable_name;
29  set_linkler(l);
30  }
31 
35  void set_linkler(Linkler* l) {
36  l_ = l;
37  swu_names_.clear();
38  valid_executable_ = false;
39 
40  if(l_ != NULL) {
41  SWUSet* swus = l_->get_full_swuset(executable_name_);
42  if(swus != NULL) {
43  valid_executable_ = true;
44  SWUSet::iterator it = swus->begin();
45  for(; it != swus->end(); ++it) {
46  swu_names_.push_back((*it)->name());
47  }
48  }
49  }
50  }
51 
55  return clone;
56  }
57 
59  virtual bool operator() (E_type edge) {
60  return !this->inverted_;
61  }
62 
64  virtual bool enabled() const {
65  if(!valid_executable_)
66  return false;
67  return this->enabled_;
68  }
69 
71  virtual bool operator() (V_type swu) {
72  if(this->enabled_ && valid_executable_) {
73  // Search whether or not the SWU exists in the list of SWU names
74  std::vector<std::string>::iterator res = std::find(swu_names_.begin(), swu_names_.end(), swu->name());
75  // If it is in the list return
76  if(res == swu_names_.end() && !this->inverted_) {
77  return false;
78  } else if(res != swu_names_.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  std::string executable_name() {
92  return executable_name_;
93  }
94 
95  std::vector<std::string>& swu_names() {
96  return swu_names_;
97  }
98  private:
99  std::string executable_name_;
100  std::vector<std::string> swu_names_;
101  bool valid_executable_;
102  Linkler* l_;
103 };
104 #endif
Definition: run_block_filter.h:15
Forward declarations for functors.
Definition: defines.h:32
Definition: linkler.h:20
RunBlockFilter(std::string filter_name, std::string executable_name, Linkler *l)
Definition: run_block_filter.h:24
std::string name() const
Accessor for name.
Definition: swu.cc:151
Definition: graph_filter.h:15
virtual bool operator()(E_type edge)
Ignores edges.
Definition: run_block_filter.h:59
Definition: swu.h:27
virtual GraphFilter< GraphType > * clone()
Clone action.
Definition: run_block_filter.h:53
SWUSet * get_full_swuset(std::string e_name)
Definition: linkler.cc:265
virtual bool enabled() const
Disable the filter if no valid executable was used.
Definition: run_block_filter.h:64
void set_linkler(Linkler *l)
Definition: run_block_filter.h:35