- 3.0.2 rigid body dynamics module.
link_data_map.h
Go to the documentation of this file.
1 #ifndef IIT_TESTHYQ_LINK_DATA_MAP_H_
2 #define IIT_TESTHYQ_LINK_DATA_MAP_H_
3 
4 #include "declarations.h"
5 
6 namespace iit {
7 namespace TestHyQ {
8 
12 template<typename T> class LinkDataMap {
13 private:
14  T data[linksCount];
15 public:
16  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
17 
19  LinkDataMap(const T& defaultValue);
20  LinkDataMap(const LinkDataMap& rhs);
21  LinkDataMap& operator=(const LinkDataMap& rhs);
22  LinkDataMap& operator=(const T& rhs);
23  T& operator[](LinkIdentifiers which);
24  const T& operator[](LinkIdentifiers which) const;
25 private:
26  void copydata(const LinkDataMap& rhs);
27  void assigndata(const T& commonValue);
28 };
29 
30 template<typename T> inline
31 LinkDataMap<T>::LinkDataMap(const T& value) {
32  assigndata(value);
33 }
34 
35 template<typename T> inline
37 {
38  copydata(rhs);
39 }
40 
41 template<typename T> inline
43 {
44  if(&rhs != this) {
45  copydata(rhs);
46  }
47  return *this;
48 }
49 
50 template<typename T> inline
52 {
53  assigndata(value);
54  return *this;
55 }
56 
57 template<typename T> inline
59  return data[l];
60 }
61 
62 template<typename T> inline
64  return data[l];
65 }
66 
67 template<typename T> inline
68 void LinkDataMap<T>::copydata(const LinkDataMap& rhs) {
69  data[TRUNK] = rhs[TRUNK];
70  data[LF_HIPASSEMBLY] = rhs[LF_HIPASSEMBLY];
71  data[LF_UPPERLEG] = rhs[LF_UPPERLEG];
72  data[LF_LOWERLEG] = rhs[LF_LOWERLEG];
73  data[RF_HIPASSEMBLY] = rhs[RF_HIPASSEMBLY];
74  data[RF_UPPERLEG] = rhs[RF_UPPERLEG];
75  data[RF_LOWERLEG] = rhs[RF_LOWERLEG];
76  data[LH_HIPASSEMBLY] = rhs[LH_HIPASSEMBLY];
77  data[LH_UPPERLEG] = rhs[LH_UPPERLEG];
78  data[LH_LOWERLEG] = rhs[LH_LOWERLEG];
79  data[RH_HIPASSEMBLY] = rhs[RH_HIPASSEMBLY];
80  data[RH_UPPERLEG] = rhs[RH_UPPERLEG];
81  data[RH_LOWERLEG] = rhs[RH_LOWERLEG];
82 }
83 
84 template<typename T> inline
85 void LinkDataMap<T>::assigndata(const T& value) {
86  data[TRUNK] = value;
87  data[LF_HIPASSEMBLY] = value;
88  data[LF_UPPERLEG] = value;
89  data[LF_LOWERLEG] = value;
90  data[RF_HIPASSEMBLY] = value;
91  data[RF_UPPERLEG] = value;
92  data[RF_LOWERLEG] = value;
93  data[LH_HIPASSEMBLY] = value;
94  data[LH_UPPERLEG] = value;
95  data[LH_LOWERLEG] = value;
96  data[RH_HIPASSEMBLY] = value;
97  data[RH_UPPERLEG] = value;
98  data[RH_LOWERLEG] = value;
99 }
100 
101 template<typename T> inline
102 std::ostream& operator<<(std::ostream& out, const LinkDataMap<T>& map) {
103  out
104  << " trunk = "
105  << map[TRUNK]
106  << " LF_hipassembly = "
107  << map[LF_HIPASSEMBLY]
108  << " LF_upperleg = "
109  << map[LF_UPPERLEG]
110  << " LF_lowerleg = "
111  << map[LF_LOWERLEG]
112  << " RF_hipassembly = "
113  << map[RF_HIPASSEMBLY]
114  << " RF_upperleg = "
115  << map[RF_UPPERLEG]
116  << " RF_lowerleg = "
117  << map[RF_LOWERLEG]
118  << " LH_hipassembly = "
119  << map[LH_HIPASSEMBLY]
120  << " LH_upperleg = "
121  << map[LH_UPPERLEG]
122  << " LH_lowerleg = "
123  << map[LH_LOWERLEG]
124  << " RH_hipassembly = "
125  << map[RH_HIPASSEMBLY]
126  << " RH_upperleg = "
127  << map[RH_UPPERLEG]
128  << " RH_lowerleg = "
129  << map[RH_LOWERLEG]
130  ;
131  return out;
132 }
133 
134 }
135 }
136 #endif
Definition: declarations.h:50
Definition: declarations.h:43
EIGEN_MAKE_ALIGNED_OPERATOR_NEW LinkDataMap()
Definition: link_data_map.h:18
Definition: declarations.h:51
Definition: declarations.h:42
Definition: declarations.h:46
Definition: declarations.h:49
Definition: declarations.h:41
Definition: declarations.h:47
Definition: declarations.h:45
LinkIdentifiers
Definition: declarations.h:40
Definition: link_data_map.h:12
Definition: declarations.h:52
Definition: declarations.h:44
Definition: declarations.h:53
LinkDataMap & operator=(const LinkDataMap &rhs)
Definition: link_data_map.h:42
T & operator[](LinkIdentifiers which)
Definition: link_data_map.h:58
Definition: declarations.h:48