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

Command constructor takes a documentation string as input.

	* include/dynamic-graph/command-getter.h,
	* include/dynamic-graph/command-getter.t.cpp,
	* include/dynamic-graph/command-setter.h,
	* include/dynamic-graph/command-setter.t.cpp,
	* include/dynamic-graph/command.h,
	* src/command/command.cpp.
parent 3e09f772
No related branches found
No related tags found
No related merge requests found
......@@ -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();
......
......@@ -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)
{
}
......
......@@ -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();
......
......@@ -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)
{
}
......
......@@ -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
......
......@@ -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
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