- 3.0.2 models module.
link_data_map.h
Go to the documentation of this file.
1 #ifndef IIT_CT_DOUBLEINVERTEDPENDULUM_LINK_DATA_MAP_H_
2 #define IIT_CT_DOUBLEINVERTEDPENDULUM_LINK_DATA_MAP_H_
3 
4 #include "declarations.h"
5 
6 namespace iit {
7 namespace ct_DoubleInvertedPendulum {
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) {
70  data[LINK1] = rhs[LINK1];
71  data[LINK2] = rhs[LINK2];
72 }
73 
74 template<typename T> inline
75 void LinkDataMap<T>::assigndata(const T& value) {
76  data[DOUBLEINVERTEDPENDULUMBASE] = value;
77  data[LINK1] = value;
78  data[LINK2] = value;
79 }
80 
81 template<typename T> inline
82 std::ostream& operator<<(std::ostream& out, const LinkDataMap<T>& map) {
83  out
84  << " DoubleInvertedPendulumBase = "
86  << " Link1 = "
87  << map[LINK1]
88  << " Link2 = "
89  << map[LINK2]
90  ;
91  return out;
92 }
93 
94 }
95 }
96 #endif
Definition: link_data_map.h:12
T & operator[](LinkIdentifiers which)
Definition: link_data_map.h:58
LinkDataMap & operator=(const LinkDataMap &rhs)
Definition: link_data_map.h:42
Definition: declarations.h:32
EIGEN_MAKE_ALIGNED_OPERATOR_NEW LinkDataMap()
Definition: link_data_map.h:18
Definition: declarations.h:33
LinkIdentifiers
Definition: declarations.h:30