Skip to content
Snippets Groups Projects
Commit c6de6a06 authored by Florent Lamiraux's avatar Florent Lamiraux
Browse files

Add some documentation

    * include/dynamic-graph/command-getter.h,
    * include/dynamic-graph/command-setter.h,
    * include/dynamic-graph/command.h.
parent 2b534f13
No related branches found
No related tags found
No related merge requests found
......@@ -26,6 +26,32 @@ namespace dynamicgraph {
///
/// 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:
......@@ -33,7 +59,7 @@ namespace dynamicgraph {
typedef T (E::*GetterMethod) () const;
/// Constructor
Getter(E& entity, GetterMethod);
protected:
virtual Value doExecute();
......
......@@ -26,6 +26,32 @@ namespace dynamicgraph {
///
/// 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:
......@@ -33,7 +59,7 @@ namespace dynamicgraph {
typedef void (E::*SetterMethod) (const T&);
/// Constructor
Setter(E& entity, SetterMethod);
protected:
virtual Value doExecute();
......
......@@ -28,9 +28,18 @@ namespace dynamicgraph {
/// Abstract class for entity commands
///
/// This class provide a mean to control entities from external python script.
/// A command has several parameters (dynamicgraph::parameter) that can take
/// various types of values (dynamicgraph::Value).
///
/// 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 DYNAMICGRAPH_EXPORT Command
{
public:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment