- 3.0.2 models module.
joint_data_map.h
Go to the documentation of this file.
1 #ifndef IIT_HYQ_JOINT_DATA_MAP_H_
2 #define IIT_HYQ_JOINT_DATA_MAP_H_
3 
4 #include "declarations.h"
5 
6 namespace iit {
7 namespace HyQ {
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[LF_HAA] = rhs[LF_HAA];
68  data[LF_HFE] = rhs[LF_HFE];
69  data[LF_KFE] = rhs[LF_KFE];
70  data[RF_HAA] = rhs[RF_HAA];
71  data[RF_HFE] = rhs[RF_HFE];
72  data[RF_KFE] = rhs[RF_KFE];
73  data[LH_HAA] = rhs[LH_HAA];
74  data[LH_HFE] = rhs[LH_HFE];
75  data[LH_KFE] = rhs[LH_KFE];
76  data[RH_HAA] = rhs[RH_HAA];
77  data[RH_HFE] = rhs[RH_HFE];
78  data[RH_KFE] = rhs[RH_KFE];
79 }
80 
81 template<typename T> inline
82 void JointDataMap<T>::assigndata(const T& value) {
83  data[LF_HAA] = value;
84  data[LF_HFE] = value;
85  data[LF_KFE] = value;
86  data[RF_HAA] = value;
87  data[RF_HFE] = value;
88  data[RF_KFE] = value;
89  data[LH_HAA] = value;
90  data[LH_HFE] = value;
91  data[LH_KFE] = value;
92  data[RH_HAA] = value;
93  data[RH_HFE] = value;
94  data[RH_KFE] = value;
95 }
96 
97 template<typename T> inline
98 std::ostream& operator<<(std::ostream& out, const JointDataMap<T>& map) {
99  out
100  << " LF_HAA = "
101  << map[LF_HAA]
102  << " LF_HFE = "
103  << map[LF_HFE]
104  << " LF_KFE = "
105  << map[LF_KFE]
106  << " RF_HAA = "
107  << map[RF_HAA]
108  << " RF_HFE = "
109  << map[RF_HFE]
110  << " RF_KFE = "
111  << map[RF_KFE]
112  << " LH_HAA = "
113  << map[LH_HAA]
114  << " LH_HFE = "
115  << map[LH_HFE]
116  << " LH_KFE = "
117  << map[LH_KFE]
118  << " RH_HAA = "
119  << map[RH_HAA]
120  << " RH_HFE = "
121  << map[RH_HFE]
122  << " RH_KFE = "
123  << map[RH_KFE]
124  ;
125  return out;
126 }
127 
128 }
129 }
130 #endif
Definition: declarations.h:31
T & operator[](JointIdentifiers which)
Definition: joint_data_map.h:56
Definition: declarations.h:36
Definition: declarations.h:29
Definition: joint_data_map.h:12
Definition: declarations.h:34
Definition: declarations.h:37
Definition: declarations.h:28
Definition: declarations.h:38
JointDataMap()
Definition: joint_data_map.h:16
Definition: declarations.h:35
JointDataMap & operator=(const JointDataMap &rhs)
Definition: joint_data_map.h:40
Definition: declarations.h:27
JointIdentifiers
Definition: declarations.h:26
Definition: declarations.h:33
Definition: declarations.h:32
Definition: declarations.h:30