Skip to content

Commit 681d5b4

Browse files
authored
Merge pull request #88 from nim65s/devel
add doc/make CommandVoid 5-8
2 parents ec98d1c + 6a0aa99 commit 681d5b4

File tree

3 files changed

+335
-3
lines changed

3 files changed

+335
-3
lines changed

include/dynamic-graph/command-bind.h

Lines changed: 332 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,338 @@ inline std::string docCommandVoid4(const std::string &doc,
343343
} // namespace command
344344
} // namespace dynamicgraph
345345

346+
/* --- FUNCTION 5 ARGS ------------------------------------------------------ */
347+
namespace dynamicgraph {
348+
namespace command {
349+
350+
template <class E, typename T1, typename T2, typename T3, typename T4, typename T5>
351+
struct CommandVoid5 : public Command {
352+
typedef boost::function<void(const T1 &, const T2 &, const T3 &, const T4 &, const T5 &)>
353+
function_t;
354+
typedef void (E::*memberFunction_ptr_t)(const T1 &, const T2 &, const T3 &,
355+
const T4 &, const T5 &);
356+
357+
CommandVoid5(E &entity, function_t function, const std::string &docString)
358+
: Command(entity,
359+
boost::assign::list_of(ValueHelper<T1>::TypeID)(
360+
ValueHelper<T2>::TypeID)(ValueHelper<T3>::TypeID)(
361+
ValueHelper<T4>::TypeID)(ValueHelper<T5>::TypeID),
362+
docString),
363+
fptr(function) {}
364+
365+
protected:
366+
virtual Value doExecute() {
367+
assert(getParameterValues().size() == 5);
368+
T1 val1 = getParameterValues()[0].value();
369+
T2 val2 = getParameterValues()[1].value();
370+
T3 val3 = getParameterValues()[2].value();
371+
T4 val4 = getParameterValues()[3].value();
372+
T5 val5 = getParameterValues()[4].value();
373+
fptr(val1, val2, val3, val4, val5);
374+
return Value(); // void
375+
}
376+
377+
private:
378+
function_t fptr;
379+
};
380+
381+
template <class E, typename T1, typename T2, typename T3, typename T4, typename T5>
382+
CommandVoid5<E, T1, T2, T3, T4, T5> *
383+
makeCommandVoid5(E &entity,
384+
typename CommandVoid5<E, T1, T2, T3, T4, T5>::function_t function,
385+
const std::string &docString) {
386+
return new CommandVoid5<E, T1, T2, T3, T4, T5>(entity, function, docString);
387+
}
388+
389+
template <class E, typename T1, typename T2, typename T3, typename T4, typename T5>
390+
CommandVoid5<E, T1, T2, T3, T4, T5> *makeCommandVoid5(
391+
E &entity,
392+
boost::function<void(E *, const T1 &, const T2 &, const T3 &, const T4 &, const T5 &)>
393+
function,
394+
const std::string &docString) {
395+
return new CommandVoid5<E, T1, T2, T3, T4, T5>(
396+
entity, boost::bind(function, &entity, _1, _2, _3, _4, _5), docString);
397+
}
398+
399+
template <class E, typename T1, typename T2, typename T3, typename T4, typename T5>
400+
CommandVoid5<E, T1, T2, T3, T4, T5> *makeCommandVoid5(
401+
E &entity,
402+
void (E::*function)(const T1 &, const T2 &, const T3 &, const T4 &, const T5 &),
403+
const std::string &docString) {
404+
return new CommandVoid5<E, T1, T2, T3, T4, T5>(
405+
entity, boost::bind(function, &entity, _1, _2, _3, _4, _5), docString);
406+
return NULL;
407+
}
408+
409+
inline std::string docCommandVoid5(const std::string &doc,
410+
const std::string &type1,
411+
const std::string &type2,
412+
const std::string &type3,
413+
const std::string &type4,
414+
const std::string &type5) {
415+
return (std::string("\n") + doc + "\n\n" + "Input:\n - A " + type1 + ".\n" +
416+
"Input:\n - A " + type2 + ".\n" + "Input:\n - A " + type3 + ".\n" +
417+
"Input:\n - A " + type4 + ".\n" + "Input:\n - A " + type5 + ".\n" +
418+
"Void return.\n\n");
419+
}
420+
421+
} // namespace command
422+
} // namespace dynamicgraph
423+
424+
/* --- FUNCTION 6 ARGS ------------------------------------------------------ */
425+
namespace dynamicgraph {
426+
namespace command {
427+
428+
template <class E, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
429+
struct CommandVoid6 : public Command {
430+
typedef boost::function<void(const T1 &, const T2 &, const T3 &, const T4 &, const T5 &, const T6 &)>
431+
function_t;
432+
typedef void (E::*memberFunction_ptr_t)(const T1 &, const T2 &, const T3 &,
433+
const T4 &, const T5 &, const T6 &);
434+
435+
CommandVoid6(E &entity, function_t function, const std::string &docString)
436+
: Command(entity,
437+
boost::assign::list_of(ValueHelper<T1>::TypeID)(
438+
ValueHelper<T2>::TypeID)(ValueHelper<T3>::TypeID)(
439+
ValueHelper<T4>::TypeID)(ValueHelper<T5>::TypeID)(
440+
ValueHelper<T6>::TypeID),
441+
docString),
442+
fptr(function) {}
443+
444+
protected:
445+
virtual Value doExecute() {
446+
assert(getParameterValues().size() == 6);
447+
T1 val1 = getParameterValues()[0].value();
448+
T2 val2 = getParameterValues()[1].value();
449+
T3 val3 = getParameterValues()[2].value();
450+
T4 val4 = getParameterValues()[3].value();
451+
T5 val5 = getParameterValues()[4].value();
452+
T6 val6 = getParameterValues()[5].value();
453+
fptr(val1, val2, val3, val4, val5, val6);
454+
return Value(); // void
455+
}
456+
457+
private:
458+
function_t fptr;
459+
};
460+
461+
template <class E, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
462+
CommandVoid6<E, T1, T2, T3, T4, T5, T6> *
463+
makeCommandVoid6(E &entity,
464+
typename CommandVoid6<E, T1, T2, T3, T4, T5, T6>::function_t function,
465+
const std::string &docString) {
466+
return new CommandVoid6<E, T1, T2, T3, T4, T5, T6>(entity, function, docString);
467+
}
468+
469+
template <class E, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
470+
CommandVoid6<E, T1, T2, T3, T4, T5, T6> *makeCommandVoid6(
471+
E &entity,
472+
boost::function<void(E *, const T1 &, const T2 &, const T3 &, const T4 &, const T5 &, const T6 &)>
473+
function,
474+
const std::string &docString) {
475+
return new CommandVoid6<E, T1, T2, T3, T4, T5, T6>(
476+
entity, boost::bind(function, &entity, _1, _2, _3, _4, _5, _6), docString);
477+
}
478+
479+
template <class E, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
480+
CommandVoid6<E, T1, T2, T3, T4, T5, T6> *makeCommandVoid6(
481+
E &entity,
482+
void (E::*function)(const T1 &, const T2 &, const T3 &, const T4 &, const T5 &, const T6 &),
483+
const std::string &docString) {
484+
return new CommandVoid6<E, T1, T2, T3, T4, T5, T6>(
485+
entity, boost::bind(function, &entity, _1, _2, _3, _4, _5, _6), docString);
486+
return NULL;
487+
}
488+
489+
inline std::string docCommandVoid6(const std::string &doc,
490+
const std::string &type1,
491+
const std::string &type2,
492+
const std::string &type3,
493+
const std::string &type4,
494+
const std::string &type5,
495+
const std::string &type6) {
496+
return (std::string("\n") + doc + "\n\n" + "Input:\n - A " + type1 + ".\n" +
497+
"Input:\n - A " + type2 + ".\n" + "Input:\n - A " + type3 + ".\n" +
498+
"Input:\n - A " + type4 + ".\n" + "Input:\n - A " + type5 + ".\n" +
499+
"Input:\n - A " + type6 + ".\n" + "Void return.\n\n");
500+
}
501+
502+
} // namespace command
503+
} // namespace dynamicgraph
504+
505+
/* --- FUNCTION 7 ARGS ------------------------------------------------------ */
506+
namespace dynamicgraph {
507+
namespace command {
508+
509+
template <class E, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
510+
struct CommandVoid7 : public Command {
511+
typedef boost::function<void(const T1 &, const T2 &, const T3 &, const T4 &, const T5 &, const T6 &, const T7 &)>
512+
function_t;
513+
typedef void (E::*memberFunction_ptr_t)(const T1 &, const T2 &, const T3 &,
514+
const T4 &, const T5 &, const T6 &,
515+
const T7 &);
516+
517+
CommandVoid7(E &entity, function_t function, const std::string &docString)
518+
: Command(entity,
519+
boost::assign::list_of(ValueHelper<T1>::TypeID)(
520+
ValueHelper<T2>::TypeID)(ValueHelper<T3>::TypeID)(
521+
ValueHelper<T4>::TypeID)(ValueHelper<T5>::TypeID)(
522+
ValueHelper<T6>::TypeID)(ValueHelper<T7>::TypeID),
523+
docString),
524+
fptr(function) {}
525+
526+
protected:
527+
virtual Value doExecute() {
528+
assert(getParameterValues().size() == 7);
529+
T1 val1 = getParameterValues()[0].value();
530+
T2 val2 = getParameterValues()[1].value();
531+
T3 val3 = getParameterValues()[2].value();
532+
T4 val4 = getParameterValues()[3].value();
533+
T5 val5 = getParameterValues()[4].value();
534+
T6 val6 = getParameterValues()[5].value();
535+
T7 val7 = getParameterValues()[6].value();
536+
fptr(val1, val2, val3, val4, val5, val6, val7);
537+
return Value(); // void
538+
}
539+
540+
private:
541+
function_t fptr;
542+
};
543+
544+
template <class E, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
545+
CommandVoid7<E, T1, T2, T3, T4, T5, T6, T7> *
546+
makeCommandVoid7(E &entity,
547+
typename CommandVoid7<E, T1, T2, T3, T4, T5, T6, T7>::function_t function,
548+
const std::string &docString) {
549+
return new CommandVoid7<E, T1, T2, T3, T4, T5, T6, T7>(entity, function, docString);
550+
}
551+
552+
template <class E, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
553+
CommandVoid7<E, T1, T2, T3, T4, T5, T6, T7> *makeCommandVoid7(
554+
E &entity,
555+
boost::function<void(E *, const T1 &, const T2 &, const T3 &, const T4 &, const T5 &, const T6 &, const T7 &)>
556+
function,
557+
const std::string &docString) {
558+
return new CommandVoid7<E, T1, T2, T3, T4, T5, T6, T7>(
559+
entity, boost::bind(function, &entity, _1, _2, _3, _4, _5, _6, _7), docString);
560+
}
561+
562+
template <class E, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
563+
CommandVoid7<E, T1, T2, T3, T4, T5, T6, T7> *makeCommandVoid7(
564+
E &entity,
565+
void (E::*function)(const T1 &, const T2 &, const T3 &, const T4 &, const T5 &, const T6 &, const T7 &),
566+
const std::string &docString) {
567+
return new CommandVoid7<E, T1, T2, T3, T4, T5, T6, T7>(
568+
entity, boost::bind(function, &entity, _1, _2, _3, _4, _5, _6, _7), docString);
569+
return NULL;
570+
}
571+
572+
inline std::string docCommandVoid7(const std::string &doc,
573+
const std::string &type1,
574+
const std::string &type2,
575+
const std::string &type3,
576+
const std::string &type4,
577+
const std::string &type5,
578+
const std::string &type6,
579+
const std::string &type7) {
580+
return (std::string("\n") + doc + "\n\n" + "Input:\n - A " + type1 + ".\n" +
581+
"Input:\n - A " + type2 + ".\n" + "Input:\n - A " + type3 + ".\n" +
582+
"Input:\n - A " + type4 + ".\n" + "Input:\n - A " + type5 + ".\n" +
583+
"Input:\n - A " + type6 + ".\n" + "Input:\n - A " + type7 + ".\n" +
584+
"Void return.\n\n");
585+
}
586+
587+
} // namespace command
588+
} // namespace dynamicgraph
589+
590+
/* --- FUNCTION 8 ARGS ------------------------------------------------------ */
591+
namespace dynamicgraph {
592+
namespace command {
593+
594+
template <class E, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
595+
struct CommandVoid8 : public Command {
596+
typedef boost::function<void(const T1 &, const T2 &, const T3 &, const T4 &, const T5 &, const T6 &, const T7 &, const T8 &)>
597+
function_t;
598+
typedef void (E::*memberFunction_ptr_t)(const T1 &, const T2 &, const T3 &,
599+
const T4 &, const T5 &, const T6 &,
600+
const T7 &, const T8 &);
601+
602+
CommandVoid8(E &entity, function_t function, const std::string &docString)
603+
: Command(entity,
604+
boost::assign::list_of(ValueHelper<T1>::TypeID)(
605+
ValueHelper<T2>::TypeID)(ValueHelper<T3>::TypeID)(
606+
ValueHelper<T4>::TypeID)(ValueHelper<T5>::TypeID)(
607+
ValueHelper<T6>::TypeID)(ValueHelper<T7>::TypeID)(
608+
ValueHelper<T8>::TypeID),
609+
docString),
610+
fptr(function) {}
611+
612+
protected:
613+
virtual Value doExecute() {
614+
assert(getParameterValues().size() == 8);
615+
T1 val1 = getParameterValues()[0].value();
616+
T2 val2 = getParameterValues()[1].value();
617+
T3 val3 = getParameterValues()[2].value();
618+
T4 val4 = getParameterValues()[3].value();
619+
T5 val5 = getParameterValues()[4].value();
620+
T6 val6 = getParameterValues()[5].value();
621+
T7 val7 = getParameterValues()[6].value();
622+
T8 val8 = getParameterValues()[7].value();
623+
fptr(val1, val2, val3, val4, val5, val6, val7, val8);
624+
return Value(); // void
625+
}
626+
627+
private:
628+
function_t fptr;
629+
};
630+
631+
template <class E, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
632+
CommandVoid8<E, T1, T2, T3, T4, T5, T6, T7, T8> *
633+
makeCommandVoid8(E &entity,
634+
typename CommandVoid8<E, T1, T2, T3, T4, T5, T6, T7, T8>::function_t function,
635+
const std::string &docString) {
636+
return new CommandVoid8<E, T1, T2, T3, T4, T5, T6, T7, T8>(entity, function, docString);
637+
}
638+
639+
template <class E, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
640+
CommandVoid8<E, T1, T2, T3, T4, T5, T6, T7, T8> *makeCommandVoid8(
641+
E &entity,
642+
boost::function<void(E *, const T1 &, const T2 &, const T3 &, const T4 &, const T5 &, const T6 &, const T7 &, const T8 &)>
643+
function,
644+
const std::string &docString) {
645+
return new CommandVoid8<E, T1, T2, T3, T4, T5, T6, T7, T8>(
646+
entity, boost::bind(function, &entity, _1, _2, _3, _4, _5, _6, _7, _8), docString);
647+
}
648+
649+
template <class E, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
650+
CommandVoid8<E, T1, T2, T3, T4, T5, T6, T7, T8> *makeCommandVoid8(
651+
E &entity,
652+
void (E::*function)(const T1 &, const T2 &, const T3 &, const T4 &, const T5 &, const T6 &, const T7 &, const T8 &),
653+
const std::string &docString) {
654+
return new CommandVoid8<E, T1, T2, T3, T4, T5, T6, T7, T8>(
655+
entity, boost::bind(function, &entity, _1, _2, _3, _4, _5, _6, _7, _8), docString);
656+
return NULL;
657+
}
658+
659+
inline std::string docCommandVoid8(const std::string &doc,
660+
const std::string &type1,
661+
const std::string &type2,
662+
const std::string &type3,
663+
const std::string &type4,
664+
const std::string &type5,
665+
const std::string &type6,
666+
const std::string &type7,
667+
const std::string &type8) {
668+
return (std::string("\n") + doc + "\n\n" + "Input:\n - A " + type1 + ".\n" +
669+
"Input:\n - A " + type2 + ".\n" + "Input:\n - A " + type3 + ".\n" +
670+
"Input:\n - A " + type4 + ".\n" + "Input:\n - A " + type5 + ".\n" +
671+
"Input:\n - A " + type6 + ".\n" + "Input:\n - A " + type7 + ".\n" +
672+
"Input:\n - A " + type8 + ".\n" + "Void return.\n\n");
673+
}
674+
675+
} // namespace command
676+
} // namespace dynamicgraph
677+
346678
/* --- FUNCTION VERBOSE ----------------------------------------------------- */
347679
/* This bind a function void f( ostream& ) that display some results into
348680
* a string f( void ) that return some string results. */

