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>
20 namespace torquecontrol {
21 using ::dynamicgraph::command::docCommandVerbose;
22 using ::dynamicgraph::command::docCommandVoid0;
23 using ::dynamicgraph::command::docCommandVoid1;
24 using ::dynamicgraph::command::docCommandVoid2;
25 using ::dynamicgraph::command::docDirectGetter;
26 using ::dynamicgraph::command::docDirectSetter;
27 using ::dynamicgraph::command::makeCommandVerbose;
28 using ::dynamicgraph::command::makeCommandVoid0;
29 using ::dynamicgraph::command::makeCommandVoid1;
30 using ::dynamicgraph::command::makeCommandVoid2;
31 using ::dynamicgraph::command::makeDirectGetter;
32 using ::dynamicgraph::command::makeDirectSetter;
40 template <
class E,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5>
42 typedef boost::function<void(
const T1&,
const T2&,
const T3&,
const T4&,
const T5&)>
function_t;
43 typedef boost::function<void(E*,
const T1&,
const T2&,
const T3&,
const T4&,
const T5&)>
memberFunction_t;
48 boost::assign::list_of(ValueHelper<T1>::TypeID)(ValueHelper<T2>::TypeID)(ValueHelper<T3>::TypeID)(
49 ValueHelper<T4>::TypeID)(ValueHelper<T5>::TypeID),
55 assert(getParameterValues().size() == 5);
56 T1 val1 = getParameterValues()[0].value();
57 T2 val2 = getParameterValues()[1].value();
58 T3 val3 = getParameterValues()[2].value();
59 T4 val4 = getParameterValues()[3].value();
60 T5 val5 = getParameterValues()[4].value();
61 fptr(val1, val2, val3, val4, val5);
69 template <
class E,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5>
75 template <
class E,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5>
77 E& entity, boost::function<
void(E*,
const T1&,
const T2&,
const T3&,
const T4&,
const T5&)>
function,
78 const std::string& docString) {
79 return new CommandVoid5<E, T1, T2, T3, T4, T5>(entity, boost::bind(
function, &entity, _1, _2, _3, _4, _5),
83 template <
class E,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5>
85 void (E::*
function)(
const T1&,
const T2&,
const T3&,
const T4&,
87 const std::string& docString) {
88 return new CommandVoid5<E, T1, T2, T3, T4, T5>(entity, boost::bind(
function, &entity, _1, _2, _3, _4, _5),
93 inline std::string
docCommandVoid5(
const std::string& doc,
const std::string& type1,
const std::string& type2,
94 const std::string& type3,
const std::string& type4,
const std::string& type5) {
95 return (std::string(
"\n") + doc +
"\n\n" +
"Input:\n - A " + type1 +
".\n" +
"Input:\n - A " + type2 +
".\n" +
96 "Input:\n - A " + type3 +
".\n" +
"Input:\n - A " + type4 +
".\n" +
"Input:\n - A " + type5 +
".\n" +
100 template <
class E,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6>
102 typedef boost::function<void(
const T1&,
const T2&,
const T3&,
const T4&,
const T5&,
const T6&)>
function_t;
103 typedef boost::function<void(E*,
const T1&,
const T2&,
const T3&,
const T4&,
const T5&,
const T6&)>
memberFunction_t;
108 boost::assign::list_of(ValueHelper<T1>::TypeID)(ValueHelper<T2>::TypeID)(ValueHelper<T3>::TypeID)(
109 ValueHelper<T4>::TypeID)(ValueHelper<T5>::TypeID)(ValueHelper<T6>::TypeID),
115 assert(getParameterValues().size() == 6);
116 T1 val1 = getParameterValues()[0].value();
117 T2 val2 = getParameterValues()[1].value();
118 T3 val3 = getParameterValues()[2].value();
119 T4 val4 = getParameterValues()[3].value();
120 T5 val5 = getParameterValues()[4].value();
121 T6 val6 = getParameterValues()[5].value();
122 fptr(val1, val2, val3, val4, val5, val6);
130 template <
class E,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6>
136 template <
class E,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6>
138 E& entity, boost::function<
void(E*,
const T1&,
const T2&,
const T3&,
const T4&,
const T5&,
const T6&)>
function,
139 const std::string& docString) {
140 return new CommandVoid6<E, T1, T2, T3, T4, T5, T6>(entity, boost::bind(
function, &entity, _1, _2, _3, _4, _5, _6),
144 template <
class E,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6>
146 void (E::*
function)(
const T1&,
const T2&,
const T3&,
147 const T4&,
const T5&,
const T6&),
148 const std::string& docString) {
149 return new CommandVoid6<E, T1, T2, T3, T4, T5, T6>(entity, boost::bind(
function, &entity, _1, _2, _3, _4, _5, _6),
154 inline std::string
docCommandVoid6(
const std::string& doc,
const std::string& type1,
const std::string& type2,
155 const std::string& type3,
const std::string& type4,
const std::string& type5,
156 const std::string& type6) {
157 return (std::string(
"\n") + doc +
"\n\n" +
"Input:\n - A " + type1 +
".\n" +
"Input:\n - A " + type2 +
".\n" +
158 "Input:\n - A " + type3 +
".\n" +
"Input:\n - A " + type4 +
".\n" +
"Input:\n - A " + type5 +
".\n" +
159 "Input:\n - A " + type6 +
".\n" +
"Void return.\n\n");
162 template <
class E,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6,
typename T7>
164 typedef boost::function<void(
const T1&,
const T2&,
const T3&,
const T4&,
const T5&,
const T6&,
const T7&)>
166 typedef boost::function<void(E*,
const T1&,
const T2&,
const T3&,
const T4&,
const T5&,
const T6&,
const T7&)>
168 typedef void (E::*
memberFunction_ptr_t)(
const T1&,
const T2&,
const T3&,
const T4&,
const T5&,
const T6&,
const T7&);
173 boost::assign::list_of(ValueHelper<T1>::TypeID)(ValueHelper<T2>::TypeID)(ValueHelper<T3>::TypeID)(
174 ValueHelper<T4>::TypeID)(ValueHelper<T5>::TypeID)(ValueHelper<T6>::TypeID)(ValueHelper<T7>::TypeID),
180 assert(getParameterValues().size() == 7);
181 T1 val1 = getParameterValues()[0].value();
182 T2 val2 = getParameterValues()[1].value();
183 T3 val3 = getParameterValues()[2].value();
184 T4 val4 = getParameterValues()[3].value();
185 T5 val5 = getParameterValues()[4].value();
186 T6 val6 = getParameterValues()[5].value();
187 T7 val7 = getParameterValues()[6].value();
188 fptr(val1, val2, val3, val4, val5, val6, val7);
196 template <
class E,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6,
typename T7>
199 const std::string& docString) {
203 template <
class E,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6,
typename T7>
206 boost::function<
void(E*,
const T1&,
const T2&,
const T3&,
const T4&,
const T5&,
const T6&,
const T7&)>
function,
207 const std::string& docString) {
209 entity, boost::bind(
function, &entity, _1, _2, _3, _4, _5, _6, _7), docString);
212 template <
class E,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6,
typename T7>
214 E& entity,
void (E::*
function)(
const T1&,
const T2&,
const T3&,
const T4&,
const T5&,
const T6&,
const T7&),
215 const std::string& docString) {
217 entity, boost::bind(
function, &entity, _1, _2, _3, _4, _5, _6, _7), docString);
221 inline std::string
docCommandVoid7(
const std::string& doc,
const std::string& type1,
const std::string& type2,
222 const std::string& type3,
const std::string& type4,
const std::string& type5,
223 const std::string& type6,
const std::string& type7) {
224 return (std::string(
"\n") + doc +
"\n\n" +
"Input:\n - A " + type1 +
".\n" +
"Input:\n - A " + type2 +
".\n" +
225 "Input:\n - A " + type3 +
".\n" +
"Input:\n - A " + type4 +
".\n" +
"Input:\n - A " + type5 +
".\n" +
226 "Input:\n - A " + type6 +
".\n" +
"Input:\n - A " + type7 +
".\n" +
"Void return.\n\n");
232 #endif // __sot_torquecontrol_commands_helper_H__