diff --git a/include/dynamic-graph/command-bind.h b/include/dynamic-graph/command-bind.h index cf85a58c9975e1408c9592d012c551b1b3ade368..d28941e87e67feb4a9d0ea5624e50ad9c9fc7d1c 100644 --- a/include/dynamic-graph/command-bind.h +++ b/include/dynamic-graph/command-bind.h @@ -343,6 +343,338 @@ inline std::string docCommandVoid4(const std::string &doc, } // namespace command } // namespace dynamicgraph +/* --- FUNCTION 5 ARGS ------------------------------------------------------ */ +namespace dynamicgraph { +namespace command { + +template <class E, typename T1, typename T2, typename T3, typename T4, typename T5> +struct CommandVoid5 : public Command { + typedef boost::function<void(const T1 &, const T2 &, const T3 &, const T4 &, const T5 &)> + function_t; + typedef void (E::*memberFunction_ptr_t)(const T1 &, const T2 &, const T3 &, + const T4 &, const T5 &); + + CommandVoid5(E &entity, function_t function, const std::string &docString) + : Command(entity, + boost::assign::list_of(ValueHelper<T1>::TypeID)( + ValueHelper<T2>::TypeID)(ValueHelper<T3>::TypeID)( + ValueHelper<T4>::TypeID)(ValueHelper<T5>::TypeID), + docString), + fptr(function) {} + +protected: + virtual Value doExecute() { + assert(getParameterValues().size() == 5); + T1 val1 = getParameterValues()[0].value(); + T2 val2 = getParameterValues()[1].value(); + T3 val3 = getParameterValues()[2].value(); + T4 val4 = getParameterValues()[3].value(); + T5 val5 = getParameterValues()[4].value(); + fptr(val1, val2, val3, val4, val5); + return Value(); // void + } + +private: + function_t fptr; +}; + +template <class E, typename T1, typename T2, typename T3, typename T4, typename T5> +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) { + return new CommandVoid5<E, T1, T2, T3, T4, T5>(entity, function, docString); +} + +template <class E, typename T1, typename T2, typename T3, typename T4, typename T5> +CommandVoid5<E, T1, T2, T3, T4, T5> *makeCommandVoid5( + E &entity, + boost::function<void(E *, const T1 &, const T2 &, const T3 &, const T4 &, const T5 &)> + function, + const std::string &docString) { + return new CommandVoid5<E, T1, T2, T3, T4, T5>( + entity, boost::bind(function, &entity, _1, _2, _3, _4, _5), docString); +} + +template <class E, typename T1, typename T2, typename T3, typename T4, typename T5> +CommandVoid5<E, T1, T2, T3, T4, T5> *makeCommandVoid5( + E &entity, + void (E::*function)(const T1 &, const T2 &, const T3 &, const T4 &, const T5 &), + const std::string &docString) { + return new CommandVoid5<E, T1, T2, T3, T4, T5>( + entity, boost::bind(function, &entity, _1, _2, _3, _4, _5), docString); + return NULL; +} + +inline 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) { + return (std::string("\n") + doc + "\n\n" + "Input:\n - A " + type1 + ".\n" + + "Input:\n - A " + type2 + ".\n" + "Input:\n - A " + type3 + ".\n" + + "Input:\n - A " + type4 + ".\n" + "Input:\n - A " + type5 + ".\n" + + "Void return.\n\n"); +} + +} // namespace command +} // namespace dynamicgraph + +/* --- FUNCTION 6 ARGS ------------------------------------------------------ */ +namespace dynamicgraph { +namespace command { + +template <class E, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6> +struct CommandVoid6 : public Command { + typedef boost::function<void(const T1 &, const T2 &, const T3 &, const T4 &, const T5 &, const T6 &)> + function_t; + typedef void (E::*memberFunction_ptr_t)(const T1 &, const T2 &, const T3 &, + const T4 &, const T5 &, const T6 &); + + CommandVoid6(E &entity, function_t function, const std::string &docString) + : Command(entity, + boost::assign::list_of(ValueHelper<T1>::TypeID)( + ValueHelper<T2>::TypeID)(ValueHelper<T3>::TypeID)( + ValueHelper<T4>::TypeID)(ValueHelper<T5>::TypeID)( + ValueHelper<T6>::TypeID), + docString), + fptr(function) {} + +protected: + virtual Value doExecute() { + assert(getParameterValues().size() == 6); + T1 val1 = getParameterValues()[0].value(); + T2 val2 = getParameterValues()[1].value(); + T3 val3 = getParameterValues()[2].value(); + T4 val4 = getParameterValues()[3].value(); + T5 val5 = getParameterValues()[4].value(); + T6 val6 = getParameterValues()[5].value(); + fptr(val1, val2, val3, val4, val5, val6); + return Value(); // void + } + +private: + function_t fptr; +}; + +template <class E, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6> +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) { + return new CommandVoid6<E, T1, T2, T3, T4, T5, T6>(entity, function, docString); +} + +template <class E, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6> +CommandVoid6<E, T1, T2, T3, T4, T5, T6> *makeCommandVoid6( + E &entity, + boost::function<void(E *, const T1 &, const T2 &, const T3 &, const T4 &, const T5 &, const T6 &)> + function, + const std::string &docString) { + return new CommandVoid6<E, T1, T2, T3, T4, T5, T6>( + entity, boost::bind(function, &entity, _1, _2, _3, _4, _5, _6), docString); +} + +template <class E, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6> +CommandVoid6<E, T1, T2, T3, T4, T5, T6> *makeCommandVoid6( + E &entity, + void (E::*function)(const T1 &, const T2 &, const T3 &, const T4 &, const T5 &, const T6 &), + const std::string &docString) { + return new CommandVoid6<E, T1, T2, T3, T4, T5, T6>( + entity, boost::bind(function, &entity, _1, _2, _3, _4, _5, _6), docString); + return NULL; +} + +inline 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) { + return (std::string("\n") + doc + "\n\n" + "Input:\n - A " + type1 + ".\n" + + "Input:\n - A " + type2 + ".\n" + "Input:\n - A " + type3 + ".\n" + + "Input:\n - A " + type4 + ".\n" + "Input:\n - A " + type5 + ".\n" + + "Input:\n - A " + type6 + ".\n" + "Void return.\n\n"); +} + +} // namespace command +} // namespace dynamicgraph + +/* --- FUNCTION 7 ARGS ------------------------------------------------------ */ +namespace dynamicgraph { +namespace command { + +template <class E, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7> +struct CommandVoid7 : public Command { + typedef boost::function<void(const T1 &, const T2 &, const T3 &, const T4 &, const T5 &, const T6 &, const T7 &)> + function_t; + typedef void (E::*memberFunction_ptr_t)(const T1 &, const T2 &, const T3 &, + const T4 &, const T5 &, const T6 &, + const T7 &); + + CommandVoid7(E &entity, function_t function, const std::string &docString) + : Command(entity, + boost::assign::list_of(ValueHelper<T1>::TypeID)( + ValueHelper<T2>::TypeID)(ValueHelper<T3>::TypeID)( + ValueHelper<T4>::TypeID)(ValueHelper<T5>::TypeID)( + ValueHelper<T6>::TypeID)(ValueHelper<T7>::TypeID), + docString), + fptr(function) {} + +protected: + virtual Value doExecute() { + assert(getParameterValues().size() == 7); + T1 val1 = getParameterValues()[0].value(); + T2 val2 = getParameterValues()[1].value(); + T3 val3 = getParameterValues()[2].value(); + T4 val4 = getParameterValues()[3].value(); + T5 val5 = getParameterValues()[4].value(); + T6 val6 = getParameterValues()[5].value(); + T7 val7 = getParameterValues()[6].value(); + fptr(val1, val2, val3, val4, val5, val6, val7); + return Value(); // void + } + +private: + function_t fptr; +}; + +template <class E, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7> +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) { + return new CommandVoid7<E, T1, T2, T3, T4, T5, T6, T7>(entity, function, docString); +} + +template <class E, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7> +CommandVoid7<E, T1, T2, T3, T4, T5, T6, T7> *makeCommandVoid7( + E &entity, + boost::function<void(E *, const T1 &, const T2 &, const T3 &, const T4 &, const T5 &, const T6 &, const T7 &)> + function, + const std::string &docString) { + return new CommandVoid7<E, T1, T2, T3, T4, T5, T6, T7>( + entity, boost::bind(function, &entity, _1, _2, _3, _4, _5, _6, _7), docString); +} + +template <class E, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7> +CommandVoid7<E, T1, T2, T3, T4, T5, T6, T7> *makeCommandVoid7( + E &entity, + void (E::*function)(const T1 &, const T2 &, const T3 &, const T4 &, const T5 &, const T6 &, const T7 &), + const std::string &docString) { + return new CommandVoid7<E, T1, T2, T3, T4, T5, T6, T7>( + entity, boost::bind(function, &entity, _1, _2, _3, _4, _5, _6, _7), docString); + return NULL; +} + +inline 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) { + return (std::string("\n") + doc + "\n\n" + "Input:\n - A " + type1 + ".\n" + + "Input:\n - A " + type2 + ".\n" + "Input:\n - A " + type3 + ".\n" + + "Input:\n - A " + type4 + ".\n" + "Input:\n - A " + type5 + ".\n" + + "Input:\n - A " + type6 + ".\n" + "Input:\n - A " + type7 + ".\n" + + "Void return.\n\n"); +} + +} // namespace command +} // namespace dynamicgraph + +/* --- FUNCTION 8 ARGS ------------------------------------------------------ */ +namespace dynamicgraph { +namespace command { + +template <class E, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> +struct CommandVoid8 : public Command { + typedef boost::function<void(const T1 &, const T2 &, const T3 &, const T4 &, const T5 &, const T6 &, const T7 &, const T8 &)> + function_t; + typedef void (E::*memberFunction_ptr_t)(const T1 &, const T2 &, const T3 &, + const T4 &, const T5 &, const T6 &, + const T7 &, const T8 &); + + CommandVoid8(E &entity, function_t function, const std::string &docString) + : Command(entity, + boost::assign::list_of(ValueHelper<T1>::TypeID)( + ValueHelper<T2>::TypeID)(ValueHelper<T3>::TypeID)( + ValueHelper<T4>::TypeID)(ValueHelper<T5>::TypeID)( + ValueHelper<T6>::TypeID)(ValueHelper<T7>::TypeID)( + ValueHelper<T8>::TypeID), + docString), + fptr(function) {} + +protected: + virtual Value doExecute() { + assert(getParameterValues().size() == 8); + T1 val1 = getParameterValues()[0].value(); + T2 val2 = getParameterValues()[1].value(); + T3 val3 = getParameterValues()[2].value(); + T4 val4 = getParameterValues()[3].value(); + T5 val5 = getParameterValues()[4].value(); + T6 val6 = getParameterValues()[5].value(); + T7 val7 = getParameterValues()[6].value(); + T8 val8 = getParameterValues()[7].value(); + fptr(val1, val2, val3, val4, val5, val6, val7, val8); + return Value(); // void + } + +private: + function_t fptr; +}; + +template <class E, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> +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) { + return new CommandVoid8<E, T1, T2, T3, T4, T5, T6, T7, T8>(entity, function, docString); +} + +template <class E, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> +CommandVoid8<E, T1, T2, T3, T4, T5, T6, T7, T8> *makeCommandVoid8( + E &entity, + boost::function<void(E *, const T1 &, const T2 &, const T3 &, const T4 &, const T5 &, const T6 &, const T7 &, const T8 &)> + function, + const std::string &docString) { + return new CommandVoid8<E, T1, T2, T3, T4, T5, T6, T7, T8>( + entity, boost::bind(function, &entity, _1, _2, _3, _4, _5, _6, _7, _8), docString); +} + +template <class E, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> +CommandVoid8<E, T1, T2, T3, T4, T5, T6, T7, T8> *makeCommandVoid8( + E &entity, + void (E::*function)(const T1 &, const T2 &, const T3 &, const T4 &, const T5 &, const T6 &, const T7 &, const T8 &), + const std::string &docString) { + return new CommandVoid8<E, T1, T2, T3, T4, T5, T6, T7, T8>( + entity, boost::bind(function, &entity, _1, _2, _3, _4, _5, _6, _7, _8), docString); + return NULL; +} + +inline 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) { + return (std::string("\n") + doc + "\n\n" + "Input:\n - A " + type1 + ".\n" + + "Input:\n - A " + type2 + ".\n" + "Input:\n - A " + type3 + ".\n" + + "Input:\n - A " + type4 + ".\n" + "Input:\n - A " + type5 + ".\n" + + "Input:\n - A " + type6 + ".\n" + "Input:\n - A " + type7 + ".\n" + + "Input:\n - A " + type8 + ".\n" + "Void return.\n\n"); +} + +} // namespace command +} // namespace dynamicgraph + /* --- FUNCTION VERBOSE ----------------------------------------------------- */ /* This bind a function void f( ostream& ) that display some results into * a string f( void ) that return some string results. */ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4cd68f477370b37070c2efcc88b943023505c86e..279868d4ceaf375e9e97461aa34c74fdb5e1a729 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -9,7 +9,7 @@ SET(tracer-real-time_deps tracer) FOREACH(plugin ${plugins}) GET_FILENAME_COMPONENT(LIBRARY_NAME ${plugin} NAME) - ADD_LIBRARY(${LIBRARY_NAME} SHARED ${plugin}) + ADD_LIBRARY(${LIBRARY_NAME} SHARED "${plugin}.cpp") IF(SUFFIX_SO_VERSION) SET_TARGET_PROPERTIES(${LIBRARY_NAME} PROPERTIES SOVERSION ${PROJECT_VERSION}) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 0a28a35fe3d79013a79037c6ed2db5c74e1b3a3b..b323c6c7adb8db4d08ba55b41c95b79942c9261c 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -7,7 +7,7 @@ ADD_DEFINITIONS(-DTESTS_PLUGINDIR="${LIBRARY_OUTPUT_PATH}") ADD_DEFINITIONS(-DTESTS_DYNLIBSUFFIX="${CMAKE_SHARED_LIBRARY_SUFFIX}") MACRO(DYNAMIC_GRAPH_TEST NAME) - ADD_UNIT_TEST(${NAME} ${NAME}.cpp) + ADD_UNIT_TEST(${NAME} "${NAME}.cpp") TARGET_LINK_LIBRARIES(${NAME} PRIVATE ${PROJECT_NAME} Boost::unit_test_framework) ENDMACRO(DYNAMIC_GRAPH_TEST) @@ -15,7 +15,7 @@ ENDMACRO(DYNAMIC_GRAPH_TEST) SET(signalcast_libs signal-cast-registerer-libA signal-cast-registerer-libB) FOREACH(lib ${signalcast_libs}) - ADD_LIBRARY(${lib} SHARED ${lib}) + ADD_LIBRARY(${lib} SHARED "${lib}.cpp") TARGET_LINK_LIBRARIES(${lib} PRIVATE ${PROJECT_NAME}) ENDFOREACH()