Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • cberge/dynamic-graph
  • ostasse/dynamic-graph
  • gsaurel/dynamic-graph
  • stack-of-tasks/dynamic-graph
4 results
Show changes
Showing
with 813 additions and 196 deletions
......@@ -62,6 +62,6 @@ load classes of entities and create instances of entities.</p>
\li Type-safe connection of input and output signals
\li On-demand signal computation as well as a caching system for signal values
allow fast computation of signal values, which is a critical point for real-time
systems\n See \ref scriptingabout
systems\n
*/
......@@ -10,8 +10,8 @@ are recorded to a memory buffer, which can be emptied at any time.
The \b commands that this entity exposes are:
\code
empty (discards all buffers)
buffersize (sets buffer size for recording)
trace (writes traces to files)
getBufferSize (gets buffer size for recording)
setBufferSize (sets buffer size for recording)
\endcode
Plus all the commands exposed by \ref tracerdoc
\n
......
/* Customizing Doxygen output */
/* Needed to allow line breaks in tables*/
.memberdecls {
table-layout: fixed;
width: 100%;
}
/* Needed to break long template names*/
.memTemplItemLeft {
white-space: normal !important;
word-wrap: break-word;
}
/* Needed to break long template names*/
.memItemLeft {
white-space: normal !important;
word-wrap: break-word;
}
<!-- HTML header for doxygen 1.8.11-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen $doxygenversion"/>
<!--BEGIN PROJECT_NAME--><title>$projectname: $title</title><!--END PROJECT_NAME-->
<!--BEGIN !PROJECT_NAME--><title>$title</title><!--END !PROJECT_NAME-->
<link href="$relpath^tabs.css" rel="stylesheet" type="text/css"/>
<link href="$relpath^sot.ico" rel="icon" type="image/x-icon">
<script type="text/javascript" src="$relpath^jquery.js"></script>
<script type="text/javascript" src="$relpath^dynsections.js"></script>
$treeview
$search
$mathjax
<link href="$relpath^$stylesheet" rel="stylesheet" type="text/css" />
$extrastylesheet
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<!--BEGIN TITLEAREA-->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<!--BEGIN PROJECT_LOGO-->
<td id="projectlogo"><img alt="Logo" src="$relpath^$projectlogo"/></td>
<!--END PROJECT_LOGO-->
<!--BEGIN PROJECT_NAME-->
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">$projectname
<!--BEGIN PROJECT_NUMBER-->&#160;<span id="projectnumber">$projectnumber</span><!--END PROJECT_NUMBER-->
</div>
<!--BEGIN PROJECT_BRIEF--><div id="projectbrief">$projectbrief</div><!--END PROJECT_BRIEF-->
</td>
<!--END PROJECT_NAME-->
<!--BEGIN !PROJECT_NAME-->
<!--BEGIN PROJECT_BRIEF-->
<td style="padding-left: 0.5em;">
<div id="projectbrief">$projectbrief</div>
</td>
<!--END PROJECT_BRIEF-->
<!--END !PROJECT_NAME-->
<!--BEGIN DISABLE_INDEX-->
<!--BEGIN SEARCHENGINE-->
<td>$searchbox</td>
<!--END SEARCHENGINE-->
<!--END DISABLE_INDEX-->
</tr>
</tbody>
</table>
</div>
<!--END TITLEAREA-->
<!-- end header part -->
File moved
......@@ -9,7 +9,7 @@
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
id="svg2"
version="1.1"
inkscape:version="0.47 r22583"
......
doc/pictures/sot.ico

4.98 KiB

doc/pictures/sot.png

2.78 KiB

