6 #ifndef __sot_torquecontrol_commands_helper_H__
7 #define __sot_torquecontrol_commands_helper_H__
9 #include <boost/function.hpp>
12 #include <dynamic-graph/command.h>
13 #include <dynamic-graph/command-direct-setter.h>
14 #include <dynamic-graph/command-direct-getter.h>
15 #include <dynamic-graph/command-bind.h>
21 namespace torquecontrol {
22 using ::dynamicgraph::command::docCommandVerbose;
23 using ::dynamicgraph::command::docCommandVoid0;
24 using ::dynamicgraph::command::docCommandVoid1;
25 using ::dynamicgraph::command::docCommandVoid2;
26 using ::dynamicgraph::command::docDirectGetter;
27 using ::dynamicgraph::command::docDirectSetter;
28 using ::dynamicgraph::command::makeCommandVerbose;
29 using ::dynamicgraph::command::makeCommandVoid0;
30 using ::dynamicgraph::command::makeCommandVoid1;
31 using ::dynamicgraph::command::makeCommandVoid2;
32 using ::dynamicgraph::command::makeDirectGetter;
33 using ::dynamicgraph::command::makeDirectSetter;
41 template <
class E,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5>
43 typedef boost::function<void(
const T1&,
const T2&,
const T3&,
const T4&,
const T5&)>
function_t;
44 typedef boost::function<void(E*,
const T1&,
const T2&,
const T3&,
const T4&,
const T5&)>
memberFunction_t;
49 boost::assign::list_of(ValueHelper<T1>::TypeID)(ValueHelper<T2>::TypeID)(ValueHelper<T3>::TypeID)(
50 ValueHelper<T4>::TypeID)(ValueHelper<T5>::TypeID),
56 assert(getParameterValues().size() == 5);
57 T1 val1 = getParameterValues()[0].value();
58 T2 val2 = getParameterValues()[1].value();
59 T3 val3 = getParameterValues()[2].value();
60 T4 val4 = getParameterValues()[3].value();
61 T5 val5 = getParameterValues()[4].value();
62 fptr(val1, val2, val3, val4, val5);
70 template <
class E,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5>
76 template <
class E,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5>
78 E& entity, boost::function<
void(E*,
const T1&,
const T2&,
const T3&,
const T4&,
const T5&)>
function,
79 const std::string& docString) {
80 return new CommandVoid5<E, T1, T2, T3, T4, T5>(entity, boost::bind(
function, &entity, _1, _2, _3, _4, _5),
84 template <
class E,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5>
86 void (E::*
function)(
const T1&,
const T2&,
const T3&,
const T4&,
88 const std::string& docString) {
89 return new CommandVoid5<E, T1, T2, T3, T4, T5>(entity, boost::bind(
function, &entity, _1, _2, _3, _4, _5),
94 inline std::string
docCommandVoid5(
const std::string& doc,
const std::string& type1,
const std::string& type2,
95 const std::string& type3,
const std::string& type4,
const std::string& type5) {
96 return (std::string(
"\n") + doc +
"\n\n" +
"Input:\n - A " + type1 +
".\n" +
"Input:\n - A " + type2 +
".\n" +
97 "Input:\n - A " + type3 +
".\n" +
"Input:\n - A " + type4 +
".\n" +
"Input:\n - A " + type5 +
".\n" +
101 template <
class E,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6>
103 typedef boost::function<void(
const T1&,
const T2&,
const T3&,
const T4&,
const T5&,
const T6&)>
function_t;
104 typedef boost::function<void(E*,
const T1&,
const T2&,
const T3&,
const T4&,
const T5&,
const T6&)>
memberFunction_t;
109 boost::assign::list_of(ValueHelper<T1>::TypeID)(ValueHelper<T2>::TypeID)(ValueHelper<T3>::TypeID)(
110 ValueHelper<T4>::TypeID)(ValueHelper<T5>::TypeID)(ValueHelper<T6>::TypeID),
116 assert(getParameterValues().size() == 6);
117 T1 val1 = getParameterValues()[0].value();
118 T2 val2 = getParameterValues()[1].value();
119 T3 val3 = getParameterValues()[2].value();
120 T4 val4 = getParameterValues()[3].value();
121 T5 val5 = getParameterValues()[4].value();
122 T6 val6 = getParameterValues()[5].value();
123 fptr(val1, val2, val3, val4, val5, val6);
131 template <
class E,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6>
137 template <
class E,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6>
139 E& entity, boost::function<
void(E*,
const T1&,
const T2&,
const T3&,
const T4&,
const T5&,
const T6&)>
function,
140 const std::string& docString) {
141 return new CommandVoid6<E, T1, T2, T3, T4, T5, T6>(entity, boost::bind(
function, &entity, _1, _2, _3, _4, _5, _6),
145 template <
class E,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6>
147 void (E::*
function)(
const T1&,
const T2&,
const T3&,
148 const T4&,
const T5&,
const T6&),
149 const std::string& docString) {
150 return new CommandVoid6<E, T1, T2, T3, T4, T5, T6>(entity, boost::bind(
function, &entity, _1, _2, _3, _4, _5, _6),
155 inline std::string
docCommandVoid6(
const std::string& doc,
const std::string& type1,
const std::string& type2,
156 const std::string& type3,
const std::string& type4,
const std::string& type5,
157 const std::string& type6) {
158 return (std::string(
"\n") + doc +
"\n\n" +
"Input:\n - A " + type1 +
".\n" +
"Input:\n - A " + type2 +
".\n" +
159 "Input:\n - A " + type3 +
".\n" +
"Input:\n - A " + type4 +
".\n" +
"Input:\n - A " + type5 +
".\n" +
160 "Input:\n - A " + type6 +
".\n" +
"Void return.\n\n");
163 template <
class E,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6,
typename T7>
165 typedef boost::function<void(
const T1&,
const T2&,
const T3&,
const T4&,
const T5&,
const T6&,
const T7&)>
167 typedef boost::function<void(E*,
const T1&,
const T2&,
const T3&,
const T4&,
const T5&,
const T6&,
const T7&)>
169 typedef void (E::*
memberFunction_ptr_t)(
const T1&,
const T2&,
const T3&,
const T4&,
const T5&,
const T6&,
const T7&);
174 boost::assign::list_of(ValueHelper<T1>::TypeID)(ValueHelper<T2>::TypeID)(ValueHelper<T3>::TypeID)(
175 ValueHelper<T4>::TypeID)(ValueHelper<T5>::TypeID)(ValueHelper<T6>::TypeID)(ValueHelper<T7>::TypeID),
181 assert(getParameterValues().size() == 7);
182 T1 val1 = getParameterValues()[0].value();
183 T2 val2 = getParameterValues()[1].value();
184 T3 val3 = getParameterValues()[2].value();
185 T4 val4 = getParameterValues()[3].value();
186 T5 val5 = getParameterValues()[4].value();
187 T6 val6 = getParameterValues()[5].value();
188 T7 val7 = getParameterValues()[6].value();
189 fptr(val1, val2, val3, val4, val5, val6, val7);
197 template <
class E,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6,
typename T7>
200 const std::string& docString) {
204 template <
class E,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6,
typename T7>
207 boost::function<
void(E*,
const T1&,
const T2&,
const T3&,
const T4&,
const T5&,
const T6&,
const T7&)>
function,
208 const std::string& docString) {
210 entity, boost::bind(
function, &entity, _1, _2, _3, _4, _5, _6, _7), docString);
213 template <
class E,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6,
typename T7>
215 E& entity,
void (E::*
function)(
const T1&,
const T2&,
const T3&,
const T4&,
const T5&,
const T6&,
const T7&),
216 const std::string& docString) {
218 entity, boost::bind(
function, &entity, _1, _2, _3, _4, _5, _6, _7), docString);
222 inline std::string
docCommandVoid7(
const std::string& doc,
const std::string& type1,
const std::string& type2,
223 const std::string& type3,
const std::string& type4,
const std::string& type5,
224 const std::string& type6,
const std::string& type7) {
225 return (std::string(
"\n") + doc +
"\n\n" +
"Input:\n - A " + type1 +
".\n" +
"Input:\n - A " + type2 +
".\n" +
226 "Input:\n - A " + type3 +
".\n" +
"Input:\n - A " + type4 +
".\n" +
"Input:\n - A " + type5 +
".\n" +
227 "Input:\n - A " + type6 +
".\n" +
"Input:\n - A " + type7 +
".\n" +
"Void return.\n\n");
233 #endif // __sot_torquecontrol_commands_helper_H__