6 #ifndef __sot_torquecontrol_commands_helper_H__
7 #define __sot_torquecontrol_commands_helper_H__
9 #include <boost/function.hpp>
12 #include <dynamic-graph/config.hh>
13 #include <dynamic-graph/command.h>
14 #include <dynamic-graph/command-direct-setter.h>
15 #include <dynamic-graph/command-direct-getter.h>
16 #include <dynamic-graph/command-bind.h>
22 namespace torquecontrol {
23 using ::dynamicgraph::command::docCommandVerbose;
24 using ::dynamicgraph::command::docCommandVoid0;
25 using ::dynamicgraph::command::docCommandVoid1;
26 using ::dynamicgraph::command::docCommandVoid2;
27 using ::dynamicgraph::command::docCommandVoid3;
28 using ::dynamicgraph::command::docCommandVoid4;
29 using ::dynamicgraph::command::docDirectGetter;
30 using ::dynamicgraph::command::docDirectSetter;
31 using ::dynamicgraph::command::makeCommandVerbose;
32 using ::dynamicgraph::command::makeCommandVoid0;
33 using ::dynamicgraph::command::makeCommandVoid1;
34 using ::dynamicgraph::command::makeCommandVoid2;
35 using ::dynamicgraph::command::makeCommandVoid3;
36 using ::dynamicgraph::command::makeCommandVoid4;
37 using ::dynamicgraph::command::makeDirectGetter;
38 using ::dynamicgraph::command::makeDirectSetter;
43 #if DYNAMIC_GRAPH_VERSION_AT_LEAST(4, 4, 0)
47 namespace torquecontrol {
51 using ::dynamicgraph::command::docCommandVoid8;
55 using ::dynamicgraph::command::makeCommandVoid8;
64 template <
class E,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5>
66 typedef boost::function<void(
const T1&,
const T2&,
const T3&,
const T4&,
const T5&)>
function_t;
67 typedef boost::function<void(E*,
const T1&,
const T2&,
const T3&,
const T4&,
const T5&)>
memberFunction_t;
72 boost::assign::list_of(ValueHelper<T1>::TypeID)(ValueHelper<T2>::TypeID)(ValueHelper<T3>::TypeID)(
73 ValueHelper<T4>::TypeID)(ValueHelper<T5>::TypeID),
79 assert(getParameterValues().size() == 5);
80 T1 val1 = getParameterValues()[0].value();
81 T2 val2 = getParameterValues()[1].value();
82 T3 val3 = getParameterValues()[2].value();
83 T4 val4 = getParameterValues()[3].value();
84 T5 val5 = getParameterValues()[4].value();
85 fptr(val1, val2, val3, val4, val5);
93 template <
class E,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5>
99 template <
class E,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5>
101 E& entity, boost::function<
void(E*,
const T1&,
const T2&,
const T3&,
const T4&,
const T5&)>
function,
102 const std::string& docString) {
103 return new CommandVoid5<E, T1, T2, T3, T4, T5>(entity, boost::bind(
function, &entity, _1, _2, _3, _4, _5),
107 template <
class E,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5>
109 void (E::*
function)(
const T1&,
const T2&,
const T3&,
const T4&,
111 const std::string& docString) {
112 return new CommandVoid5<E, T1, T2, T3, T4, T5>(entity, boost::bind(
function, &entity, _1, _2, _3, _4, _5),
117 inline std::string
docCommandVoid5(
const std::string& doc,
const std::string& type1,
const std::string& type2,
118 const std::string& type3,
const std::string& type4,
const std::string& type5) {
119 return (std::string(
"\n") + doc +
"\n\n" +
"Input:\n - A " + type1 +
".\n" +
"Input:\n - A " + type2 +
".\n" +
120 "Input:\n - A " + type3 +
".\n" +
"Input:\n - A " + type4 +
".\n" +
"Input:\n - A " + type5 +
".\n" +
124 template <
class E,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6>
126 typedef boost::function<void(
const T1&,
const T2&,
const T3&,
const T4&,
const T5&,
const T6&)>
function_t;
127 typedef boost::function<void(E*,
const T1&,
const T2&,
const T3&,
const T4&,
const T5&,
const T6&)>
memberFunction_t;
132 boost::assign::list_of(ValueHelper<T1>::TypeID)(ValueHelper<T2>::TypeID)(ValueHelper<T3>::TypeID)(
133 ValueHelper<T4>::TypeID)(ValueHelper<T5>::TypeID)(ValueHelper<T6>::TypeID),
139 assert(getParameterValues().size() == 6);
140 T1 val1 = getParameterValues()[0].value();
141 T2 val2 = getParameterValues()[1].value();
142 T3 val3 = getParameterValues()[2].value();
143 T4 val4 = getParameterValues()[3].value();
144 T5 val5 = getParameterValues()[4].value();
145 T6 val6 = getParameterValues()[5].value();
146 fptr(val1, val2, val3, val4, val5, val6);
154 template <
class E,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6>
160 template <
class E,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6>
162 E& entity, boost::function<
void(E*,
const T1&,
const T2&,
const T3&,
const T4&,
const T5&,
const T6&)>
function,
163 const std::string& docString) {
164 return new CommandVoid6<E, T1, T2, T3, T4, T5, T6>(entity, boost::bind(
function, &entity, _1, _2, _3, _4, _5, _6),
168 template <
class E,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6>
170 void (E::*
function)(
const T1&,
const T2&,
const T3&,
171 const T4&,
const T5&,
const T6&),
172 const std::string& docString) {
173 return new CommandVoid6<E, T1, T2, T3, T4, T5, T6>(entity, boost::bind(
function, &entity, _1, _2, _3, _4, _5, _6),
178 inline std::string
docCommandVoid6(
const std::string& doc,
const std::string& type1,
const std::string& type2,
179 const std::string& type3,
const std::string& type4,
const std::string& type5,
180 const std::string& type6) {
181 return (std::string(
"\n") + doc +
"\n\n" +
"Input:\n - A " + type1 +
".\n" +
"Input:\n - A " + type2 +
".\n" +
182 "Input:\n - A " + type3 +
".\n" +
"Input:\n - A " + type4 +
".\n" +
"Input:\n - A " + type5 +
".\n" +
183 "Input:\n - A " + type6 +
".\n" +
"Void return.\n\n");
186 template <
class E,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6,
typename T7>
188 typedef boost::function<void(
const T1&,
const T2&,
const T3&,
const T4&,
const T5&,
const T6&,
const T7&)>
190 typedef boost::function<void(E*,
const T1&,
const T2&,
const T3&,
const T4&,
const T5&,
const T6&,
const T7&)>
192 typedef void (E::*
memberFunction_ptr_t)(
const T1&,
const T2&,
const T3&,
const T4&,
const T5&,
const T6&,
const T7&);
197 boost::assign::list_of(ValueHelper<T1>::TypeID)(ValueHelper<T2>::TypeID)(ValueHelper<T3>::TypeID)(
198 ValueHelper<T4>::TypeID)(ValueHelper<T5>::TypeID)(ValueHelper<T6>::TypeID)(ValueHelper<T7>::TypeID),
204 assert(getParameterValues().size() == 7);
205 T1 val1 = getParameterValues()[0].value();
206 T2 val2 = getParameterValues()[1].value();
207 T3 val3 = getParameterValues()[2].value();
208 T4 val4 = getParameterValues()[3].value();
209 T5 val5 = getParameterValues()[4].value();
210 T6 val6 = getParameterValues()[5].value();
211 T7 val7 = getParameterValues()[6].value();
212 fptr(val1, val2, val3, val4, val5, val6, val7);
220 template <
class E,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6,
typename T7>
223 const std::string& docString) {
227 template <
class E,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6,
typename T7>
230 boost::function<
void(E*,
const T1&,
const T2&,
const T3&,
const T4&,
const T5&,
const T6&,
const T7&)>
function,
231 const std::string& docString) {
233 entity, boost::bind(
function, &entity, _1, _2, _3, _4, _5, _6, _7), docString);
236 template <
class E,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6,
typename T7>
238 E& entity,
void (E::*
function)(
const T1&,
const T2&,
const T3&,
const T4&,
const T5&,
const T6&,
const T7&),
239 const std::string& docString) {
241 entity, boost::bind(
function, &entity, _1, _2, _3, _4, _5, _6, _7), docString);
245 inline std::string
docCommandVoid7(
const std::string& doc,
const std::string& type1,
const std::string& type2,
246 const std::string& type3,
const std::string& type4,
const std::string& type5,
247 const std::string& type6,
const std::string& type7) {
248 return (std::string(
"\n") + doc +
"\n\n" +
"Input:\n - A " + type1 +
".\n" +
"Input:\n - A " + type2 +
".\n" +
249 "Input:\n - A " + type3 +
".\n" +
"Input:\n - A " + type4 +
".\n" +
"Input:\n - A " + type5 +
".\n" +
250 "Input:\n - A " + type6 +
".\n" +
"Input:\n - A " + type7 +
".\n" +
"Void return.\n\n");
257 #endif // __sot_torquecontrol_commands_helper_H__