File moved
......@@ -15,4 +15,4 @@
#include <dynamic-graph/command-setter.h>
#include <dynamic-graph/command.h>
#endif //! DYNAMIC_GRAPH_ALL_COMMANDS_H
#endif //! DYNAMIC_GRAPH_ALL_COMMANDS_H
......@@ -12,4 +12,4 @@
#include <dynamic-graph/signal-time-dependent.h>
#include <dynamic-graph/signal.h>
#endif //! DYNAMIC_GRAPH_ALL_SIGNALS_H
#endif //! DYNAMIC_GRAPH_ALL_SIGNALS_H
......@@ -20,28 +20,30 @@
*
*/
#include "dynamic-graph/command.h"
#include <boost/assign/list_of.hpp>
#include <boost/bind.hpp>
#include <boost/function.hpp>
#include "dynamic-graph/command.h"
/* --- FUNCTION 0 ARGS ----------------------------------------------------- */
namespace dynamicgraph {
namespace command {
template <class E> struct CommandVoid0 : public Command {
template <class E>
struct CommandVoid0 : public Command {
CommandVoid0(E &entity, boost::function<void(void)> function,
const std::string &docString)
: Command(entity, EMPTY_ARG, docString), fptr(function) {}
protected:
protected:
virtual Value doExecute() {
assert(getParameterValues().size() == 0);
fptr();
return Value(); // void
return Value(); // void
}
private:
private:
boost::function<void(void)> fptr;
};
......@@ -69,49 +71,47 @@ inline std::string docCommandVoid0(const std::string &doc) {
return std::string("\n") + doc + "\n\nNo input.\nVoid return.\n\n";
}
} // namespace command
} // namespace dynamicgraph
} // namespace command
} // namespace dynamicgraph
/* --- FUNCTION 1 ARGS ------------------------------------------------------ */
namespace dynamicgraph {
namespace command {
template <class E, typename T> struct CommandVoid1 : public Command {
template <class E, typename T>
struct CommandVoid1 : public Command {
typedef boost::function<void(const T &)> function_t;
typedef boost::function<void(E *, const T &)> memberFunction_t;
typedef void (E::*memberFunction_ptr_t)(const T &);
CommandVoid1(E &entity, function_t function, const std::string &docString)
: Command(entity, boost::assign::list_of(ValueHelper<T>::TypeID),
docString),
fptr(function) {}
protected:
protected:
virtual Value doExecute() {
assert(getParameterValues().size() == 1);
T val = getParameterValues()[0].value();
fptr(val);
return Value(); // void
return Value(); // void
}
private:
private:
function_t fptr;
};
template <class E, typename T>
CommandVoid1<E, T> *
makeCommandVoid1(E &entity, boost::function<void(const T &)> function,
// typename CommandVoid1<E,T>::function_t function ,
const std::string &docString) {
CommandVoid1<E, T> *makeCommandVoid1(
E &entity, boost::function<void(const T &)> function,
// typename CommandVoid1<E,T>::function_t function ,
const std::string &docString) {
return new CommandVoid1<E, T>(entity, function, docString);
}
template <class E, typename T>
CommandVoid1<E, T> *makeCommandVoid1(
E &entity,
// The following syntaxt don't compile when not specializing the template
// arg... why ???
// typename CommandVoid1<E,T>::memberFunction_t function ,
// The following syntaxt don't compile when not specializing
// the template arg... why ???
boost::function<void(E *, const T &)> function,
const std::string &docString) {
return new CommandVoid1<E, T>(entity, boost::bind(function, &entity, _1),
......@@ -132,8 +132,8 @@ inline std::string docCommandVoid1(const std::string &doc,
".\nVoid return.\n\n";
}
} // namespace command
} // namespace dynamicgraph
} // namespace command
} // namespace dynamicgraph
/* --- FUNCTION 2 ARGS ------------------------------------------------------ */
namespace dynamicgraph {
......@@ -142,8 +142,6 @@ namespace command {
template <class E, typename T1, typename T2>
struct CommandVoid2 : public Command {
typedef boost::function<void(const T1 &, const T2 &)> function_t;
typedef boost::function<void(E *, const T1 &, const T2 &)> memberFunction_t;
typedef void (E::*memberFunction_ptr_t)(const T1 &, const T2 &);
CommandVoid2(E &entity, function_t function, const std::string &docString)
: Command(entity,
......@@ -152,33 +150,31 @@ struct CommandVoid2 : public Command {
docString),
fptr(function) {}
protected:
protected:
virtual Value doExecute() {
assert(getParameterValues().size() == 2);
T1 val1 = getParameterValues()[0].value();
T2 val2 = getParameterValues()[1].value();
fptr(val1, val2);
return Value(); // void
return Value(); // void
}
private:
private:
function_t fptr;
};
template <class E, typename T1, typename T2>
CommandVoid2<E, T1, T2> *
makeCommandVoid2(E &entity,
boost::function<void(const T1 &, const T2 &)> function,
const std::string &docString) {
CommandVoid2<E, T1, T2> *makeCommandVoid2(
E &entity, boost::function<void(const T1 &, const T2 &)> function,
const std::string &docString) {
return new CommandVoid2<E, T1, T2>(entity, function, docString);
}
template <class E, typename T1, typename T2>
CommandVoid2<E, T1, T2> *makeCommandVoid2(
E &entity,
// The following syntaxt don't compile when not specializing the template
// arg... why ???
// typename CommandVoid2<E,T1,T2>::memberFunction_t function ,
// The following syntaxt don't compile when not specializing
// the template arg... why ???
boost::function<void(E *, const T1 &, const T2 &)> function,
const std::string &docString) {
return new CommandVoid2<E, T1, T2>(
......@@ -186,9 +182,10 @@ CommandVoid2<E, T1, T2> *makeCommandVoid2(
}
template <class E, typename T1, typename T2>
CommandVoid2<E, T1, T2> *
makeCommandVoid2(E &entity, void (E::*function)(const T1 &, const T2 &),
const std::string &docString) {
CommandVoid2<E, T1, T2> *makeCommandVoid2(E &entity,
void (E::*function)(const T1 &,
const T2 &),
const std::string &docString) {
return new CommandVoid2<E, T1, T2>(
entity, boost::bind(function, &entity, _1, _2), docString);
return NULL;
......@@ -201,8 +198,8 @@ inline std::string docCommandVoid2(const std::string &doc,
"Input:\n - A " + type2 + ".\n" + "Void return.\n\n");
}
} // namespace command
} // namespace dynamicgraph
} // namespace command
} // namespace dynamicgraph
/* --- FUNCTION 3 ARGS ------------------------------------------------------ */
namespace dynamicgraph {
......@@ -211,9 +208,6 @@ namespace command {
template <class E, typename T1, typename T2, typename T3>
struct CommandVoid3 : public Command {
typedef boost::function<void(const T1 &, const T2 &, const T3 &)> function_t;
typedef boost::function<void(E *, const T1 &, const T2 &, const T3 &)>
memberFunction_t;
typedef void (E::*memberFunction_ptr_t)(const T1 &, const T2 &, const T3);
CommandVoid3(E &entity, function_t function, const std::string &docString)
: Command(entity,
......@@ -222,25 +216,24 @@ struct CommandVoid3 : public Command {
docString),
fptr(function) {}
protected:
protected:
virtual Value doExecute() {
assert(getParameterValues().size() == 3);
T1 val1 = getParameterValues()[0].value();
T2 val2 = getParameterValues()[1].value();
T3 val3 = getParameterValues()[2].value();
fptr(val1, val2, val3);
return Value(); // void
return Value(); // void
}
private:
private:
function_t fptr;
};
template <class E, typename T1, typename T2, typename T3>
CommandVoid3<E, T1, T2, T3> *
makeCommandVoid3(E &entity,
typename CommandVoid3<E, T1, T2, T3>::function_t function,
const std::string &docString) {
CommandVoid3<E, T1, T2, T3> *makeCommandVoid3(
E &entity, typename CommandVoid3<E, T1, T2, T3>::function_t function,
const std::string &docString) {
return new CommandVoid3<E, T1, T2, T3>(entity, function, docString);
}
......@@ -249,7 +242,6 @@ CommandVoid3<E, T1, T2, T3> *makeCommandVoid3(
E &entity,
// The following syntaxt don't compile when not specializing the template
// arg... why ???
// typename CommandVoid3<E,T1,T2>::memberFunction_t function ,
boost::function<void(E *, const T1 &, const T2 &, const T3 &)> function,
const std::string &docString) {
return new CommandVoid3<E, T1, T2, T3>(
......@@ -257,10 +249,9 @@ CommandVoid3<E, T1, T2, T3> *makeCommandVoid3(
}
template <class E, typename T1, typename T2, typename T3>
CommandVoid3<E, T1, T2, T3> *
makeCommandVoid3(E &entity,
void (E::*function)(const T1 &, const T2 &, const T3 &),
const std::string &docString) {
CommandVoid3<E, T1, T2, T3> *makeCommandVoid3(
E &entity, void (E::*function)(const T1 &, const T2 &, const T3 &),
const std::string &docString) {
return new CommandVoid3<E, T1, T2, T3>(
entity, boost::bind(function, &entity, _1, _2, _3), docString);
return NULL;
......@@ -275,8 +266,8 @@ inline std::string docCommandVoid3(const std::string &doc,
"Void return.\n\n");
}
} // namespace command
} // namespace dynamicgraph
} // namespace command
} // namespace dynamicgraph
/* --- FUNCTION 4 ARGS ------------------------------------------------------ */
namespace dynamicgraph {
......@@ -286,9 +277,6 @@ template <class E, typename T1, typename T2, typename T3, typename T4>
struct CommandVoid4 : public Command {
typedef boost::function<void(const T1 &, const T2 &, const T3 &, const T4 &)>
function_t;
typedef boost::function<void(E *, const T1 &, const T2 &, const T3 &,
const T4 &)>
memberFunction_t;
typedef void (E::*memberFunction_ptr_t)(const T1 &, const T2 &, const T3 &,
const T4 &);
......@@ -300,7 +288,7 @@ struct CommandVoid4 : public Command {
docString),
fptr(function) {}
protected:
protected:
virtual Value doExecute() {
assert(getParameterValues().size() == 4);
T1 val1 = getParameterValues()[0].value();
......@@ -308,18 +296,17 @@ protected:
T3 val3 = getParameterValues()[2].value();
T4 val4 = getParameterValues()[3].value();
fptr(val1, val2, val3, val4);
return Value(); // void
return Value(); // void
}
private:
private:
function_t fptr;
};
template <class E, typename T1, typename T2, typename T3, typename T4>
CommandVoid4<E, T1, T2, T3, T4> *
makeCommandVoid4(E &entity,
typename CommandVoid4<E, T1, T2, T3, T4>::function_t function,
const std::string &docString) {
CommandVoid4<E, T1, T2, T3, T4> *makeCommandVoid4(
E &entity, typename CommandVoid4<E, T1, T2, T3, T4>::function_t function,
const std::string &docString) {
return new CommandVoid4<E, T1, T2, T3, T4>(entity, function, docString);
}
......@@ -353,8 +340,368 @@ inline std::string docCommandVoid4(const std::string &doc,
"Input:\n - A " + type4 + ".\n" + "Void return.\n\n");
}
} // namespace command
} // namespace dynamicgraph
} // 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
......@@ -362,51 +709,37 @@ inline std::string docCommandVoid4(const std::string &doc,
namespace dynamicgraph {
namespace command {
template <class E> struct CommandVerbose : public Command {
template <class E>
struct CommandVerbose : public Command {
typedef boost::function<void(std::ostream &)> function_t;
typedef boost::function<void(E *, std::ostream &)> memberFunction_t;
typedef void (E::*memberFunctionConst_ptr_t)(std::ostream &) const;
typedef void (E::*memberFunction_ptr_t)(std::ostream &);
CommandVerbose(E &entity, function_t function, const std::string &docString)
: Command(entity, EMPTY_ARG, docString), fptr(function) {}
protected:
protected:
virtual Value doExecute() {
assert(getParameterValues().size() == 0);
std::ostringstream oss;
fptr(oss);
return Value(oss.str()); // return string
return Value(oss.str()); // return string
}
private:
private:
function_t fptr;
};
template <class E>
CommandVerbose<E> *
makeCommandVerbose(E &entity, typename CommandVerbose<E>::function_t function,
const std::string &docString) {
return new CommandVerbose<E>(entity, function, docString);
return NULL;
}
template <class E>
CommandVerbose<E> *makeCommandVerbose(
E &entity,
// void (E::*function) (std::ostream&) const,
typename CommandVerbose<E>::memberFunctionConst_ptr_t function,
E &entity, typename CommandVerbose<E>::function_t function,
const std::string &docString) {
return new CommandVerbose<E>(entity, boost::bind(function, &entity, _1),
docString);
return new CommandVerbose<E>(entity, function, docString);
return NULL;
}
template <class E>
CommandVerbose<E> *
makeCommandVerbose(E &entity,
typename CommandVerbose<E>::memberFunction_ptr_t function,
const std::string &docString) {
CommandVerbose<E> *makeCommandVerbose(E &entity,
void (E::*function)(std::ostream &),
const std::string &docString) {
return new CommandVerbose<E>(entity, boost::bind(function, &entity, _1),
docString);
return NULL;
......@@ -415,8 +748,189 @@ makeCommandVerbose(E &entity,
inline std::string docCommandVerbose(const std::string &doc) {
return std::string("\n") + doc + "\n\nNo input.\n Return a string.\n\n";
}
/*************************/
/* Template return types */
/*************************/
template <class E, class ReturnType>
struct CommandReturnType0 : public Command {
CommandReturnType0(E &entity, boost::function<ReturnType(void)> function,
const std::string &docString)
: Command(entity, EMPTY_ARG, docString), fptr(function) {}
protected:
virtual Value doExecute() {
assert(getParameterValues().size() == 0);
Value res(fptr());
return res;
}
private:
boost::function<ReturnType(void)> fptr;
};
template <class E, class ReturnType>
CommandReturnType0<E, ReturnType> *makeCommandReturnType0(
E &entity, boost::function<ReturnType(void)> function,
const std::string &docString) {
return new CommandReturnType0<E, ReturnType>(entity, function, docString);
}
template <class E, class ReturnType>
CommandReturnType0<E, ReturnType> *makeCommandReturnType0(
E &entity, boost::function<ReturnType(E *)> function,
const std::string &docString) {
return new CommandReturnType0<E, ReturnType>(
entity, boost::bind(function, &entity), docString);
}
template <class E, class ReturnType>
CommandReturnType0<E, ReturnType> *makeCommandReturnType0(
E &entity, ReturnType (E::*function)(void), const std::string &docString) {
return new CommandReturnType0<E, ReturnType>(
entity, boost::bind(function, &entity), docString);
}
template <typename ReturnType>
inline std::string docCommandReturnType0(
const std::string &doc, const std::string & /* return_type */) {
return std::string("\n") + doc + "\n\nNo input.\n" +
typeid(ReturnType).name() + " return.\n\n";
}
} // namespace command
} // namespace dynamicgraph
/* --- FUNCTION 1 ARGS ------------------------------------------------------ */
namespace dynamicgraph {
namespace command {
template <class E, typename ReturnType, typename T>
struct CommandReturnType1 : public Command {
typedef boost::function<ReturnType(const T &)> function_t;
CommandReturnType1(E &entity, function_t function,
const std::string &docString)
: Command(entity, boost::assign::list_of(ValueHelper<T>::TypeID),
docString),
fptr(function) {}
protected:
virtual Value doExecute() {
assert(getParameterValues().size() == 1);
T val = getParameterValues()[0].value();
Value res(fptr(val));
return res;
}
private:
function_t fptr;
};
template <class E, typename ReturnType, typename T>
CommandReturnType1<E, ReturnType, T> *makeCommandReturnType1(
E &entity, boost::function<ReturnType(const T &)> function,
const std::string &docString) {
return new CommandReturnType1<E, ReturnType, T>(entity, function, docString);
}
template <class E, typename ReturnType, typename T>
CommandReturnType1<E, ReturnType, T> *makeCommandReturnType1(
E &entity,
// The following syntaxt don't compile when not
// specializing the template arg... why ???
boost::function<ReturnType(E *, const T &)> function,
const std::string &docString) {
return new CommandReturnType1<E, ReturnType, T>(
entity, boost::bind(function, &entity, _1), docString);
}
template <class E, typename ReturnType, typename T>
CommandReturnType1<E, ReturnType, T> *makeCommandReturnType1(
E &entity, ReturnType (E::*function)(const T &),
const std::string &docString) {
return new CommandReturnType1<E, ReturnType, T>(
entity, boost::bind(function, &entity, _1), docString);
return NULL;
}
template <typename ReturnType>
inline std::string docCommandReturnType1(const std::string &doc,
const std::string &type) {
return std::string("\n") + doc + "\n\nInput:\n - A " + type + ".\n" +
typeid(ReturnType).name() + "return.\n\n";
}
} // namespace command
} // namespace dynamicgraph
/*********** FUNCTION 2 Arguments ************************/
namespace dynamicgraph {
namespace command {
template <class E, typename ReturnType, typename T1, typename T2>
struct CommandReturnType2 : public Command {
typedef boost::function<ReturnType(const T1 &, const T2 &)> function_t;
CommandReturnType2(E &entity, function_t function,
const std::string &docString)
: Command(entity,
boost::assign::list_of(ValueHelper<T1>::TypeID)(
ValueHelper<T2>::TypeID),
docString),
fptr(function) {}
protected:
virtual Value doExecute() {
assert(getParameterValues().size() == 2);
T1 val1 = getParameterValues()[0].value();
T2 val2 = getParameterValues()[1].value();
Value res(fptr(val1, val2));
return res;
}
private:
function_t fptr;
};
template <class E, typename ReturnType, typename T1, typename T2>
CommandReturnType2<E, ReturnType, T1, T2> *makeCommandReturnType2(
E &entity, boost::function<ReturnType(const T1 &, const T2 &)> function,
const std::string &docString) {
return new CommandReturnType2<E, ReturnType, T1, T2>(entity, function,
docString);
}
template <class E, typename ReturnType, typename T1, typename T2>
CommandReturnType2<E, ReturnType, T1, T2> *makeCommandReturnType2(
E &entity,
// The following syntaxt don't compile when not specializing the template
// arg... why ???
boost::function<ReturnType(E *, const T1 &, const T2 &)> function,
const std::string &docString) {
return new CommandReturnType2<E, ReturnType, T1, T2>(
entity, boost::bind(function, &entity, _1, _2), docString);
}
template <class E, typename ReturnType, typename T1, typename T2>
CommandReturnType2<E, ReturnType, T1, T2> *makeCommandReturnType2(
E &entity, ReturnType (E::*function)(const T1 &, const T2 &),
const std::string &docString) {
return new CommandReturnType2<E, ReturnType, T1, T2>(
entity, boost::bind(function, &entity, _1, _2), docString);
return NULL;
}
template <typename ReturnType>
inline std::string docCommandReturnType2(const std::string &doc,
const std::string &type1,
const std::string &type2) {
return (std::string("\n") + doc + "\n\n" + "Input:\n - A " + type1 + ".\n" +
"Input:\n - A " + type2 + ".\n" +
"ReturnType:\n - Returns:" + typeid(ReturnType).name() + +".\n\n");
}
} // namespace command
} // namespace dynamicgraph
} // namespace command
} // namespace dynamicgraph
#endif // __dg_command_bind_h__
#endif // __dg_command_bind_h__
......@@ -15,15 +15,17 @@
*
*/
#include "dynamic-graph/command.h"
#include <boost/assign/list_of.hpp>
#include "dynamic-graph/command.h"
/* --- GETTER --------------------------------------------------------- */
namespace dynamicgraph {
namespace command {
template <class E, typename T> class DirectGetter : public Command {
public:
template <class E, typename T>
class DirectGetter : public Command {
public:
/// Pointer to method that sets parameter of type T
typedef T (E::*GetterMethod)() const;
......@@ -31,10 +33,10 @@ public:
DirectGetter(E &entity, T *ptr, const std::string &docString)
: Command(entity, std::vector<Value::Type>(), docString), T_ptr(ptr) {}
protected:
protected:
virtual Value doExecute() { return Value(*T_ptr); }
private:
private:
T *T_ptr;
};
......@@ -50,7 +52,7 @@ inline std::string docDirectGetter(const std::string &name,
type + ".\n\n";
}
} // namespace command
} // namespace dynamicgraph
} // namespace command
} // namespace dynamicgraph
#endif // __dg_command_direct_getter_h__
#endif // __dg_command_direct_getter_h__
......@@ -15,29 +15,31 @@
*
*/
#include "dynamic-graph/command.h"
#include <boost/assign/list_of.hpp>
#include "dynamic-graph/command.h"
/* --- SETTER --------------------------------------------------------- */
namespace dynamicgraph {
namespace command {
template <class E, typename T> class DirectSetter : public Command {
public:
template <class E, typename T>
class DirectSetter : public Command {
public:
DirectSetter(E &entity, T *ptr, const std::string &docString)
: Command(entity, boost::assign::list_of(ValueHelper<T>::TypeID),
docString),
T_ptr(ptr) {}
protected:
protected:
virtual Value doExecute() {
const std::vector<Value> &values = getParameterValues();
T val = values[0].value();
(*T_ptr) = val;
return Value(); // void
return Value(); // void
}
private:
private:
T *T_ptr;
};
......@@ -53,7 +55,7 @@ inline std::string docDirectSetter(const std::string &name,
".\nVoid return.\n\n";
}
} // namespace command
} // namespace dynamicgraph
} // namespace command
} // namespace dynamicgraph
#endif // __dg_command_direct_setter_h__
#endif // __dg_command_direct_setter_h__
......@@ -41,21 +41,22 @@ namespace command {
/// \li T should be a type supported by class Value,
/// \li prototype of E::getParameter should be exactly as specified in this
/// example.
template <class E, typename T> class Getter : public Command {
public:
template <class E, typename T>
class Getter : public Command {
public:
/// Pointer to method that sets parameter of type T
typedef T (E::*GetterMethod)() const;
/// Constructor
Getter(E &entity, GetterMethod getterMethod, const std::string &docString);
protected:
protected:
virtual Value doExecute();
private:
private:
GetterMethod getterMethod_;
};
} // namespace command
} // namespace dynamicgraph
} // namespace command
} // namespace dynamicgraph
#include "dynamic-graph/command-getter.t.cpp"
#endif // DYNAMIC_GRAPH_COMMAND_GETTER_H
#endif // DYNAMIC_GRAPH_COMMAND_GETTER_H
......@@ -8,6 +8,7 @@
#define DYNAMIC_GRAPH_COMMAND_GETTER_T_CPP
#include "dynamic-graph/command-getter.h"
#include <sstream>
namespace dynamicgraph {
......@@ -20,12 +21,13 @@ Getter<E, T>::Getter(E &entity, GetterMethod getterMethod,
: Command(entity, std::vector<Value::Type>(), docstring),
getterMethod_(getterMethod) {}
template <class E, typename T> Value Getter<E, T>::doExecute() {
template <class E, typename T>
Value Getter<E, T>::doExecute() {
E &entity = static_cast<E &>(owner());
T value = (entity.*getterMethod_)();
return Value(value);
}
} // namespace command
} // namespace dynamicgraph
} // namespace command
} // namespace dynamicgraph
#endif // DYNAMIC_GRAPH_COMMAND_GETTER_T_CPP
#endif // DYNAMIC_GRAPH_COMMAND_GETTER_T_CPP
......@@ -41,21 +41,22 @@ namespace command {
/// \li T should be a type supported by class Value,
/// \li prototype of E::setParameter should be exactly as specified in this
/// example.
template <class E, typename T> class Setter : public Command {
public:
template <class E, typename T>
class Setter : public Command {
public:
/// Pointer to method that sets parameter of type T
typedef void (E::*SetterMethod)(const T &);
/// Constructor
Setter(E &entity, SetterMethod setterMethod, const std::string &docString);
protected:
protected:
virtual Value doExecute();
private:
private:
SetterMethod setterMethod_;
};
} // namespace command
} // namespace dynamicgraph
} // namespace command
} // namespace dynamicgraph
#include "dynamic-graph/command-setter.t.cpp"
#endif // DYNAMIC_GRAPH_COMMAND_SETTER_H
#endif // DYNAMIC_GRAPH_COMMAND_SETTER_H
......@@ -8,10 +8,12 @@
#define DYNAMIC_GRAPH_COMMAND_SETTER_T_CPP
#include "dynamic-graph/command-setter.h"
#include "dynamic-graph/linear-algebra.h"
#include <boost/assign/list_of.hpp>
#include <sstream>
#include "dynamic-graph/linear-algebra.h"
namespace dynamicgraph {
class Entity;
namespace command {
......@@ -19,19 +21,20 @@ namespace command {
//
// Template specialization: bool
//
template <class E> class Setter<E, bool> : public Command {
public:
template <class E>
class Setter<E, bool> : public Command {
public:
/// Pointer to method that sets parameter of type bool
typedef void (E::*SetterMethod)(const bool &);
/// Constructor
Setter(E &entity, SetterMethod setterMethod, const std::string &docString);
protected:
protected:
virtual Value doExecute();
private:
private:
SetterMethod setterMethod_;
}; // Class Setter
}; // Class Setter
template <class E>
Setter<E, bool>::Setter(E &entity, SetterMethod setterMethod,
......@@ -39,7 +42,8 @@ Setter<E, bool>::Setter(E &entity, SetterMethod setterMethod,
: Command(entity, boost::assign::list_of(Value::BOOL), docString),
setterMethod_(setterMethod) {}
template <class E> Value Setter<E, bool>::doExecute() {
template <class E>
Value Setter<E, bool>::doExecute() {
const std::vector<Value> &values = getParameterValues();
// Get parameter
bool value = values[0].value();
......@@ -51,19 +55,20 @@ template <class E> Value Setter<E, bool>::doExecute() {
//
// Template specialization: unsigned
//
template <class E> class Setter<E, unsigned> : public Command {
public:
template <class E>
class Setter<E, unsigned> : public Command {
public:
/// Pointer to method that sets parameter of type unsigned
typedef void (E::*SetterMethod)(const unsigned &);
/// Constructor
Setter(E &entity, SetterMethod setterMethod, const std::string &docString);
protected:
protected:
virtual Value doExecute();
private:
private:
SetterMethod setterMethod_;
}; // Class Setter
}; // Class Setter
template <class E>
Setter<E, unsigned>::Setter(E &entity, SetterMethod setterMethod,
......@@ -71,7 +76,8 @@ Setter<E, unsigned>::Setter(E &entity, SetterMethod setterMethod,
: Command(entity, boost::assign::list_of(Value::UNSIGNED), docString),
setterMethod_(setterMethod) {}
template <class E> Value Setter<E, unsigned>::doExecute() {
template <class E>
Value Setter<E, unsigned>::doExecute() {
const std::vector<Value> &values = getParameterValues();
// Get parameter
unsigned value = values[0].value();
......@@ -83,19 +89,20 @@ template <class E> Value Setter<E, unsigned>::doExecute() {
//
// Template specialization: int
//
template <class E> class Setter<E, int> : public Command {
public:
template <class E>
class Setter<E, int> : public Command {
public:
/// Pointer to method that sets parameter of type int
typedef void (E::*SetterMethod)(const int &);
/// Constructor
Setter(E &entity, SetterMethod setterMethod, const std::string &docString);
protected:
protected:
virtual Value doExecute();
private:
private:
SetterMethod setterMethod_;
}; // Class Setter
}; // Class Setter
template <class E>
Setter<E, int>::Setter(E &entity, SetterMethod setterMethod,
......@@ -103,7 +110,8 @@ Setter<E, int>::Setter(E &entity, SetterMethod setterMethod,
: Command(entity, boost::assign::list_of(Value::INT), docString),
setterMethod_(setterMethod) {}
template <class E> Value Setter<E, int>::doExecute() {
template <class E>
Value Setter<E, int>::doExecute() {
const std::vector<Value> &values = getParameterValues();
// Get parameter
int value = values[0].value();
......@@ -115,19 +123,20 @@ template <class E> Value Setter<E, int>::doExecute() {
//
// Template specialization: float
//
template <class E> class Setter<E, float> : public Command {
public:
template <class E>
class Setter<E, float> : public Command {
public:
/// Pointer to method that sets parameter of type float
typedef void (E::*SetterMethod)(const float &);
/// Constructor
Setter(E &entity, SetterMethod setterMethod, const std::string &docString);
protected:
protected:
virtual Value doExecute();
private:
private:
SetterMethod setterMethod_;
}; // Class Setter
}; // Class Setter
template <class E>
Setter<E, float>::Setter(E &entity, SetterMethod setterMethod,
......@@ -135,7 +144,8 @@ Setter<E, float>::Setter(E &entity, SetterMethod setterMethod,
: Command(entity, boost::assign::list_of(Value::FLOAT), docString),
setterMethod_(setterMethod) {}
template <class E> Value Setter<E, float>::doExecute() {
template <class E>
Value Setter<E, float>::doExecute() {
const std::vector<Value> &values = getParameterValues();
// Get parameter
float value = values[0].value();
......@@ -147,19 +157,20 @@ template <class E> Value Setter<E, float>::doExecute() {
//
// Template specialization: double
//
template <class E> class Setter<E, double> : public Command {
public:
template <class E>
class Setter<E, double> : public Command {
public:
/// Pointer to method that sets parameter of type double
typedef void (E::*SetterMethod)(const double &);
/// Constructor
Setter(E &entity, SetterMethod setterMethod, const std::string &docString);
protected:
protected:
virtual Value doExecute();
private:
private:
SetterMethod setterMethod_;
}; // Class Setter
}; // Class Setter
template <class E>
Setter<E, double>::Setter(E &entity, SetterMethod setterMethod,
......@@ -167,7 +178,8 @@ Setter<E, double>::Setter(E &entity, SetterMethod setterMethod,
: Command(entity, boost::assign::list_of(Value::DOUBLE), docString),
setterMethod_(setterMethod) {}
template <class E> Value Setter<E, double>::doExecute() {
template <class E>
Value Setter<E, double>::doExecute() {
const std::vector<Value> &values = getParameterValues();
// Get parameter
double value = values[0].value();
......@@ -179,19 +191,20 @@ template <class E> Value Setter<E, double>::doExecute() {
//
// Template specialization: std::string
//
template <class E> class Setter<E, std::string> : public Command {
public:
template <class E>
class Setter<E, std::string> : public Command {
public:
/// Pointer to method that sets parameter of type std::string
typedef void (E::*SetterMethod)(const std::string &);
/// Constructor
Setter(E &entity, SetterMethod setterMethod, const std::string &docString);
protected:
protected:
virtual Value doExecute();
private:
private:
SetterMethod setterMethod_;
}; // Class Setter
}; // Class Setter
template <class E>
Setter<E, std::string>::Setter(E &entity, SetterMethod setterMethod,
......@@ -199,7 +212,8 @@ Setter<E, std::string>::Setter(E &entity, SetterMethod setterMethod,
: Command(entity, boost::assign::list_of(Value::STRING), docString),
setterMethod_(setterMethod) {}
template <class E> Value Setter<E, std::string>::doExecute() {
template <class E>
Value Setter<E, std::string>::doExecute() {
const std::vector<Value> &values = getParameterValues();
// Get parameter
std::string value = values[0].value();
......@@ -211,19 +225,20 @@ template <class E> Value Setter<E, std::string>::doExecute() {
//
// Template specialization: Vector
//
template <class E> class Setter<E, Vector> : public Command {
public:
template <class E>
class Setter<E, Vector> : public Command {
public:
/// Pointer to method that sets parameter of type Vector
typedef void (E::*SetterMethod)(const Vector &);
/// Constructor
Setter(E &entity, SetterMethod setterMethod, const std::string &docString);
protected:
protected:
virtual Value doExecute();
private:
private:
SetterMethod setterMethod_;
}; // Class Setter
}; // Class Setter
template <class E>
Setter<E, Vector>::Setter(E &entity, SetterMethod setterMethod,
......@@ -231,7 +246,8 @@ Setter<E, Vector>::Setter(E &entity, SetterMethod setterMethod,
: Command(entity, boost::assign::list_of(Value::VECTOR), docString),
setterMethod_(setterMethod) {}
template <class E> Value Setter<E, Vector>::doExecute() {
template <class E>
Value Setter<E, Vector>::doExecute() {
const std::vector<Value> &values = getParameterValues();
// Get parameter
Vector value = values[0].value();
......@@ -243,19 +259,20 @@ template <class E> Value Setter<E, Vector>::doExecute() {
//
// Template specialization: Matrix
//
template <class E> class Setter<E, Matrix> : public Command {
public:
template <class E>
class Setter<E, Matrix> : public Command {
public:
/// Pointer to method that sets parameter of type Matrix
typedef void (E::*SetterMethod)(const Matrix &);
/// Constructor
Setter(E &entity, SetterMethod setterMethod, const std::string &docString);
protected:
protected:
virtual Value doExecute();
private:
private:
SetterMethod setterMethod_;
}; // Class Setter
}; // Class Setter
template <class E>
Setter<E, Matrix>::Setter(E &entity, SetterMethod setterMethod,
......@@ -263,7 +280,8 @@ Setter<E, Matrix>::Setter(E &entity, SetterMethod setterMethod,
: Command(entity, boost::assign::list_of(Value::MATRIX), docString),
setterMethod_(setterMethod) {}
template <class E> Value Setter<E, Matrix>::doExecute() {
template <class E>
Value Setter<E, Matrix>::doExecute() {
const std::vector<Value> &values = getParameterValues();
// Get parameter
Matrix value = values[0].value();
......@@ -272,7 +290,7 @@ template <class E> Value Setter<E, Matrix>::doExecute() {
return Value();
}
} // namespace command
} // namespace dynamicgraph
} // namespace command
} // namespace dynamicgraph
#endif // DYNAMIC_GRAPH_COMMAND_SETTER_T_CPP
#endif // DYNAMIC_GRAPH_COMMAND_SETTER_T_CPP
......@@ -7,13 +7,15 @@
#ifndef DYNAMIC_GRAPH_COMMAND_H
#define DYNAMIC_GRAPH_COMMAND_H
#include <vector>
#include "dynamic-graph/dynamic-graph-api.h"
#include "dynamic-graph/value.h"
#include <vector>
namespace dynamicgraph {
class Entity;
namespace command {
/// \ingroup dgraph
/// Abstract class for entity commands
///
/// This class provide a mean to control entities from external
......@@ -31,7 +33,7 @@ namespace command {
/// vector of Values the types of which should fit the vector specified
/// at construction.
class DYNAMIC_GRAPH_DLLAPI Command {
public:
public:
virtual ~Command();
/// Store the owner entity and a vector of value types
/// \param entity reference to Entity owning this command.
......@@ -52,20 +54,20 @@ public:
/// Get documentation string
std::string getDocstring() const;
protected:
protected:
/// Specific action performed by the command
virtual Value doExecute() = 0;
private:
private:
Entity &owner_;
std::vector<Value::Type> valueTypeVector_;
std::vector<Value> valueVector_;
std::string docstring_;
public:
public:
static const std::vector<Value::Type> EMPTY_ARG;
};
} // namespace command
} // namespace dynamicgraph
} // namespace command
} // namespace dynamicgraph
#endif // DYNAMIC_GRAPH_COMMAND_H
#endif // DYNAMIC_GRAPH_COMMAND_H