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 2324 additions and 2180 deletions
......@@ -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
This diff is collapsed.
......@@ -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__
......@@ -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_setter_h__
#define __dg_command_direct_setter_h__
......@@ -26,50 +15,47 @@
*
*/
#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:
DirectSetter(E& entity,T* ptr,const std::string& docString)
:Command(entity, boost::assign::list_of(ValueHelper<T>::TypeID), docString)
,T_ptr(ptr)
{}
protected:
virtual Value doExecute()
{
const std::vector<Value>& values = getParameterValues();
T val = values[0].value();
(*T_ptr) = val;
return Value(); // void
}
private:
T* T_ptr;
};
template <class E, typename T>
DirectSetter<E,T>*
makeDirectSetter( E& entity,T* ptr,
const std::string& docString)
{ return new DirectSetter<E,T>(entity,ptr,docString); }
inline std::string docDirectSetter( const std::string& name,
const std::string& type )
{
return std::string("\nSet the ")+name+".\n\nInput:\n - a "
+type+".\nVoid return.\n\n";
}
} // namespace command
} // namespace dynamicgraph
#endif // __dg_command_direct_setter_h__
namespace command {
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:
virtual Value doExecute() {
const std::vector<Value> &values = getParameterValues();
T val = values[0].value();
(*T_ptr) = val;
return Value(); // void
}
private:
T *T_ptr;
};
template <class E, typename T>
DirectSetter<E, T> *makeDirectSetter(E &entity, T *ptr,
const std::string &docString) {
return new DirectSetter<E, T>(entity, ptr, docString);
}
inline std::string docDirectSetter(const std::string &name,
const std::string &type) {
return std::string("\nSet the ") + name + ".\n\nInput:\n - a " + type +
".\nVoid return.\n\n";
}
} // namespace command
} // namespace dynamicgraph
#endif // __dg_command_direct_setter_h__
......@@ -3,17 +3,6 @@
//
// Author: Florent Lamiraux
//
// 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 DYNAMIC_GRAPH_COMMAND_GETTER_H
#define DYNAMIC_GRAPH_COMMAND_GETTER_H
......@@ -21,55 +10,53 @@
#include "dynamic-graph/command.h"
namespace dynamicgraph {
namespace command {
///
/// Command that calls a parameter getter function
///
/// This class is templated by a type E deriving from entity and
/// a type T of data.
///
/// Let us assume that class E has a private member of type T and a
/// public getter function for this member:
/// \code
/// class E : public Entity
/// {
/// public:
/// E (const std::string& inName) : Entity(inName) {}
/// T getParameter() const {return parameter_;}
/// private:
/// T parameter_;
/// };
/// \endcode
/// Then the command defined by:
/// \code
/// E entity("MyEntity");
/// Getter<E,T> command(entity, &E::getParameter)
/// \endcode
/// returns the value of <c>entity.parameter_</c> upon invocation.
///
/// \note
/// \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:
/// 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:
virtual Value doExecute();
private:
GetterMethod getterMethod_;
};
} // namespace command
} // namespace dynamicgraph
namespace command {
///
/// Command that calls a parameter getter function
///
/// This class is templated by a type E deriving from entity and
/// a type T of data.
///
/// Let us assume that class E has a private member of type T and a
/// public getter function for this member:
/// \code
/// class E : public Entity
/// {
/// public:
/// E (const std::string& inName) : Entity(inName) {}
/// T getParameter() const {return parameter_;}
/// private:
/// T parameter_;
/// };
/// \endcode
/// Then the command defined by:
/// \code
/// E entity("MyEntity");
/// Getter<E,T> command(entity, &E::getParameter)
/// \endcode
/// returns the value of <c>entity.parameter_</c> upon invocation.
///
/// \note
/// \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:
/// 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:
virtual Value doExecute();
private:
GetterMethod getterMethod_;
};
} // namespace command
} // namespace dynamicgraph
#include "dynamic-graph/command-getter.t.cpp"
#endif //DYNAMIC_GRAPH_COMMAND_GETTER_H
#endif // DYNAMIC_GRAPH_COMMAND_GETTER_H
......@@ -3,43 +3,31 @@
//
// Author: Florent Lamiraux
//
// 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 DYNAMIC_GRAPH_COMMAND_GETTER_T_CPP
#define DYNAMIC_GRAPH_COMMAND_GETTER_T_CPP
#include "dynamic-graph/command-getter.h"
#include <sstream>
namespace dynamicgraph {
class Entity;
namespace command {
class Entity;
namespace command {
template <class E, typename T>
Getter<E, T>::Getter(E& entity, GetterMethod getterMethod,
const std::string& docstring) :
Command(entity, std::vector<Value::Type>(), docstring),
getterMethod_(getterMethod)
{
}
template <class E, typename T>
Getter<E, T>::Getter(E &entity, GetterMethod getterMethod,
const std::string &docstring)
: Command(entity, std::vector<Value::Type>(), docstring),
getterMethod_(getterMethod) {}
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
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
#endif // DYNAMIC_GRAPH_COMMAND_GETTER_T_CPP
#endif // DYNAMIC_GRAPH_COMMAND_GETTER_T_CPP
......@@ -3,17 +3,6 @@
//
// Author: Florent Lamiraux
//
// 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 DYNAMIC_GRAPH_COMMAND_SETTER_H
#define DYNAMIC_GRAPH_COMMAND_SETTER_H
......@@ -21,55 +10,53 @@
#include "dynamic-graph/command.h"
namespace dynamicgraph {
namespace command {
///
/// Command that calls a parameter setter function
///
/// This class is templated by a type E deriving from entity and
/// a type T of data.
///
/// Let us assume that class E has a private member of type T and a
/// public setter function for this member:
/// \code
/// class E : public Entity
/// {
/// public:
/// E (const std::string& inName) : Entity(inName) {}
/// void setParameter(const T& parameter) {parameter_ = parameter;}
/// private:
/// T parameter_;
/// };
/// \endcode
/// Then the command defined by:
/// \code
/// E entity("MyEntity");
/// Setter<E,T> command(entity, &E::getParameter)
/// \endcode
/// sets the value of <c>entity.parameter_</c> upon invocation.
///
/// \note
/// \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:
/// 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:
virtual Value doExecute();
private:
SetterMethod setterMethod_;
};
} // namespace command
} // namespace dynamicgraph
namespace command {
///
/// Command that calls a parameter setter function
///
/// This class is templated by a type E deriving from entity and
/// a type T of data.
///
/// Let us assume that class E has a private member of type T and a
/// public setter function for this member:
/// \code
/// class E : public Entity
/// {
/// public:
/// E (const std::string& inName) : Entity(inName) {}
/// void setParameter(const T& parameter) {parameter_ = parameter;}
/// private:
/// T parameter_;
/// };
/// \endcode
/// Then the command defined by:
/// \code
/// E entity("MyEntity");
/// Setter<E,T> command(entity, &E::getParameter)
/// \endcode
/// sets the value of <c>entity.parameter_</c> upon invocation.
///
/// \note
/// \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:
/// 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:
virtual Value doExecute();
private:
SetterMethod setterMethod_;
};
} // namespace command
} // namespace dynamicgraph
#include "dynamic-graph/command-setter.t.cpp"
#endif //DYNAMIC_GRAPH_COMMAND_SETTER_H
#endif // DYNAMIC_GRAPH_COMMAND_SETTER_H
......@@ -3,334 +3,294 @@
//
// Author: Florent Lamiraux
//
// 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 DYNAMIC_GRAPH_COMMAND_SETTER_T_CPP
#define DYNAMIC_GRAPH_COMMAND_SETTER_T_CPP
#include <sstream>
#include "dynamic-graph/command-setter.h"
#include <boost/assign/list_of.hpp>
#include <sstream>
#include "dynamic-graph/linear-algebra.h"
namespace dynamicgraph {
class Entity;
namespace command {
//
// Template specialization: bool
//
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:
virtual Value doExecute();
private:
SetterMethod setterMethod_;
}; // Class Setter
template <class E>
Setter<E, bool>::Setter(E& entity, SetterMethod setterMethod,
const std::string& docString) :
Command(entity, boost::assign::list_of(Value::BOOL), docString),
setterMethod_(setterMethod)
{
}
template <class E>
Value Setter<E, bool>::doExecute()
{
const std::vector<Value>& values = getParameterValues();
// Get parameter
bool value = values[0].value();
E& entity = static_cast<E&>(owner());
(entity.*setterMethod_)(value);
return Value();
}
//
// Template specialization: unsigned
//
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:
virtual Value doExecute();
private:
SetterMethod setterMethod_;
}; // Class Setter
template <class E>
Setter<E, unsigned>::Setter(E& entity, SetterMethod setterMethod,
const std::string& docString) :
Command(entity, boost::assign::list_of(Value::UNSIGNED), docString),
setterMethod_(setterMethod)
{
}
template <class E>
Value Setter<E, unsigned>::doExecute()
{
const std::vector<Value>& values = getParameterValues();
// Get parameter
unsigned value = values[0].value();
E& entity = static_cast<E&>(owner());
(entity.*setterMethod_)(value);
return Value();
}
//
// Template specialization: int
//
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:
virtual Value doExecute();
private:
SetterMethod setterMethod_;
}; // Class Setter
template <class E>
Setter<E, int>::Setter(E& entity, SetterMethod setterMethod,
const std::string& docString) :
Command(entity, boost::assign::list_of(Value::INT), docString),
setterMethod_(setterMethod)
{
}
template <class E>
Value Setter<E, int>::doExecute()
{
const std::vector<Value>& values = getParameterValues();
// Get parameter
int value = values[0].value();
E& entity = static_cast<E&>(owner());
(entity.*setterMethod_)(value);
return Value();
}
//
// Template specialization: float
//
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:
virtual Value doExecute();
private:
SetterMethod setterMethod_;
}; // Class Setter
template <class E>
Setter<E, float>::Setter(E& entity, SetterMethod setterMethod,
const std::string& docString) :
Command(entity, boost::assign::list_of(Value::FLOAT), docString),
setterMethod_(setterMethod)
{
}
template <class E>
Value Setter<E, float>::doExecute()
{
const std::vector<Value>& values = getParameterValues();
// Get parameter
float value = values[0].value();
E& entity = static_cast<E&>(owner());
(entity.*setterMethod_)(value);
return Value();
}
//
// Template specialization: double
//
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:
virtual Value doExecute();
private:
SetterMethod setterMethod_;
}; // Class Setter
template <class E>
Setter<E, double>::Setter(E& entity, SetterMethod setterMethod,
const std::string& docString) :
Command(entity, boost::assign::list_of(Value::DOUBLE), docString),
setterMethod_(setterMethod)
{
}
template <class E>
Value Setter<E, double>::doExecute()
{
const std::vector<Value>& values = getParameterValues();
// Get parameter
double value = values[0].value();
E& entity = static_cast<E&>(owner());
(entity.*setterMethod_)(value);
return Value();
}
//
// Template specialization: std::string
//
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:
virtual Value doExecute();
private:
SetterMethod setterMethod_;
}; // Class Setter
template <class E>
Setter<E, std::string>::Setter(E& entity, SetterMethod setterMethod,
const std::string& docString) :
Command(entity, boost::assign::list_of(Value::STRING), docString),
setterMethod_(setterMethod)
{
}
template <class E>
Value Setter<E, std::string>::doExecute()
{
const std::vector<Value>& values = getParameterValues();
// Get parameter
std::string value = values[0].value();
E& entity = static_cast<E&>(owner());
(entity.*setterMethod_)(value);
return Value();
}
//
// Template specialization: Vector
//
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:
virtual Value doExecute();
private:
SetterMethod setterMethod_;
}; // Class Setter
template <class E>
Setter<E, Vector>::Setter(E& entity, SetterMethod setterMethod,
const std::string& docString) :
Command(entity, boost::assign::list_of(Value::VECTOR), docString),
setterMethod_(setterMethod)
{
}
template <class E>
Value Setter<E, Vector>::doExecute()
{
const std::vector<Value>& values = getParameterValues();
// Get parameter
Vector value = values[0].value();
E& entity = static_cast<E&>(owner());
(entity.*setterMethod_)(value);
return Value();
}
//
// Template specialization: Matrix
//
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:
virtual Value doExecute();
private:
SetterMethod setterMethod_;
}; // Class Setter
template <class E>
Setter<E, Matrix>::Setter(E& entity, SetterMethod setterMethod,
const std::string& docString) :
Command(entity, boost::assign::list_of(Value::MATRIX), docString),
setterMethod_(setterMethod)
{
}
template <class E>
Value Setter<E, Matrix>::doExecute()
{
const std::vector<Value>& values = getParameterValues();
// Get parameter
Matrix value = values[0].value();
E& entity = static_cast<E&>(owner());
(entity.*setterMethod_)(value);
return Value();
}
} // namespace command
} // namespace dynamicgraph
#endif // DYNAMIC_GRAPH_COMMAND_SETTER_T_CPP
class Entity;
namespace command {
//
// Template specialization: bool
//
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:
virtual Value doExecute();
private:
SetterMethod setterMethod_;
}; // Class Setter
template <class E>
Setter<E, bool>::Setter(E &entity, SetterMethod setterMethod,
const std::string &docString)
: Command(entity, boost::assign::list_of(Value::BOOL), docString),
setterMethod_(setterMethod) {}
template <class E>
Value Setter<E, bool>::doExecute() {
const std::vector<Value> &values = getParameterValues();
// Get parameter
bool value = values[0].value();
E &entity = static_cast<E &>(owner());
(entity.*setterMethod_)(value);
return Value();
}
//
// Template specialization: unsigned
//
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:
virtual Value doExecute();
private:
SetterMethod setterMethod_;
}; // Class Setter
template <class E>
Setter<E, unsigned>::Setter(E &entity, SetterMethod setterMethod,
const std::string &docString)
: Command(entity, boost::assign::list_of(Value::UNSIGNED), docString),
setterMethod_(setterMethod) {}
template <class E>
Value Setter<E, unsigned>::doExecute() {
const std::vector<Value> &values = getParameterValues();
// Get parameter
unsigned value = values[0].value();
E &entity = static_cast<E &>(owner());
(entity.*setterMethod_)(value);
return Value();
}
//
// Template specialization: int
//
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:
virtual Value doExecute();
private:
SetterMethod setterMethod_;
}; // Class Setter
template <class E>
Setter<E, int>::Setter(E &entity, SetterMethod setterMethod,
const std::string &docString)
: Command(entity, boost::assign::list_of(Value::INT), docString),
setterMethod_(setterMethod) {}
template <class E>
Value Setter<E, int>::doExecute() {
const std::vector<Value> &values = getParameterValues();
// Get parameter
int value = values[0].value();
E &entity = static_cast<E &>(owner());
(entity.*setterMethod_)(value);
return Value();
}
//
// Template specialization: float
//
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:
virtual Value doExecute();
private:
SetterMethod setterMethod_;
}; // Class Setter
template <class E>
Setter<E, float>::Setter(E &entity, SetterMethod setterMethod,
const std::string &docString)
: Command(entity, boost::assign::list_of(Value::FLOAT), docString),
setterMethod_(setterMethod) {}
template <class E>
Value Setter<E, float>::doExecute() {
const std::vector<Value> &values = getParameterValues();
// Get parameter
float value = values[0].value();
E &entity = static_cast<E &>(owner());
(entity.*setterMethod_)(value);
return Value();
}
//
// Template specialization: double
//
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:
virtual Value doExecute();
private:
SetterMethod setterMethod_;
}; // Class Setter
template <class E>
Setter<E, double>::Setter(E &entity, SetterMethod setterMethod,
const std::string &docString)
: Command(entity, boost::assign::list_of(Value::DOUBLE), docString),
setterMethod_(setterMethod) {}
template <class E>
Value Setter<E, double>::doExecute() {
const std::vector<Value> &values = getParameterValues();
// Get parameter
double value = values[0].value();
E &entity = static_cast<E &>(owner());
(entity.*setterMethod_)(value);
return Value();
}
//
// Template specialization: std::string
//
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:
virtual Value doExecute();
private:
SetterMethod setterMethod_;
}; // Class Setter
template <class E>
Setter<E, std::string>::Setter(E &entity, SetterMethod setterMethod,
const std::string &docString)
: Command(entity, boost::assign::list_of(Value::STRING), docString),
setterMethod_(setterMethod) {}
template <class E>
Value Setter<E, std::string>::doExecute() {
const std::vector<Value> &values = getParameterValues();
// Get parameter
std::string value = values[0].value();
E &entity = static_cast<E &>(owner());
(entity.*setterMethod_)(value);
return Value();
}
//
// Template specialization: Vector
//
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:
virtual Value doExecute();
private:
SetterMethod setterMethod_;
}; // Class Setter
template <class E>
Setter<E, Vector>::Setter(E &entity, SetterMethod setterMethod,
const std::string &docString)
: Command(entity, boost::assign::list_of(Value::VECTOR), docString),
setterMethod_(setterMethod) {}
template <class E>
Value Setter<E, Vector>::doExecute() {
const std::vector<Value> &values = getParameterValues();
// Get parameter
Vector value = values[0].value();
E &entity = static_cast<E &>(owner());
(entity.*setterMethod_)(value);
return Value();
}
//
// Template specialization: Matrix
//
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:
virtual Value doExecute();
private:
SetterMethod setterMethod_;
}; // Class Setter
template <class E>
Setter<E, Matrix>::Setter(E &entity, SetterMethod setterMethod,
const std::string &docString)
: Command(entity, boost::assign::list_of(Value::MATRIX), docString),
setterMethod_(setterMethod) {}
template <class E>
Value Setter<E, Matrix>::doExecute() {
const std::vector<Value> &values = getParameterValues();
// Get parameter
Matrix value = values[0].value();
E &entity = static_cast<E &>(owner());
(entity.*setterMethod_)(value);
return Value();
}
} // namespace command
} // namespace dynamicgraph
#endif // DYNAMIC_GRAPH_COMMAND_SETTER_T_CPP
......@@ -3,77 +3,71 @@
//
// Author: Florent Lamiraux
//
// 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 DYNAMIC_GRAPH_COMMAND_H
#define DYNAMIC_GRAPH_COMMAND_H
#include <vector>
#include "dynamic-graph/value.h"
#include "dynamic-graph/dynamic-graph-api.h"
#include "dynamic-graph/value.h"
namespace dynamicgraph {
class Entity;
namespace command {
/// Abstract class for entity commands
///
/// This class provide a mean to control entities from external python script.
///
/// A command
/// \li is owned by an entity,
/// \li takes parameters of type Value,
/// \li return an instance of Value when calling Command::execute()
///
/// At construction, the prototype of the command is defined by providing
/// a vector of Value::Type.
///
/// Parameters are set by calling Command::setParameterValues with a
/// vector of Values the types of which should fit the vector specified
/// at construction.
class DYNAMIC_GRAPH_DLLAPI Command
{
public:
virtual ~Command();
/// Store the owner entity and a vector of value types
/// \param entity reference to Entity owning this command.
/// \param valueTypes vector specifying the number and types of parameters
/// \param docstring documentation of the command
Command(Entity& entity, const std::vector<Value::Type>& valueTypes,
const std::string& docstring);
/// Return the value type of all parameters
const std::vector<Value::Type>& valueTypes() const;
/// Set parameter values
void setParameterValues(const std::vector<Value>& values);
/// Get parameter values
const std::vector<Value>& getParameterValues() const;
/// Execute the command after checking parameters
Value execute();
/// Get a reference to the Entity owning this command
Entity& owner();
/// Get documentation string
std::string getDocstring() const;
protected:
/// Specific action performed by the command
virtual Value doExecute() = 0;
private:
Entity& owner_;
std::vector<Value::Type> valueTypeVector_;
std::vector<Value> valueVector_;
std::string docstring_;
public:
static const std::vector<Value::Type> EMPTY_ARG;
};
} // namespace command
} // namespace dynamicgraph
class Entity;
namespace command {
/// \ingroup dgraph
/// Abstract class for entity commands
///
/// This class provide a mean to control entities from external
/// python script.
///
/// A command
/// \li is owned by an entity,
/// \li takes parameters of type Value,
/// \li return an instance of Value when calling Command::execute()
///
/// At construction, the prototype of the command is defined by providing
/// a vector of Value::Type.
///
/// Parameters are set by calling Command::setParameterValues with a
/// vector of Values the types of which should fit the vector specified
/// at construction.
class DYNAMIC_GRAPH_DLLAPI Command {
public:
virtual ~Command();
/// Store the owner entity and a vector of value types
/// \param entity reference to Entity owning this command.
/// \param valueTypes vector specifying the number and types of parameters
/// \param docstring documentation of the command
Command(Entity &entity, const std::vector<Value::Type> &valueTypes,
const std::string &docstring);
/// Return the value type of all parameters
const std::vector<Value::Type> &valueTypes() const;
/// Set parameter values
void setParameterValues(const std::vector<Value> &values);
/// Get parameter values
const std::vector<Value> &getParameterValues() const;
/// Execute the command after checking parameters
Value execute();
/// Get a reference to the Entity owning this command
Entity &owner();
/// Get documentation string
std::string getDocstring() const;
protected:
/// Specific action performed by the command
virtual Value doExecute() = 0;
private:
Entity &owner_;
std::vector<Value::Type> valueTypeVector_;
std::vector<Value> valueVector_;
std::string docstring_;
public:
static const std::vector<Value::Type> EMPTY_ARG;
};
} // namespace command
} // namespace dynamicgraph
#endif //DYNAMIC_GRAPH_COMMAND_H
#endif // DYNAMIC_GRAPH_COMMAND_H
This diff is collapsed.
......@@ -2,20 +2,8 @@
// 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_API_H
# define DYNAMIC_GRAPH_API_H
# include <dynamic-graph/config.hh>
#endif //! DYNAMIC_GRAPH_API_H
#define DYNAMIC_GRAPH_API_H
#include <dynamic-graph/config.hh>
#endif //! DYNAMIC_GRAPH_API_H
This diff is collapsed.
/*
* Copyright 2011, Nicolas Mansard, LAAS-CNRS
*
* This file is part of sot-core.
* sot-core 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.
* sot-core 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 sot-core. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __sot_core_entity_helper_H__
#define __sot_core_entity_helper_H__
namespace dynamicgraph {
namespace dynamicgraph
{
template <typename Ent>
struct EntityHelper {
typedef Ent EntityClassName;
// static const std::string CLASS_NAME; TO BE ADDED IN DG DIRECTLY
};
template< typename Ent >
struct EntityHelper
{
typedef Ent EntityClassName;
//static const std::string CLASS_NAME; TO BE ADDED IN DG DIRECTLY
};
} // namespace dynamicgraph
} // namespace dynamicgraph
#endif // __sot_core_entity_helper_H__
#endif // __sot_core_entity_helper_H__
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.