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