- 3.0.2 rigid body dynamics module.
link_data_map.h
Go to the documentation of this file.
1 #ifndef IIT_TESTIRB4600_LINK_DATA_MAP_H_
2 #define IIT_TESTIRB4600_LINK_DATA_MAP_H_
3 
4 #include "declarations.h"
5 
6 namespace iit {
7 namespace testirb4600 {
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[LINK0] = rhs[LINK0];
70  data[LINK1] = rhs[LINK1];
71  data[LINK2] = rhs[LINK2];
72  data[LINK3] = rhs[LINK3];
73  data[LINK4] = rhs[LINK4];
74  data[LINK5] = rhs[LINK5];
75  data[LINK6] = rhs[LINK6];
76 }
77 
78 template<typename T> inline
79 void LinkDataMap<T>::assigndata(const T& value) {
80  data[LINK0] = value;
81  data[LINK1] = value;
82  data[LINK2] = value;
83  data[LINK3] = value;
84  data[LINK4] = value;
85  data[LINK5] = value;
86  data[LINK6] = value;
87 }
88 
89 template<typename T> inline
90 std::ostream& operator<<(std::ostream& out, const LinkDataMap<T>& map) {
91  out
92  << " link0 = "
93  << map[LINK0]
94  << " link1 = "
95  << map[LINK1]
96  << " link2 = "
97  << map[LINK2]
98  << " link3 = "
99  << map[LINK3]
100  << " link4 = "
101  << map[LINK4]
102  << " link5 = "
103  << map[LINK5]
104  << " link6 = "
105  << map[LINK6]
106  ;
107  return out;
108 }
109 
110 }
111 }
112 #endif
Definition: declarations.h:38
Definition: declarations.h:37
EIGEN_MAKE_ALIGNED_OPERATOR_NEW LinkDataMap()
Definition: link_data_map.h:18
LinkDataMap & operator=(const LinkDataMap &rhs)
Definition: link_data_map.h:42
Definition: declarations.h:40
LinkIdentifiers
Definition: declarations.h:34
Definition: link_data_map.h:12
Definition: declarations.h:35
Definition: declarations.h:36
Definition: declarations.h:41
T & operator[](LinkIdentifiers which)
Definition: link_data_map.h:58
Definition: declarations.h:39