- 3.0.2 models module.
joint_data_map.h
Go to the documentation of this file.
1 #ifndef IIT_CT_DOUBLEINVERTEDPENDULUM_JOINT_DATA_MAP_H_
2 #define IIT_CT_DOUBLEINVERTEDPENDULUM_JOINT_DATA_MAP_H_
3 
4 #include "declarations.h"
5 
6 namespace iit {
7 namespace ct_DoubleInvertedPendulum {
8 
12 template<typename T> class JointDataMap {
13 private:
14  T data[jointsCount];
15 public:
17  JointDataMap(const T& defaultValue);
18  JointDataMap(const JointDataMap& rhs);
19  JointDataMap& operator=(const JointDataMap& rhs);
20  JointDataMap& operator=(const T& rhs);
21  T& operator[](JointIdentifiers which);
22  const T& operator[](JointIdentifiers which) const;
23 private:
24  void copydata(const JointDataMap& rhs);
25  void assigndata(const T& rhs);
26 };
27 
28 template<typename T> inline
30  assigndata(value);
31 }
32 
33 template<typename T> inline
35 {
36  copydata(rhs);
37 }
38 
39 template<typename T> inline
41 {
42  if(&rhs != this) {
43  copydata(rhs);
44  }
45  return *this;
46 }
47 
48 template<typename T> inline
50 {
51  assigndata(value);
52  return *this;
53 }
54 
55 template<typename T> inline
57  return data[j];
58 }
59 
60 template<typename T> inline
62  return data[j];
63 }
64 
65 template<typename T> inline
66 void JointDataMap<T>::copydata(const JointDataMap& rhs) {
67  data[JOINT1] = rhs[JOINT1];
68  data[JOINT2] = rhs[JOINT2];
69 }
70 
71 template<typename T> inline
72 void JointDataMap<T>::assigndata(const T& value) {
73  data[JOINT1] = value;
74  data[JOINT2] = value;
75 }
76 
77 template<typename T> inline
78 std::ostream& operator<<(std::ostream& out, const JointDataMap<T>& map) {
79  out
80  << " Joint1 = "
81  << map[JOINT1]
82  << " Joint2 = "
83  << map[JOINT2]
84  ;
85  return out;
86 }
87 
88 }
89 }
90 #endif
Definition: declarations.h:27
Definition: declarations.h:26
JointDataMap()
Definition: joint_data_map.h:16
T & operator[](JointIdentifiers which)
Definition: joint_data_map.h:56
JointIdentifiers
Definition: declarations.h:25
JointDataMap & operator=(const JointDataMap &rhs)
Definition: joint_data_map.h:40
Definition: joint_data_map.h:12