src/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ SET(tracer-real-time_deps tracer)
99

1010
FOREACH(plugin ${plugins})
1111
GET_FILENAME_COMPONENT(LIBRARY_NAME ${plugin} NAME)
12-
ADD_LIBRARY(${LIBRARY_NAME} SHARED ${plugin})
12+
ADD_LIBRARY(${LIBRARY_NAME} SHARED "${plugin}.cpp")
1313

1414
IF(SUFFIX_SO_VERSION)
1515
SET_TARGET_PROPERTIES(${LIBRARY_NAME} PROPERTIES SOVERSION ${PROJECT_VERSION})

tests/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ ADD_DEFINITIONS(-DTESTS_PLUGINDIR="${LIBRARY_OUTPUT_PATH}")
77
ADD_DEFINITIONS(-DTESTS_DYNLIBSUFFIX="${CMAKE_SHARED_LIBRARY_SUFFIX}")
88

99
MACRO(DYNAMIC_GRAPH_TEST NAME)
10-
ADD_UNIT_TEST(${NAME} ${NAME}.cpp)
10+
ADD_UNIT_TEST(${NAME} "${NAME}.cpp")
1111
TARGET_LINK_LIBRARIES(${NAME} PRIVATE ${PROJECT_NAME} Boost::unit_test_framework)
1212
ENDMACRO(DYNAMIC_GRAPH_TEST)
1313

1414
# Signal cast test.
1515
SET(signalcast_libs signal-cast-registerer-libA signal-cast-registerer-libB)
1616

1717
FOREACH(lib ${signalcast_libs})
18-
ADD_LIBRARY(${lib} SHARED ${lib})
18+
ADD_LIBRARY(${lib} SHARED "${lib}.cpp")
1919
TARGET_LINK_LIBRARIES(${lib} PRIVATE ${PROJECT_NAME})
2020
ENDFOREACH()
2121

0 commit comments

Comments
 (0)