diff --git a/include/dynamic-graph/command-getter.h b/include/dynamic-graph/command-getter.h index 336eea56f878ed13dd98f691637256802eb3d0af..73e845eed1ba66acceb8cddf786fb058e7302bc0 100644 --- a/include/dynamic-graph/command-getter.h +++ b/include/dynamic-graph/command-getter.h @@ -58,7 +58,8 @@ namespace dynamicgraph { /// Pointer to method that sets paramter of type T typedef T (E::*GetterMethod) () const; /// Constructor - Getter(E& entity, GetterMethod); + Getter(E& entity, GetterMethod getterMethod, + const std::string& docString); protected: virtual Value doExecute(); diff --git a/include/dynamic-graph/command-getter.t.cpp b/include/dynamic-graph/command-getter.t.cpp index 98d5522c2d387e84714831db81b777d0c817a936..63e06bdf01e700e0a31952eb2a5d0508576e570d 100644 --- a/include/dynamic-graph/command-getter.t.cpp +++ b/include/dynamic-graph/command-getter.t.cpp @@ -25,8 +25,9 @@ namespace dynamicgraph { namespace command { template <class E, typename T> - Getter<E, T>::Getter(E& entity, GetterMethod getterMethod) : - Command(entity, std::vector<Value::Type>()), + Getter<E, T>::Getter(E& entity, GetterMethod getterMethod, + const std::string& docstring) : + Command(entity, std::vector<Value::Type>(), docstring), getterMethod_(getterMethod) { } diff --git a/include/dynamic-graph/command-setter.h b/include/dynamic-graph/command-setter.h index f6648c197c800c685da683916940cf3d2128a00a..588567ee085a418d3fbe028cfdac19e878ae3262 100644 --- a/include/dynamic-graph/command-setter.h +++ b/include/dynamic-graph/command-setter.h @@ -58,7 +58,8 @@ namespace dynamicgraph { /// Pointer to method that sets paramter of type T typedef void (E::*SetterMethod) (const T&); /// Constructor - Setter(E& entity, SetterMethod); + Setter(E& entity, SetterMethod setterMethod, + const std::string& docString); protected: virtual Value doExecute(); diff --git a/include/dynamic-graph/command-setter.t.cpp b/include/dynamic-graph/command-setter.t.cpp index 7d26fc445d38a9349559f89119e7f010250aac15..937c7edeb70bdb7a1ccb41d1193df7b5ee692a32 100644 --- a/include/dynamic-graph/command-setter.t.cpp +++ b/include/dynamic-graph/command-setter.t.cpp @@ -35,7 +35,8 @@ namespace dynamicgraph { /// Pointer to method that sets paramter of type bool typedef void (E::*SetterMethod) (const bool&); /// Constructor - Setter(E& entity, SetterMethod); + Setter(E& entity, SetterMethod setterMethod, + const std::string& docString); protected: virtual Value doExecute(); @@ -45,8 +46,9 @@ namespace dynamicgraph { }; // Class Setter template <class E> - Setter<E, bool>::Setter(E& entity, SetterMethod setterMethod) : - Command(entity, boost::assign::list_of(Value::BOOL)), + Setter<E, bool>::Setter(E& entity, SetterMethod setterMethod, + const std::string& docString) : + Command(entity, boost::assign::list_of(Value::BOOL), docString), setterMethod_(setterMethod) { } @@ -71,7 +73,8 @@ namespace dynamicgraph { /// Pointer to method that sets paramter of type unsigned typedef void (E::*SetterMethod) (const unsigned&); /// Constructor - Setter(E& entity, SetterMethod); + Setter(E& entity, SetterMethod setterMethod, + const std::string& docString); protected: virtual Value doExecute(); @@ -81,8 +84,9 @@ namespace dynamicgraph { }; // Class Setter template <class E> - Setter<E, unsigned>::Setter(E& entity, SetterMethod setterMethod) : - Command(entity, boost::assign::list_of(Value::UNSIGNED)), + Setter<E, unsigned>::Setter(E& entity, SetterMethod setterMethod, + const std::string& docString) : + Command(entity, boost::assign::list_of(Value::UNSIGNED), docString), setterMethod_(setterMethod) { } @@ -107,7 +111,8 @@ namespace dynamicgraph { /// Pointer to method that sets paramter of type int typedef void (E::*SetterMethod) (const int&); /// Constructor - Setter(E& entity, SetterMethod); + Setter(E& entity, SetterMethod setterMethod, + const std::string& docString); protected: virtual Value doExecute(); @@ -117,8 +122,9 @@ namespace dynamicgraph { }; // Class Setter template <class E> - Setter<E, int>::Setter(E& entity, SetterMethod setterMethod) : - Command(entity, boost::assign::list_of(Value::INT)), + Setter<E, int>::Setter(E& entity, SetterMethod setterMethod, + const std::string& docString) : + Command(entity, boost::assign::list_of(Value::INT), docString), setterMethod_(setterMethod) { } @@ -143,7 +149,8 @@ namespace dynamicgraph { /// Pointer to method that sets paramter of type float typedef void (E::*SetterMethod) (const float&); /// Constructor - Setter(E& entity, SetterMethod); + Setter(E& entity, SetterMethod setterMethod, + const std::string& docString); protected: virtual Value doExecute(); @@ -153,8 +160,9 @@ namespace dynamicgraph { }; // Class Setter template <class E> - Setter<E, float>::Setter(E& entity, SetterMethod setterMethod) : - Command(entity, boost::assign::list_of(Value::FLOAT)), + Setter<E, float>::Setter(E& entity, SetterMethod setterMethod, + const std::string& docString) : + Command(entity, boost::assign::list_of(Value::FLOAT), docString), setterMethod_(setterMethod) { } @@ -179,7 +187,8 @@ namespace dynamicgraph { /// Pointer to method that sets paramter of type double typedef void (E::*SetterMethod) (const double&); /// Constructor - Setter(E& entity, SetterMethod); + Setter(E& entity, SetterMethod setterMethod, + const std::string& docString); protected: virtual Value doExecute(); @@ -189,8 +198,9 @@ namespace dynamicgraph { }; // Class Setter template <class E> - Setter<E, double>::Setter(E& entity, SetterMethod setterMethod) : - Command(entity, boost::assign::list_of(Value::DOUBLE)), + Setter<E, double>::Setter(E& entity, SetterMethod setterMethod, + const std::string& docString) : + Command(entity, boost::assign::list_of(Value::DOUBLE), docString), setterMethod_(setterMethod) { } @@ -215,7 +225,8 @@ namespace dynamicgraph { /// Pointer to method that sets paramter of type std::string typedef void (E::*SetterMethod) (const std::string&); /// Constructor - Setter(E& entity, SetterMethod); + Setter(E& entity, SetterMethod setterMethod, + const std::string& docString); protected: virtual Value doExecute(); @@ -225,8 +236,9 @@ namespace dynamicgraph { }; // Class Setter template <class E> - Setter<E, std::string>::Setter(E& entity, SetterMethod setterMethod) : - Command(entity, boost::assign::list_of(Value::STRING)), + Setter<E, std::string>::Setter(E& entity, SetterMethod setterMethod, + const std::string& docString) : + Command(entity, boost::assign::list_of(Value::STRING), docString), setterMethod_(setterMethod) { } @@ -251,7 +263,8 @@ namespace dynamicgraph { /// Pointer to method that sets paramter of type Vector typedef void (E::*SetterMethod) (const Vector&); /// Constructor - Setter(E& entity, SetterMethod); + Setter(E& entity, SetterMethod setterMethod, + const std::string& docString); protected: virtual Value doExecute(); @@ -261,8 +274,9 @@ namespace dynamicgraph { }; // Class Setter template <class E> - Setter<E, Vector>::Setter(E& entity, SetterMethod setterMethod) : - Command(entity, boost::assign::list_of(Value::VECTOR)), + Setter<E, Vector>::Setter(E& entity, SetterMethod setterMethod, + const std::string& docString) : + Command(entity, boost::assign::list_of(Value::VECTOR), docString), setterMethod_(setterMethod) { } @@ -287,7 +301,8 @@ namespace dynamicgraph { /// Pointer to method that sets paramter of type Matrix typedef void (E::*SetterMethod) (const Matrix&); /// Constructor - Setter(E& entity, SetterMethod); + Setter(E& entity, SetterMethod setterMethod, + const std::string& docString); protected: virtual Value doExecute(); @@ -297,8 +312,9 @@ namespace dynamicgraph { }; // Class Setter template <class E> - Setter<E, Matrix>::Setter(E& entity, SetterMethod setterMethod) : - Command(entity, boost::assign::list_of(Value::MATRIX)), + Setter<E, Matrix>::Setter(E& entity, SetterMethod setterMethod, + const std::string& docString) : + Command(entity, boost::assign::list_of(Value::MATRIX), docString), setterMethod_(setterMethod) { } diff --git a/include/dynamic-graph/command.h b/include/dynamic-graph/command.h index f15e793b80401fe9fa2fcd765b4530337fe0c26d..cbfd7a975e582ff5eac1f6aa8a08577865380fe9 100644 --- a/include/dynamic-graph/command.h +++ b/include/dynamic-graph/command.h @@ -47,7 +47,9 @@ namespace dynamicgraph { /// 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 - Command(Entity& entity, const std::vector<Value::Type>& valueTypes); + /// \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 @@ -58,6 +60,8 @@ namespace dynamicgraph { 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; @@ -65,6 +69,7 @@ namespace dynamicgraph { Entity& owner_; std::vector<Value::Type> valueTypeVector_; std::vector<Value> valueVector_; + std::string docstring_; }; } // namespace command } // namespace dynamicgraph diff --git a/src/command/command.cpp b/src/command/command.cpp index 8d7ed1a6066ca78c4069aac8918b81ad726d7210..2c71ef0e06a9cc3cb4cac4fa31b854575f0b848b 100644 --- a/src/command/command.cpp +++ b/src/command/command.cpp @@ -24,8 +24,9 @@ namespace dynamicgraph { Command::~Command() {} Command::Command(Entity& entity, - const std::vector<Value::Type>& valueTypes) : - owner_(entity), valueTypeVector_(valueTypes) + const std::vector<Value::Type>& valueTypes, + const std::string& docstring) : + owner_(entity), valueTypeVector_(valueTypes), docstring_(docstring) { } @@ -62,7 +63,7 @@ namespace dynamicgraph { } Value Command::execute() - { + { return doExecute(); } @@ -70,5 +71,9 @@ namespace dynamicgraph { { return owner_; } + std::string Command::getDocstring() const + { + return docstring_; + } } // namespace command } //namespace dynamicgraph