diff --git a/include/dynamic-graph/command-getter.h b/include/dynamic-graph/command-getter.h index 1f580ffffa5a296e05e73a4cff01a62b18e2ab74..3db2d17a007567a0ae47e2ee9b0aa42eed9dc990 100644 --- a/include/dynamic-graph/command-getter.h +++ b/include/dynamic-graph/command-getter.h @@ -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(); diff --git a/include/dynamic-graph/command-setter.h b/include/dynamic-graph/command-setter.h index 8fadef7fb874fbcd8993bf6312c168bcc7cab87c..070b063a493082a097102a1028a7ef86e511dc0b 100644 --- a/include/dynamic-graph/command-setter.h +++ b/include/dynamic-graph/command-setter.h @@ -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(); diff --git a/include/dynamic-graph/command.h b/include/dynamic-graph/command.h index 15824c988142e15750e61912f5abacbcb05d5382..9ab5f0695ab7c027e9cdb7a141e6f15963b61314 100644 --- a/include/dynamic-graph/command.h +++ b/include/dynamic-graph/command.h @@ -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: