- 3.0.2 rigid body dynamics module.
joint_data_map.h
Go to the documentation of this file.
1 #ifndef IIT_TESTIRB4600_JOINT_DATA_MAP_H_
2 #define IIT_TESTIRB4600_JOINT_DATA_MAP_H_
3 
4 #include "declarations.h"
5 
6 namespace iit {
7 namespace testirb4600 {
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[JA] = rhs[JA];
68  data[JB] = rhs[JB];
69  data[JC] = rhs[JC];
70  data[JD] = rhs[JD];
71  data[JE] = rhs[JE];
72  data[JF] = rhs[JF];
73 }
74 
75 template<typename T> inline
76 void JointDataMap<T>::assigndata(const T& value) {
77  data[JA] = value;
78  data[JB] = value;
79  data[JC] = value;
80  data[JD] = value;
81  data[JE] = value;
82  data[JF] = value;
83 }
84 
85 template<typename T> inline
86 std::ostream& operator<<(std::ostream& out, const JointDataMap<T>& map) {
87  out
88  << " jA = "
89  << map[JA]
90  << " jB = "
91  << map[JB]
92  << " jC = "
93  << map[JC]
94  << " jD = "
95  << map[JD]
96  << " jE = "
97  << map[JE]
98  << " jF = "
99  << map[JF]
100  ;
101  return out;
102 }
103 
104 }
105 }
106 #endif
JointIdentifiers
Definition: declarations.h:25
Definition: declarations.h:27
Definition: declarations.h:31
T & operator[](JointIdentifiers which)
Definition: joint_data_map.h:56
JointDataMap & operator=(const JointDataMap &rhs)
Definition: joint_data_map.h:40
Definition: declarations.h:30
Definition: declarations.h:26
Definition: declarations.h:29
Definition: declarations.h:28
Definition: joint_data_map.h:12
JointDataMap()
Definition: joint_data_map.h:16