GraphTool  1.0
Tool for analyzing and graphically visualizing code dependencies for Ericsson.
 All Classes Namespaces Functions Variables Typedefs Enumerations Pages
dependency.h
1 #ifndef GRAPHTOOL_DEPENDENCY_H
2 #define GRAPHTOOL_DEPENDENCY_H
3 
4 #include <string>
5 #include "mem_type.h"
6 
11 template<class T1, class T2> class Dependency {
12 
13  public:
14 
18  Dependency(T1* from, T2* to, bool is_absolute = false) {
19  from_ = from;
20  to_ = to;
21  is_absolute_ = is_absolute;
22  type_ = GraphTool::UNDEFINED; // temporary
23  }
24 
29  to_->remove_dependent(from_);
30  from_->remove_dependency(to_);
31  }
32 
37  T1* from() {
38  return from_;
39  }
40 
45  T2* to() {
46  return to_;
47  }
48 
53  const T1* from_const() const {
54  return from_;
55  }
56 
61  const T2* to_const() const {
62  return to_;
63  }
64 
70  bool absolute() const {
71  return is_absolute_;
72  }
73 
79  bool relative() const {
80  return !is_absolute_;
81  }
82 
87  void set_absolute() {
88  is_absolute_ = true;
89  }
90 
95  void set_relative() {
96  is_absolute_ = false;
97  }
98 
104  GraphTool::MemType type() const {
105  return type_;
106  }
107 
113  GraphTool::MemType type() {
114  return type_;
115  }
116 
122  std::string type_string() {
123  if(type_ == GraphTool::LDM) {
124  return "LDM";
125  } else if (type_ == GraphTool::LPM) {
126  return "LPM";
127  } else if (type_ == GraphTool::LDM_LPM) {
128  return "LDM_LPM";
129  }
130  return "UNDEFINED";
131  }
132 
138  void set_type(GraphTool::MemType type) const {
139  type_ = type;
140  }
141 
142  private:
143  T1* from_;
144  T2* to_;
145  bool is_absolute_;
146  mutable GraphTool::MemType type_;
147 };
148 
149 #endif
void remove_from_datastructure()
Definition: dependency.h:28
const T2 * to_const() const
Definition: dependency.h:61
Forward declarations for functors.
Definition: defines.h:32
const T1 * from_const() const
Definition: dependency.h:53
T1 * from()
Definition: dependency.h:37
GraphTool::MemType type()
Definition: dependency.h:113
std::string type_string()
Definition: dependency.h:122
void set_absolute()
Definition: dependency.h:87
Dependency(T1 *from, T2 *to, bool is_absolute=false)
Definition: dependency.h:18
void set_type(GraphTool::MemType type) const
Definition: dependency.h:138
bool relative() const
Definition: dependency.h:79
bool absolute() const
Definition: dependency.h:70
GraphTool::MemType type() const
Definition: dependency.h:104
T2 * to()
Definition: dependency.h:45
void set_relative()
Definition: dependency.h:95