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 1113 additions and 672 deletions
/**
\page subp_pool Pool
\section pool Pool
The class \ref dynamicgraph::PoolStorage keeps track of the entities
instanciated with the factory. The entities are the graph nodes. Signals are
constructed during the class instanciation, they do not live independently from
the entities. Signals are the directed edges of the graph. The pool can write a
file representing the graph of entities.
*/
/**
\page subp_references References
\section sec_refer References
Please when referencing the Stack-Of-Tasks use the following reference:
\anchor Mansard2009
<b> <a href="https://hal-lirmm.ccsd.cnrs.fr/lirmm-00796736/document">
"A versatile Generalized Inverted Kinematics implementation for collaborative
working humanoid robots: The Stack Of Tasks"</a>
</b>,
<em>N. Mansard, O. Stasse, P. Evrard, A. Kheddar,</em>
Int. Conf. on Autonomous Robots, ICAR, 2009
\anchor Mansard2007
<b>"Task sequencing for sensor-based control"</b>,
<em>N. Mansard, F. Chaumette,</em>
IEEE Trans. on Robotics, 23(1):60-72, February 2007
*/
/**
\page subp_signals Signals
\section sec_sigintro Signals
Entities can output different types of signals. To guarante real-time
perforamces, signals are implemented using C++ and mecanism which have a low
time foot-print. All signals are templated by a Time tick type parameter (which
is used in the caching of signals) - usually \c int. Signals are also templated
after the type of data they accept or provide. For example: (example) For a more
detailed programmer-oriented description of signals, please see \ref signals
*/
/**
\page tracerrealtimedoc TracerRealTime
\section description Description
The \b TracerRealTime entity monitors a set of signals with real-time constraints; its
function is very similar to the Tracer, except that all traces are recorded to a
memory buffer, which can be emptied at any time.
\section commands Commands
\section tracerrealtimedoc_description Description
The \b TracerRealTime entity monitors a set of signals with real-time
constraints; its function is very similar to the Tracer, except that all traces
are recorded to a memory buffer, which can be emptied at any time.
\section tracerrealtimedoc_commands Commands
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
For more information on the signals exposed by this entity, please check the
code documentation of the dynamicgraph::Tracer class.
\section sample Sample usage
\section tracerrealtimedoc_sample Sample usage
See \ref tracerdoc for a code sample of using TracerRealTime.
\section addi Additional information
\section tracerrealtimedoc_addi Additional information
See doxygen documentation for the class dynamicgraph::TracerRealTime
\section generates Generated plugin file
\section tracerrealtimedoc_generates Generated plugin file
tracer-real-time.dll or tracer-real-time.so.
**/
*/
/**
\page tracerdoc Tracer
\section description Description
The \b Tracer entity monitors a set of signals. With an input change on the entity's [trigger] signal,
the tracked signal values are recorded and traced to a file. The behavior of the trace-to-file
function can be changed, from printing to a file immediately after recording, to printing out
only when asked explicitly.
\section commands Commands
\section tracerdoc_description Description
The \b Tracer entity monitors a set of signals. With an input change on the
entity's [trigger] signal, the tracked signal values are recorded and traced to
a file. The behavior of the trace-to-file function can be changed, from printing
to a file immediately after recording, to printing out only when asked
explicitly.
\section tracerdoc_commands Commands
The \b commands that this entity exposes are:
\code
open, close (a file);
......@@ -19,29 +21,22 @@ start, stop (traces)
For more information on the signals exposed by this entity, please check the
code documentation of the dynamicgraph::Tracer class.
\n\n
\section sample Sample usage
The following code creates a TracerRealTime entity, then sets the tracing buffer
size to 10MB. It then tells the tracer to create files with names of the form:
jl_XXX.dat where XXX is the signal name, and adds a few signals after
clearing the traces;
\code
new TracerRealTime tr
tr.bufferSize 10485760
tr.open ${TRACE_REPOSITORY} jl_ .dat
OpenHRP.periodicCall addSignal tr.triger
(...)
# --- TRACE ---
tr.clear
tr.add OpenHRP.forceRARM
tr.add dyn.0
tr.add jgain.gain
\section tracerdoc_sample Sample usage
The following code creates a TracerRealTime entity and sets the tracing buffer
size to 80MB. It then tells the tracer to create files with names of the form:
/tmp/dg_XXX.dat where XXX is the signal name, and call the signal
after the device has evaluated the control law:
\code
robot.tracer = TracerRealTime("com_tracer")
robot.tracer.setBufferSize(80*(2**20))
robot.tracer.open('/tmp','dg_','.dat')
robot.device.after.addSignal('{0}.triger'.format(robot.tracer.name))
\endcode
\section addi Additional information
\section tracerdoc_addi Additional information
See doxygen documentation for the class dynamicgraph::Tracer
\section generates Generated plugin file
\section tracerdoc_generates Generated plugin file
tracer.dll or tracer.so.
**/
*/
/**
\page writegraphdoc Displaying the graph of entities
\section description Description
It is possible to view the graph of entities currently instanciated.
The format used by dynamic-graph is dot.
Using the python interpreter the following command
\code
from dynamic_graph import *
writeGraph('/tmp/my_dynamic_graph.dot')
\endcode
is writing the <b>my_dynamic_graph.dot</b> in the <b>/tmp</b> directory
\section fromdottopdf Viewing as a PDF file
To view the dot file you can simply use:
\code
dot -Tpdf /tmp/my_dynamic_graph.dot > /tmp/my_dynamic_graph.pdf
\endcode
It provides the following output:
\image html my_dynamic_graph.png
\section fromdottojs Viewing in a browser
To view the dot file you can simply use the view_sot_dg.html file.
Click on the "Choose File" to specify the filem and click on "Rendering" to
display the graph.
*/
/* 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/my_dynamic_graph.png

97.1 KiB

doc/pictures/sot.ico

4.98 KiB

doc/pictures/sot.png

2.78 KiB

File moved
# Copyright 2010, Olivier Stasse, JRL, CNRS/AIST
#
# This file is part of dynamic-graph.
# dynamic-graph is free software: you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# dynamic-graph is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Lesser Public License for more details. You should have
# received a copy of the GNU Lesser General Public License along with
# dynamic-graph. If not, see <http://www.gnu.org/licenses/>.
CONFIGURE_FILE(
${PROJECT_NAME}/import-default-paths.h.cmake
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/import-default-paths.h)
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/import-default-paths.h
DESTINATION include/${PROJECT_NAME}
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ OWNER_WRITE
)
# Headers list.
SET(${PROJECT_NAME}_HEADERS
fwd.hh
null-ptr.hh
contiifstream.h
debug.h
real-time-logger.h
dynamic-graph-api.h
entity.h
factory.h
pool.h
exception-abstract.h
exception-factory.h
exception-signal.h
exception-traces.h
signal.h
signal-array.h
signal-base.h
signal-ptr.h
signal-time-dependent.h
signal-ptr.t.cpp
signal.t.cpp
time-dependency.h
time-dependency.t.cpp
signal-caster.h
signal-cast-helper.h
all-signals.h
signal-helper.h
entity-helper.h
tracer.h
tracer-real-time.h
command.h
eigen-io.h
linear-algebra.h
value.h
command-setter.h
command-setter.t.cpp
command-getter.h
command-getter.t.cpp
command-direct-getter.h
command-direct-setter.h
command-bind.h
all-commands.h
)
# Recreate correct path for the headers
#--------------------------------------
SET(fullpath_${PROJECT_NAME}_HEADERS)
FOREACH(lHeader ${${PROJECT_NAME}_HEADERS})
SET(fullpath_${PROJECT_NAME}_HEADERS
${fullpath_${PROJECT_NAME}_HEADERS}
./${PROJECT_NAME}/${lHeader}
)
ENDFOREACH(lHeader)
#----------------------------------------------------
# Install procedure for the header files
#----------------------------------------------------
INSTALL(FILES ${fullpath_${PROJECT_NAME}_HEADERS}
DESTINATION include/${PROJECT_NAME}
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ OWNER_WRITE
)
......@@ -2,21 +2,9 @@
// Copyright 2010, François Bleibel, Olivier Stasse, JRL, CNRS/AIST
// Thomas Moulard, Nicolas Mansard LAAS-CNRS
//
// This file is part of dynamic-graph.
// dynamic-graph is free software: you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
//
// dynamic-graph is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Lesser Public License for more details. You should have
// received a copy of the GNU Lesser General Public License along with
// dynamic-graph. If not, see <http://www.gnu.org/licenses/>.
#ifndef DYNAMIC_GRAPH_ALL_COMMANDS_H
# define DYNAMIC_GRAPH_ALL_COMMANDS_H
#define DYNAMIC_GRAPH_ALL_COMMANDS_H
// Utility header files including all commands headers
......@@ -24,7 +12,7 @@
#include <dynamic-graph/command-direct-getter.h>
#include <dynamic-graph/command-direct-setter.h>
#include <dynamic-graph/command-getter.h>
#include <dynamic-graph/command.h>
#include <dynamic-graph/command-setter.h>
#include <dynamic-graph/command.h>
#endif //! DYNAMIC_GRAPH_ALL_COMMANDS_H
#endif //! DYNAMIC_GRAPH_ALL_COMMANDS_H
......@@ -2,26 +2,14 @@
// Copyright 2010, François Bleibel, Thomas Moulard, Olivier Stasse,
// JRL, CNRS/AIST.
//
// This file is part of dynamic-graph.
// dynamic-graph is free software: you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
//
// dynamic-graph is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Lesser Public License for more details. You should have
// received a copy of the GNU Lesser General Public License along with
// dynamic-graph. If not, see <http://www.gnu.org/licenses/>.
#ifndef DYNAMIC_GRAPH_ALL_SIGNALS_H
# define DYNAMIC_GRAPH_ALL_SIGNALS_H
#define DYNAMIC_GRAPH_ALL_SIGNALS_H
// Utility header files including all signal headers
# include <dynamic-graph/signal.h>
# include <dynamic-graph/signal-ptr.h>
# include <dynamic-graph/signal-time-dependent.h>
#include <dynamic-graph/signal-ptr.h>
#include <dynamic-graph/signal-time-dependent.h>
#include <dynamic-graph/signal.h>
#endif //! DYNAMIC_GRAPH_ALL_SIGNALS_H
#endif //! DYNAMIC_GRAPH_ALL_SIGNALS_H
......@@ -3,17 +3,6 @@
//
// Author: Nicolas Mansard
//
// This file is part of dynamic-graph.
// dynamic-graph is free software: you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
// dynamic-graph is distributed in the hope that it will be
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details. You should
// have received a copy of the GNU Lesser General Public License along
// with dynamic-graph. If not, see <http://www.gnu.org/licenses/>.
#ifndef __dg_command_bind_h__
#define __dg_command_bind_h__
......@@ -21,482 +10,927 @@
/* Create a command from a bind directly. Examples are:
* addCommand("myProcVoid",
* makeCommandVoid0(*this,&ClassName::functionNoArg,
* docCommandVoid0("Simple line doc here.")));
* makeCommandVoid0(*this,&ClassName::functionNoArg,
* docCommandVoid0("Simple line doc here.")));
* addCommand("myProcOneString",
* makeCommandVoid1(*this,&EntityName::functionOneStringArg,
* docCommandVoid1("Simple line doc here.",
* "string")));
* makeCommandVoid1(*this,&EntityName::functionOneStringArg,
* docCommandVoid1("Simple line doc here.",
* "string")));
*
*/
#include "dynamic-graph/command.h"
#include <boost/assign/list_of.hpp>
#include <boost/function.hpp>
#include <boost/bind.hpp>
#include <boost/function.hpp>
#include "dynamic-graph/command.h"
/* --- FUNCTION 0 ARGS ------------------------------------------------------ */
/* --- FUNCTION 0 ARGS ----------------------------------------------------- */
namespace dynamicgraph {
namespace 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:
virtual Value doExecute()
{
assert( getParameterValues().size() == 0 );
fptr();
return Value(); // void
}
private:
boost::function<void(void)> fptr;
};
template <class E >
CommandVoid0<E>* makeCommandVoid0(E& entity, boost::function<void(void)> function ,
const std::string& docString)
{
return new CommandVoid0<E>( entity,function,docString );
}
template <class E >
CommandVoid0<E>* makeCommandVoid0(E& entity, boost::function<void(E*)> function ,
const std::string& docString)
{
return new CommandVoid0<E>( entity,
boost::bind(function,&entity),docString );
}
template <class E >
CommandVoid0<E>* makeCommandVoid0(E& entity, void (E::*function) (void),
const std::string& docString)
{
return new CommandVoid0<E>( entity,
boost::bind(function,&entity),docString );
}
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 {
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:
virtual Value doExecute() {
assert(getParameterValues().size() == 0);
fptr();
return Value(); // void
}
private:
boost::function<void(void)> fptr;
};
template <class E>
CommandVoid0<E> *makeCommandVoid0(E &entity,
boost::function<void(void)> function,
const std::string &docString) {
return new CommandVoid0<E>(entity, function, docString);
}
template <class E>
CommandVoid0<E> *makeCommandVoid0(E &entity,
boost::function<void(E *)> function,
const std::string &docString) {
return new CommandVoid0<E>(entity, boost::bind(function, &entity), docString);
}
template <class E>
CommandVoid0<E> *makeCommandVoid0(E &entity, void (E::*function)(void),
const std::string &docString) {
return new CommandVoid0<E>(entity, boost::bind(function, &entity), docString);
}
inline std::string docCommandVoid0(const std::string &doc) {
return std::string("\n") + doc + "\n\nNo input.\nVoid return.\n\n";
}
} // namespace command
} // namespace dynamicgraph
/* --- FUNCTION 1 ARGS ------------------------------------------------------ */
namespace dynamicgraph {
namespace 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:
virtual Value doExecute()
{
assert( getParameterValues().size() == 1 );
T val = getParameterValues()[0].value();
fptr(val);
return Value(); // void
}
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)
{
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 ,
boost::function<void(E*,const T&)> function,
const std::string& docString)
{
return new CommandVoid1<E,T>( entity,
boost::bind(function,&entity,_1),docString );
}
template <class E,typename T >
CommandVoid1<E,T>*
makeCommandVoid1(E& entity,
void (E::*function) (const T&),
const std::string& docString)
{
return new CommandVoid1<E,T>( entity,
boost::bind(function,&entity,_1),docString );
return NULL;
}
inline std::string docCommandVoid1( const std::string& doc, const std::string& type )
{
return std::string("\n")+doc +"\n\nInput:\n - A "+type+".\nVoid return.\n\n";
}
} // namespace command
} // namespace dynamicgraph
namespace command {
template <class E, typename T>
struct CommandVoid1 : public Command {
typedef boost::function<void(const T &)> function_t;
CommandVoid1(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();
fptr(val);
return Value(); // void
}
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) {
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 ???
boost::function<void(E *, const T &)> function,
const std::string &docString) {
return new CommandVoid1<E, T>(entity, boost::bind(function, &entity, _1),
docString);
}
template <class E, typename T>
CommandVoid1<E, T> *makeCommandVoid1(E &entity, void (E::*function)(const T &),
const std::string &docString) {
return new CommandVoid1<E, T>(entity, boost::bind(function, &entity, _1),
docString);
return NULL;
}
inline std::string docCommandVoid1(const std::string &doc,
const std::string &type) {
return std::string("\n") + doc + "\n\nInput:\n - A " + type +
".\nVoid return.\n\n";
}
} // namespace command
} // namespace dynamicgraph
/* --- FUNCTION 2 ARGS ------------------------------------------------------ */
namespace dynamicgraph {
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,
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();
fptr(val1,val2);
return Value(); // void
}
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)
{
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 ,
boost::function<void(E*,const T1&,const T2&)> function,
const std::string& docString)
{
return new CommandVoid2<E,T1,T2>( entity,
boost::bind(function,&entity,_1,_2),docString );
}
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)
{
return new CommandVoid2<E,T1,T2>( entity,
boost::bind(function,&entity,_1,_2),
docString );
return NULL;
}
inline std::string docCommandVoid2( 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"
+"Void return.\n\n" );
}
} // namespace command
} // namespace dynamicgraph
namespace command {
template <class E, typename T1, typename T2>
struct CommandVoid2 : public Command {
typedef boost::function<void(const T1 &, const T2 &)> function_t;
CommandVoid2(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();
fptr(val1, val2);
return Value(); // void
}
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) {
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 ???
boost::function<void(E *, const T1 &, const T2 &)> function,
const std::string &docString) {
return new CommandVoid2<E, T1, T2>(
entity, boost::bind(function, &entity, _1, _2), docString);
}
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) {
return new CommandVoid2<E, T1, T2>(
entity, boost::bind(function, &entity, _1, _2), docString);
return NULL;
}
inline std::string docCommandVoid2(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" + "Void return.\n\n");
}
} // namespace command
} // namespace dynamicgraph
/* --- FUNCTION 3 ARGS ------------------------------------------------------ */
namespace dynamicgraph {
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,
boost::assign::list_of
(ValueHelper<T1>::TypeID)
(ValueHelper<T2>::TypeID)
(ValueHelper<T3>::TypeID), docString)
,fptr(function)
{}
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
}
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)
{
return new CommandVoid3<E,T1,T2,T3>( entity,function,docString );
}
template <class E,typename T1,typename T2,typename T3 >
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>( entity,
boost::bind(function,&entity,_1,_2,_3),docString );
}
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)
{
return new CommandVoid3<E,T1,T2,T3>( entity,
boost::bind(function,&entity,_1,_2,_3),
docString );
return NULL;
}
inline std::string docCommandVoid3( const std::string& doc,
const std::string& type1,
const std::string& type2,
const std::string& type3 )
{
return (std::string("\n")+doc+"\n\n"
+"Input:\n - A "+type1+".\n"
+"Input:\n - A "+type2+".\n"
+"Input:\n - A "+type3+".\n"
+"Void return.\n\n" );
}
} // namespace command
} // namespace dynamicgraph
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;
CommandVoid3(E &entity, function_t function, const std::string &docString)
: Command(entity,
boost::assign::list_of(ValueHelper<T1>::TypeID)(
ValueHelper<T2>::TypeID)(ValueHelper<T3>::TypeID),
docString),
fptr(function) {}
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
}
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) {
return new CommandVoid3<E, T1, T2, T3>(entity, function, docString);
}
template <class E, typename T1, typename T2, typename T3>
CommandVoid3<E, T1, T2, T3> *makeCommandVoid3(
E &entity,
// The following syntaxt don't compile when not specializing the template
// arg... why ???
boost::function<void(E *, const T1 &, const T2 &, const T3 &)> function,
const std::string &docString) {
return new CommandVoid3<E, T1, T2, T3>(
entity, boost::bind(function, &entity, _1, _2, _3), docString);
}
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) {
return new CommandVoid3<E, T1, T2, T3>(
entity, boost::bind(function, &entity, _1, _2, _3), docString);
return NULL;
}
inline std::string docCommandVoid3(const std::string &doc,
const std::string &type1,
const std::string &type2,
const std::string &type3) {
return (std::string("\n") + doc + "\n\n" + "Input:\n - A " + type1 + ".\n" +
"Input:\n - A " + type2 + ".\n" + "Input:\n - A " + type3 + ".\n" +
"Void return.\n\n");
}
} // namespace command
} // namespace dynamicgraph
/* --- FUNCTION 4 ARGS ------------------------------------------------------ */
namespace dynamicgraph {
namespace command {
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&);
CommandVoid4(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)
, docString)
,fptr(function)
{}
protected:
virtual Value doExecute()
{
assert( getParameterValues().size() == 4 );
T1 val1 = getParameterValues()[0].value();
T2 val2 = getParameterValues()[1].value();
T3 val3 = getParameterValues()[2].value();
T4 val4 = getParameterValues()[3].value();
fptr(val1,val2,val3,val4);
return Value(); // void
}
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)
{
return new CommandVoid4<E,T1,T2,T3,T4>( entity,function,docString );
}
template <class E,typename T1,typename T2,typename T3,typename T4 >
CommandVoid4<E,T1,T2,T3,T4>*
makeCommandVoid4(E& entity,
boost::function<void(E*,const T1&,const T2&,const T3&,const T4&)> function,
const std::string& docString)
{
return new CommandVoid4<E,T1,T2,T3,T4>( entity,
boost::bind(function,&entity,_1,_2,_3,_4),docString );
}
template <class E,typename T1,typename T2,typename T3,typename T4 >
CommandVoid4<E,T1,T2,T3,T4>*
makeCommandVoid4(E& entity,
void (E::*function) (const T1&,const T2&,const T3&,const T4&),
const std::string& docString)
{
return new CommandVoid4<E,T1,T2,T3,T4>( entity,
boost::bind(function,&entity,_1,_2,_3,_4),
docString );
return NULL;
}
inline std::string docCommandVoid4( const std::string& doc,
const std::string& type1,
const std::string& type2,
const std::string& type3,
const std::string& type4 )
{
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"
+"Void return.\n\n" );
}
} // namespace command
} // namespace dynamicgraph
namespace command {
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 void (E::*memberFunction_ptr_t)(const T1 &, const T2 &, const T3 &,
const T4 &);
CommandVoid4(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),
docString),
fptr(function) {}
protected:
virtual Value doExecute() {
assert(getParameterValues().size() == 4);
T1 val1 = getParameterValues()[0].value();
T2 val2 = getParameterValues()[1].value();
T3 val3 = getParameterValues()[2].value();
T4 val4 = getParameterValues()[3].value();
fptr(val1, val2, val3, val4);
return Value(); // void
}
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) {
return new CommandVoid4<E, T1, T2, T3, T4>(entity, function, docString);
}
template <class E, typename T1, typename T2, typename T3, typename T4>
CommandVoid4<E, T1, T2, T3, T4> *makeCommandVoid4(
E &entity,
boost::function<void(E *, const T1 &, const T2 &, const T3 &, const T4 &)>
function,
const std::string &docString) {
return new CommandVoid4<E, T1, T2, T3, T4>(
entity, boost::bind(function, &entity, _1, _2, _3, _4), docString);
}
template <class E, typename T1, typename T2, typename T3, typename T4>
CommandVoid4<E, T1, T2, T3, T4> *makeCommandVoid4(
E &entity,
void (E::*function)(const T1 &, const T2 &, const T3 &, const T4 &),
const std::string &docString) {
return new CommandVoid4<E, T1, T2, T3, T4>(
entity, boost::bind(function, &entity, _1, _2, _3, _4), docString);
return NULL;
}
inline std::string docCommandVoid4(const std::string &doc,
const std::string &type1,
const std::string &type2,
const std::string &type3,
const std::string &type4) {
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" + "Void return.\n\n");
}
} // 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. */
namespace dynamicgraph {
namespace 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:
virtual Value doExecute()
{
assert( getParameterValues().size() == 0 );
std::ostringstream oss;
fptr(oss);
return Value( oss.str() ); // return string
}
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,
const std::string& docString)
{
return new CommandVerbose<E>( entity,
boost::bind(function,&entity,_1),docString );
return NULL;
}
template <class E >
CommandVerbose<E>*
makeCommandVerbose(E& entity,
typename CommandVerbose<E>::memberFunction_ptr_t function,
const std::string& docString)
{
return new CommandVerbose<E>( entity,
boost::bind(function,&entity,_1),docString );
return NULL;
}
inline std::string docCommandVerbose( const std::string& doc )
{
return std::string("\n")+doc +"\n\nNo input.\n Return a string.\n\n";
}
} // namespace command
} // namespace dynamicgraph
#endif // __dg_command_bind_h__
namespace command {
template <class E>
struct CommandVerbose : public Command {
typedef boost::function<void(std::ostream &)> function_t;
CommandVerbose(E &entity, function_t function, const std::string &docString)
: Command(entity, EMPTY_ARG, docString), fptr(function) {}
protected:
virtual Value doExecute() {
assert(getParameterValues().size() == 0);
std::ostringstream oss;
fptr(oss);
return Value(oss.str()); // return string
}
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 std::string &docString) {
return new CommandVerbose<E>(entity, boost::bind(function, &entity, _1),
docString);
return NULL;
}
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
#endif // __dg_command_bind_h__
......@@ -3,17 +3,6 @@
//
// Author: Nicolas Mansard
//
// This file is part of dynamic-graph.
// dynamic-graph is free software: you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
// dynamic-graph is distributed in the hope that it will be
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details. You should
// have received a copy of the GNU Lesser General Public License along
// with dynamic-graph. If not, see <http://www.gnu.org/licenses/>.
#ifndef __dg_command_direct_getter_h__
#define __dg_command_direct_getter_h__
......@@ -26,47 +15,44 @@
*
*/
#include "dynamic-graph/command.h"
#include <boost/assign/list_of.hpp>
#include "dynamic-graph/command.h"
/* --- GETTER --------------------------------------------------------- */
namespace dynamicgraph {
namespace command {
namespace command {
template <class E, typename T>
class DirectGetter
: public Command
{
public:
/// Pointer to method that sets parameter of type T
typedef T (E::*GetterMethod) () const;
template <class E, typename T>
class DirectGetter : public Command {
public:
/// Pointer to method that sets parameter of type T
typedef T (E::*GetterMethod)() const;
/// Constructor
DirectGetter(E& entity,T* ptr,
const std::string& docString)
: Command(entity, std::vector<Value::Type>(), docString),
T_ptr(ptr) {}
/// Constructor
DirectGetter(E &entity, T *ptr, const std::string &docString)
: Command(entity, std::vector<Value::Type>(), docString), T_ptr(ptr) {}
protected:
virtual Value doExecute() { return Value(*T_ptr); }
private:
T* T_ptr;
};
protected:
virtual Value doExecute() { return Value(*T_ptr); }
template <class E, typename T>
DirectGetter<E,T>*
makeDirectGetter( E& entity,T* ptr,
const std::string& docString)
{ return new DirectGetter<E,T>(entity,ptr,docString); }
private:
T *T_ptr;
};
inline std::string docDirectGetter( const std::string& name,
const std::string& type )
{
return std::string("\nGet the ")+name+".\n\nNo input.\nReturn an "+type+".\n\n";
}
template <class E, typename T>
DirectGetter<E, T> *makeDirectGetter(E &entity, T *ptr,
const std::string &docString) {
return new DirectGetter<E, T>(entity, ptr, docString);
}
} // namespace command
} // namespace dynamicgraph
inline std::string docDirectGetter(const std::string &name,
const std::string &type) {
return std::string("\nGet the ") + name + ".\n\nNo input.\nReturn an " +
type + ".\n\n";
}
} // namespace command
} // namespace dynamicgraph
#endif // __dg_command_direct_getter_h__
#endif // __dg_command_direct_getter_h__