From c6de6a06830d2d67ffa797f2bda92c089e5e19e4 Mon Sep 17 00:00:00 2001 From: florent <florent@laas.fr> Date: Wed, 27 Oct 2010 19:15:32 +0200 Subject: [PATCH] Add some documentation * include/dynamic-graph/command-getter.h, * include/dynamic-graph/command-setter.h, * include/dynamic-graph/command.h. --- include/dynamic-graph/command-getter.h | 28 +++++++++++++++++++++++++- include/dynamic-graph/command-setter.h | 28 +++++++++++++++++++++++++- include/dynamic-graph/command.h | 15 +++++++++++--- 3 files changed, 66 insertions(+), 5 deletions(-) diff --git a/include/dynamic-graph/command-getter.h b/include/dynamic-graph/command-getter.h index 1f580ff..3db2d17 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 8fadef7..070b063 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 15824c9..9ab5f06 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: -- GitLab