7 #ifndef __dg_command_bind_h__ 8 #define __dg_command_bind_h__ 23 #include <boost/assign/list_of.hpp> 24 #include <boost/bind.hpp> 25 #include <boost/function.hpp> 36 const std::string &docString)
47 boost::function<void(void)>
fptr;
52 boost::function<
void(
void)>
function,
53 const std::string &docString) {
59 boost::function<
void(E *)>
function,
60 const std::string &docString) {
61 return new CommandVoid0<E>(entity, boost::bind(
function, &entity), docString);
66 const std::string &docString) {
67 return new CommandVoid0<E>(entity, boost::bind(
function, &entity), docString);
71 return std::string(
"\n") + doc +
"\n\nNo input.\nVoid return.\n\n";
81 template <
class E,
typename T>
85 CommandVoid1(E &entity, function_t
function,
const std::string &docString)
102 template <
class E,
typename T>
104 E &entity, boost::function<
void(
const T &)>
function,
106 const std::string &docString) {
110 template <
class E,
typename T>
115 boost::function<
void(E *,
const T &)>
function,
116 const std::string &docString) {
121 template <
class E,
typename T>
123 const std::string &docString) {
130 const std::string &type) {
131 return std::string(
"\n") + doc +
"\n\nInput:\n - A " + type +
132 ".\nVoid return.\n\n";
142 template <
class E,
typename T1,
typename T2>
144 typedef boost::function<void(const T1 &, const T2 &)>
function_t;
146 CommandVoid2(E &entity, function_t
function,
const std::string &docString)
166 template <
class E,
typename T1,
typename T2>
168 E &entity, boost::function<
void(
const T1 &,
const T2 &)>
function,
169 const std::string &docString) {
173 template <
class E,
typename T1,
typename T2>
178 boost::function<
void(E *,
const T1 &,
const T2 &)>
function,
179 const std::string &docString) {
181 entity, boost::bind(
function, &entity, _1, _2), docString);
184 template <
class E,
typename T1,
typename T2>
186 void (E::*
function)(
const T1 &,
188 const std::string &docString) {
190 entity, boost::bind(
function, &entity, _1, _2), docString);
195 const std::string &type1,
196 const std::string &type2) {
197 return (std::string(
"\n") + doc +
"\n\n" +
"Input:\n - A " + type1 +
".\n" +
198 "Input:\n - A " + type2 +
".\n" +
"Void return.\n\n");
208 template <
class E,
typename T1,
typename T2,
typename T3>
210 typedef boost::function<void(const T1 &, const T2 &, const T3 &)>
function_t;
212 CommandVoid3(E &entity, function_t
function,
const std::string &docString)
225 fptr(val1, val2, val3);
233 template <
class E,
typename T1,
typename T2,
typename T3>
236 const std::string &docString) {
240 template <
class E,
typename T1,
typename T2,
typename T3>
245 boost::function<
void(E *,
const T1 &,
const T2 &,
const T3 &)>
function,
246 const std::string &docString) {
248 entity, boost::bind(
function, &entity, _1, _2, _3), docString);
251 template <
class E,
typename T1,
typename T2,
typename T3>
253 E &entity,
void (E::*
function)(
const T1 &,
const T2 &,
const T3 &),
254 const std::string &docString) {
256 entity, boost::bind(
function, &entity, _1, _2, _3), docString);
261 const std::string &type1,
262 const std::string &type2,
263 const std::string &type3) {
264 return (std::string(
"\n") + doc +
"\n\n" +
"Input:\n - A " + type1 +
".\n" +
265 "Input:\n - A " + type2 +
".\n" +
"Input:\n - A " + type3 +
".\n" +
276 template <
class E,
typename T1,
typename T2,
typename T3,
typename T4>
278 typedef boost::function<void(const T1 &, const T2 &, const T3 &, const T4 &)>
280 typedef void (E::*memberFunction_ptr_t)(
const T1 &,
const T2 &,
const T3 &,
298 fptr(val1, val2, val3, val4);
306 template <
class E,
typename T1,
typename T2,
typename T3,
typename T4>
309 const std::string &docString) {
313 template <
class E,
typename T1,
typename T2,
typename T3,
typename T4>
316 boost::function<
void(E *,
const T1 &,
const T2 &,
const T3 &,
const T4 &)>
318 const std::string &docString) {
320 entity, boost::bind(
function, &entity, _1, _2, _3, _4), docString);
323 template <
class E,
typename T1,
typename T2,
typename T3,
typename T4>
326 void (E::*
function)(
const T1 &,
const T2 &,
const T3 &,
const T4 &),
327 const std::string &docString) {
329 entity, boost::bind(
function, &entity, _1, _2, _3, _4), docString);
334 const std::string &type1,
335 const std::string &type2,
336 const std::string &type3,
337 const std::string &type4) {
338 return (std::string(
"\n") + doc +
"\n\n" +
"Input:\n - A " + type1 +
".\n" +
339 "Input:\n - A " + type2 +
".\n" +
"Input:\n - A " + type3 +
".\n" +
340 "Input:\n - A " + type4 +
".\n" +
"Void return.\n\n");
350 template <
class E,
typename T1,
typename T2,
typename T3,
typename T4,
353 typedef boost::function<void(
const T1 &,
const T2 &,
const T3 &,
const T4 &,
356 typedef void (E::*memberFunction_ptr_t)(
const T1 &,
const T2 &,
const T3 &,
357 const T4 &,
const T5 &);
375 fptr(val1, val2, val3, val4, val5);
383 template <
class E,
typename T1,
typename T2,
typename T3,
typename T4,
388 const std::string &docString) {
392 template <
class E,
typename T1,
typename T2,
typename T3,
typename T4,
396 boost::function<
void(E *,
const T1 &,
const T2 &,
const T3 &,
const T4 &,
399 const std::string &docString) {
401 entity, boost::bind(
function, &entity, _1, _2, _3, _4, _5), docString);
404 template <
class E,
typename T1,
typename T2,
typename T3,
typename T4,
408 void (E::*
function)(
const T1 &,
const T2 &,
const T3 &,
const T4 &,
410 const std::string &docString) {
412 entity, boost::bind(
function, &entity, _1, _2, _3, _4, _5), docString);
417 const std::string &type1,
418 const std::string &type2,
419 const std::string &type3,
420 const std::string &type4,
421 const std::string &type5) {
422 return (std::string(
"\n") + doc +
"\n\n" +
"Input:\n - A " + type1 +
".\n" +
423 "Input:\n - A " + type2 +
".\n" +
"Input:\n - A " + type3 +
".\n" +
424 "Input:\n - A " + type4 +
".\n" +
"Input:\n - A " + type5 +
".\n" +
435 template <
class E,
typename T1,
typename T2,
typename T3,
typename T4,
436 typename T5,
typename T6>
438 typedef boost::function<void(
const T1 &,
const T2 &,
const T3 &,
const T4 &,
439 const T5 &,
const T6 &)>
441 typedef void (E::*memberFunction_ptr_t)(
const T1 &,
const T2 &,
const T3 &,
442 const T4 &,
const T5 &,
const T6 &);
462 fptr(val1, val2, val3, val4, val5, val6);
470 template <
class E,
typename T1,
typename T2,
typename T3,
typename T4,
471 typename T5,
typename T6>
475 const std::string &docString) {
480 template <
class E,
typename T1,
typename T2,
typename T3,
typename T4,
481 typename T5,
typename T6>
484 boost::function<
void(E *,
const T1 &,
const T2 &,
const T3 &,
const T4 &,
485 const T5 &,
const T6 &)>
487 const std::string &docString) {
489 entity, boost::bind(
function, &entity, _1, _2, _3, _4, _5, _6),
493 template <
class E,
typename T1,
typename T2,
typename T3,
typename T4,
494 typename T5,
typename T6>
497 void (E::*
function)(
const T1 &,
const T2 &,
const T3 &,
const T4 &,
498 const T5 &,
const T6 &),
499 const std::string &docString) {
501 entity, boost::bind(
function, &entity, _1, _2, _3, _4, _5, _6),
507 const std::string &doc,
const std::string &type1,
const std::string &type2,
508 const std::string &type3,
const std::string &type4,
509 const std::string &type5,
const std::string &type6) {
510 return (std::string(
"\n") + doc +
"\n\n" +
"Input:\n - A " + type1 +
".\n" +
511 "Input:\n - A " + type2 +
".\n" +
"Input:\n - A " + type3 +
".\n" +
512 "Input:\n - A " + type4 +
".\n" +
"Input:\n - A " + type5 +
".\n" +
513 "Input:\n - A " + type6 +
".\n" +
"Void return.\n\n");
523 template <
class E,
typename T1,
typename T2,
typename T3,
typename T4,
524 typename T5,
typename T6,
typename T7>
526 typedef boost::function<void(
const T1 &,
const T2 &,
const T3 &,
const T4 &,
527 const T5 &,
const T6 &,
const T7 &)>
529 typedef void (E::*memberFunction_ptr_t)(
const T1 &,
const T2 &,
const T3 &,
530 const T4 &,
const T5 &,
const T6 &,
552 fptr(val1, val2, val3, val4, val5, val6, val7);
560 template <
class E,
typename T1,
typename T2,
typename T3,
typename T4,
561 typename T5,
typename T6,
typename T7>
565 const std::string &docString) {
570 template <
class E,
typename T1,
typename T2,
typename T3,
typename T4,
571 typename T5,
typename T6,
typename T7>
574 boost::function<
void(E *,
const T1 &,
const T2 &,
const T3 &,
const T4 &,
575 const T5 &,
const T6 &,
const T7 &)>
577 const std::string &docString) {
579 entity, boost::bind(
function, &entity, _1, _2, _3, _4, _5, _6, _7),
583 template <
class E,
typename T1,
typename T2,
typename T3,
typename T4,
584 typename T5,
typename T6,
typename T7>
587 void (E::*
function)(
const T1 &,
const T2 &,
const T3 &,
const T4 &,
588 const T5 &,
const T6 &,
const T7 &),
589 const std::string &docString) {
591 entity, boost::bind(
function, &entity, _1, _2, _3, _4, _5, _6, _7),
597 const std::string &doc,
const std::string &type1,
const std::string &type2,
598 const std::string &type3,
const std::string &type4,
599 const std::string &type5,
const std::string &type6,
600 const std::string &type7) {
601 return (std::string(
"\n") + doc +
"\n\n" +
"Input:\n - A " + type1 +
".\n" +
602 "Input:\n - A " + type2 +
".\n" +
"Input:\n - A " + type3 +
".\n" +
603 "Input:\n - A " + type4 +
".\n" +
"Input:\n - A " + type5 +
".\n" +
604 "Input:\n - A " + type6 +
".\n" +
"Input:\n - A " + type7 +
".\n" +
615 template <
class E,
typename T1,
typename T2,
typename T3,
typename T4,
616 typename T5,
typename T6,
typename T7,
typename T8>
618 typedef boost::function<void(
const T1 &,
const T2 &,
const T3 &,
const T4 &,
619 const T5 &,
const T6 &,
const T7 &,
const T8 &)>
621 typedef void (E::*memberFunction_ptr_t)(
const T1 &,
const T2 &,
const T3 &,
622 const T4 &,
const T5 &,
const T6 &,
623 const T7 &,
const T8 &);
646 fptr(val1, val2, val3, val4, val5, val6, val7, val8);
654 template <
class E,
typename T1,
typename T2,
typename T3,
typename T4,
655 typename T5,
typename T6,
typename T7,
typename T8>
660 const std::string &docString) {
661 return new CommandVoid8<E, T1, T2, T3, T4, T5, T6, T7, T8>(entity,
function,
665 template <
class E,
typename T1,
typename T2,
typename T3,
typename T4,
666 typename T5,
typename T6,
typename T7,
typename T8>
669 boost::function<
void(E *,
const T1 &,
const T2 &,
const T3 &,
const T4 &,
670 const T5 &,
const T6 &,
const T7 &,
const T8 &)>
672 const std::string &docString) {
674 entity, boost::bind(
function, &entity, _1, _2, _3, _4, _5, _6, _7, _8),
678 template <
class E,
typename T1,
typename T2,
typename T3,
typename T4,
679 typename T5,
typename T6,
typename T7,
typename T8>
682 void (E::*
function)(
const T1 &,
const T2 &,
const T3 &,
const T4 &,
683 const T5 &,
const T6 &,
const T7 &,
const T8 &),
684 const std::string &docString) {
686 entity, boost::bind(
function, &entity, _1, _2, _3, _4, _5, _6, _7, _8),
692 const std::string &doc,
const std::string &type1,
const std::string &type2,
693 const std::string &type3,
const std::string &type4,
694 const std::string &type5,
const std::string &type6,
695 const std::string &type7,
const std::string &type8) {
696 return (std::string(
"\n") + doc +
"\n\n" +
"Input:\n - A " + type1 +
".\n" +
697 "Input:\n - A " + type2 +
".\n" +
"Input:\n - A " + type3 +
".\n" +
698 "Input:\n - A " + type4 +
".\n" +
"Input:\n - A " + type5 +
".\n" +
699 "Input:\n - A " + type6 +
".\n" +
"Input:\n - A " + type7 +
".\n" +
700 "Input:\n - A " + type8 +
".\n" +
"Void return.\n\n");
722 std::ostringstream oss;
724 return Value(oss.str());
734 const std::string &docString) {
741 void (E::*
function)(std::ostream &),
742 const std::string &docString) {
749 return std::string(
"\n") + doc +
"\n\nNo input.\n Return a string.\n\n";
755 template <
class E,
class ReturnType>
758 const std::string &docString)
769 boost::function<ReturnType(void)>
fptr;
772 template <
class E,
class ReturnType>
774 E &entity, boost::function<ReturnType(
void)>
function,
775 const std::string &docString) {
779 template <
class E,
class ReturnType>
781 E &entity, boost::function<ReturnType(E *)>
function,
782 const std::string &docString) {
784 entity, boost::bind(
function, &entity), docString);
787 template <
class E,
class ReturnType>
789 E &entity, ReturnType (E::*
function)(
void),
const std::string &docString) {
791 entity, boost::bind(
function, &entity), docString);
794 template <
typename ReturnType>
796 const std::string &doc,
const std::string & ) {
797 return std::string(
"\n") + doc +
"\n\nNo input.\n" +
798 typeid(ReturnType).
name() +
" return.\n\n";
808 template <
class E,
typename ReturnType,
typename T>
813 const std::string &docString)
830 template <
class E,
typename ReturnType,
typename T>
832 E &entity, boost::function<ReturnType(
const T &)>
function,
833 const std::string &docString) {
837 template <
class E,
typename ReturnType,
typename T>
842 boost::function<ReturnType(E *,
const T &)>
function,
843 const std::string &docString) {
845 entity, boost::bind(
function, &entity, _1), docString);
848 template <
class E,
typename ReturnType,
typename T>
850 E &entity, ReturnType (E::*
function)(
const T &),
851 const std::string &docString) {
853 entity, boost::bind(
function, &entity, _1), docString);
857 template <
typename ReturnType>
859 const std::string &type) {
860 return std::string(
"\n") + doc +
"\n\nInput:\n - A " + type +
".\n" +
861 typeid(ReturnType).
name() +
"return.\n\n";
871 template <
class E,
typename ReturnType,
typename T1,
typename T2>
873 typedef boost::function<ReturnType(const T1 &, const T2 &)>
function_t;
876 const std::string &docString)
896 template <
class E,
typename ReturnType,
typename T1,
typename T2>
898 E &entity, boost::function<ReturnType(
const T1 &,
const T2 &)>
function,
899 const std::string &docString) {
904 template <
class E,
typename ReturnType,
typename T1,
typename T2>
909 boost::function<ReturnType(E *,
const T1 &,
const T2 &)>
function,
910 const std::string &docString) {
912 entity, boost::bind(
function, &entity, _1, _2), docString);
915 template <
class E,
typename ReturnType,
typename T1,
typename T2>
917 E &entity, ReturnType (E::*
function)(
const T1 &,
const T2 &),
918 const std::string &docString) {
920 entity, boost::bind(
function, &entity, _1, _2), docString);
924 template <
typename ReturnType>
926 const std::string &type1,
927 const std::string &type2) {
928 return (std::string(
"\n") + doc +
"\n\n" +
"Input:\n - A " + type1 +
".\n" +
929 "Input:\n - A " + type2 +
".\n" +
930 "ReturnType:\n - Returns:" +
typeid(ReturnType).
name() + +
".\n\n");
936 #endif // __dg_command_bind_h__ std::string docCommandVoid6(const std::string &doc, const std::string &type1, const std::string &type2, const std::string &type3, const std::string &type4, const std::string &type5, const std::string &type6)
CommandVoid5< E, T1, T2, T3, T4, T5 > * makeCommandVoid5(E &entity, typename CommandVoid5< E, T1, T2, T3, T4, T5 >::function_t function, const std::string &docString)
CommandVoid0< E > * makeCommandVoid0(E &entity, boost::function< void(void)> function, const std::string &docString)
CommandVoid4(E &entity, function_t function, const std::string &docString)
std::string docCommandReturnType2(const std::string &doc, const std::string &type1, const std::string &type2)
virtual Value doExecute()
Specific action performed by the command.
CommandVoid2(E &entity, function_t function, const std::string &docString)
CommandVoid3(E &entity, function_t function, const std::string &docString)
This class implements a variant design pattern to handle basic types in Command.
boost::function< void(const T1 &, const T2 &)> function_t
virtual Value doExecute()
Specific action performed by the command.
virtual Value doExecute()
Specific action performed by the command.
boost::function< void(std::ostream &)> function_t
boost::function< void(const T1 &, const T2 &, const T3 &, const T4 &, const T5 &, const T6 &, const T7 &, const T8 &)> function_t
boost::function< ReturnType(void)> fptr
CommandVoid1< E, T > * makeCommandVoid1(E &entity, boost::function< void(const T &)> function, const std::string &docString)
std::string docCommandVoid1(const std::string &doc, const std::string &type)
boost::function< void(void)> fptr
std::string docCommandVoid4(const std::string &doc, const std::string &type1, const std::string &type2, const std::string &type3, const std::string &type4)
boost::function< ReturnType(const T &)> function_t
CommandReturnType0< E, ReturnType > * makeCommandReturnType0(E &entity, boost::function< ReturnType(void)> function, const std::string &docString)
virtual Value doExecute()
Specific action performed by the command.
virtual Value doExecute()
Specific action performed by the command.
std::string docCommandVoid0(const std::string &doc)
std::string docCommandVoid3(const std::string &doc, const std::string &type1, const std::string &type2, const std::string &type3)
std::string docCommandVoid5(const std::string &doc, const std::string &type1, const std::string &type2, const std::string &type3, const std::string &type4, const std::string &type5)
virtual Value doExecute()
Specific action performed by the command.
boost::function< void(const T1 &, const T2 &, const T3 &, const T4 &, const T5 &, const T6 &)> function_t
virtual Value doExecute()
Specific action performed by the command.
CommandVoid3< E, T1, T2, T3 > * makeCommandVoid3(E &entity, typename CommandVoid3< E, T1, T2, T3 >::function_t function, const std::string &docString)
CommandVoid1(E &entity, function_t function, const std::string &docString)
boost::function< ReturnType(const T1 &, const T2 &)> function_t
boost::function< void(const T &)> function_t
CommandVoid6(E &entity, function_t function, const std::string &docString)
boost::function< void(const T1 &, const T2 &, const T3 &)> function_t
virtual Value doExecute()
Specific action performed by the command.
CommandVoid4< E, T1, T2, T3, T4 > * makeCommandVoid4(E &entity, typename CommandVoid4< E, T1, T2, T3, T4 >::function_t function, const std::string &docString)
boost::function< void(const T1 &, const T2 &, const T3 &, const T4 &, const T5 &)> function_t
boost::function< void(const T1 &, const T2 &, const T3 &, const T4 &, const T5 &, const T6 &, const T7 &)> function_t
virtual Value doExecute()
Specific action performed by the command.
static const std::vector< Value::Type > EMPTY_ARG
CommandReturnType2(E &entity, function_t function, const std::string &docString)
std::string docCommandReturnType0(const std::string &doc, const std::string &)
CommandReturnType2< E, ReturnType, T1, T2 > * makeCommandReturnType2(E &entity, boost::function< ReturnType(const T1 &, const T2 &)> function, const std::string &docString)
CommandVoid6< E, T1, T2, T3, T4, T5, T6 > * makeCommandVoid6(E &entity, typename CommandVoid6< E, T1, T2, T3, T4, T5, T6 >::function_t function, const std::string &docString)
virtual Value doExecute()
Specific action performed by the command.
virtual Value doExecute()
Specific action performed by the command.
CommandVoid8(E &entity, function_t function, const std::string &docString)
CommandVerbose< E > * makeCommandVerbose(E &entity, typename CommandVerbose< E >::function_t function, const std::string &docString)
CommandVerbose(E &entity, function_t function, const std::string &docString)
std::string docCommandReturnType1(const std::string &doc, const std::string &type)
std::string docCommandVoid2(const std::string &doc, const std::string &type1, const std::string &type2)
CommandReturnType0(E &entity, boost::function< ReturnType(void)> function, const std::string &docString)
CommandVoid8< E, T1, T2, T3, T4, T5, T6, T7, T8 > * makeCommandVoid8(E &entity, typename CommandVoid8< E, T1, T2, T3, T4, T5, T6, T7, T8 >::function_t function, const std::string &docString)
const std::vector< Value > & getParameterValues() const
Get parameter values.
std::string docCommandVoid7(const std::string &doc, const std::string &type1, const std::string &type2, const std::string &type3, const std::string &type4, const std::string &type5, const std::string &type6, const std::string &type7)
CommandReturnType1< E, ReturnType, T > * makeCommandReturnType1(E &entity, boost::function< ReturnType(const T &)> function, const std::string &docString)
virtual Value doExecute()
Specific action performed by the command.
virtual Value doExecute()
Specific action performed by the command.
CommandVoid7< E, T1, T2, T3, T4, T5, T6, T7 > * makeCommandVoid7(E &entity, typename CommandVoid7< E, T1, T2, T3, T4, T5, T6, T7 >::function_t function, const std::string &docString)
CommandVoid7(E &entity, function_t function, const std::string &docString)
CommandVoid5(E &entity, function_t function, const std::string &docString)
CommandReturnType1(E &entity, function_t function, const std::string &docString)
std::string docCommandVoid8(const std::string &doc, const std::string &type1, const std::string &type2, const std::string &type3, const std::string &type4, const std::string &type5, const std::string &type6, const std::string &type7, const std::string &type8)
CommandVoid0(E &entity, boost::function< void(void)> function, const std::string &docString)
std::string docCommandVerbose(const std::string &doc)
CommandVoid2< E, T1, T2 > * makeCommandVoid2(E &entity, boost::function< void(const T1 &, const T2 &)> function, const std::string &docString)
boost::function< void(const T1 &, const T2 &, const T3 &, const T4 &)> function_t