Commit 48e05f15 authored by Olivier Stasse's avatar Olivier Stasse
Browse files

Fix typo. Enforce 80 columns policy.

parent db1c58f5
Pipeline #5300 passed with stage
in 3 minutes and 43 seconds
This diff is collapsed.
......@@ -19,36 +19,45 @@
#include <boost/assign/list_of.hpp>
/* --- GETTER --------------------------------------------------------- */
namespace dynamicgraph {
namespace command {
template <class E, typename T>
class DirectGetter : public Command {
public:
/// Pointer to method that sets parameter of type T
typedef T (E::*GetterMethod)() const;
/// Constructor
DirectGetter(E& entity, T* ptr, const std::string& docString)
: Command(entity, std::vector<Value::Type>(), docString), T_ptr(ptr) {}
protected:
virtual Value doExecute() { return Value(*T_ptr); }
private:
T* T_ptr;
};
template <class E, typename T>
DirectGetter<E, T>* makeDirectGetter(E& entity, T* ptr, const std::string& docString) {
return new DirectGetter<E, T>(entity, ptr, docString);
}
inline std::string docDirectGetter(const std::string& name, const std::string& type) {
return std::string("\nGet the ") + name + ".\n\nNo input.\nReturn an " + type + ".\n\n";
}
} // namespace command
namespace dynamicgraph
{
namespace command
{
template <class E, typename T>
class DirectGetter : public Command
{
public:
/// Pointer to method that sets parameter of type T
typedef T (E::*GetterMethod)() const;
/// Constructor
DirectGetter(E& entity, T* ptr, const std::string& docString)
: Command(entity, std::vector<Value::Type>(), docString), T_ptr(ptr)
{}
protected:
virtual Value doExecute() { return Value(*T_ptr); }
private:
T* T_ptr;
};
template <class E, typename T>
DirectGetter<E, T>* makeDirectGetter
(E& entity, T* ptr, const std::string& docString)
{
return new DirectGetter<E, T>(entity, ptr, docString);
}
inline std::string docDirectGetter
(const std::string& name, const std::string& type)
{
return std::string("\nGet the ") + name +
".\n\nNo input.\nReturn an " + type + ".\n\n";
}
} // namespace command
} // namespace dynamicgraph
#endif // __dg_command_direct_getter_h__
......@@ -19,37 +19,47 @@
#include <boost/assign/list_of.hpp>
/* --- SETTER --------------------------------------------------------- */
namespace dynamicgraph {
namespace command {
template <class E, typename T>
class DirectSetter : public Command {
public:
DirectSetter(E& entity, T* ptr, const std::string& docString)
: Command(entity, boost::assign::list_of(ValueHelper<T>::TypeID), docString), T_ptr(ptr) {}
protected:
virtual Value doExecute() {
const std::vector<Value>& values = getParameterValues();
T val = values[0].value();
(*T_ptr) = val;
return Value(); // void
}
private:
T* T_ptr;
};
template <class E, typename T>
DirectSetter<E, T>* makeDirectSetter(E& entity, T* ptr, const std::string& docString) {
return new DirectSetter<E, T>(entity, ptr, docString);
}
inline std::string docDirectSetter(const std::string& name, const std::string& type) {
return std::string("\nSet the ") + name + ".\n\nInput:\n - a " + type + ".\nVoid return.\n\n";
}
} // namespace command
namespace dynamicgraph
{
namespace command
{
template <class E, typename T>
class DirectSetter : public Command
{
public:
DirectSetter(E& entity, T* ptr, const std::string& docString)
: Command(entity, boost::assign::list_of(ValueHelper<T>::TypeID),
docString), T_ptr(ptr) {}
protected:
virtual Value doExecute()
{
const std::vector<Value>& values = getParameterValues();
T val = values[0].value();
(*T_ptr) = val;
return Value(); // void
}
private:
T* T_ptr;
};
template <class E, typename T>
DirectSetter<E, T>* makeDirectSetter
(E& entity, T* ptr, const std::string& docString)
{
return new DirectSetter<E, T>(entity, ptr, docString);
}
inline std::string docDirectSetter
(const std::string& name, const std::string& type)
{
return std::string("\nSet the ") + name + ".\n\nInput:\n - a " + type +
".\nVoid return.\n\n";
}
} // namespace command
} // namespace dynamicgraph
#endif // __dg_command_direct_setter_h__
......@@ -9,21 +9,28 @@
#include <sstream>
namespace dynamicgraph {
class Entity;
namespace command {
template <class E, typename T>
Getter<E, T>::Getter(E& entity, GetterMethod getterMethod, const std::string& docstring)
: Command(entity, std::vector<Value::Type>(), docstring), getterMethod_(getterMethod) {}
template <class E, typename T>
Value Getter<E, T>::doExecute() {
E& entity = static_cast<E&>(owner());
T value = (entity.*getterMethod_)();
return Value(value);
}
} // namespace command
namespace dynamicgraph
{
class Entity;
namespace command
{
template <class E, typename T>
Getter<E, T>::Getter
(E& entity, GetterMethod getterMethod,
const std::string& docstring)
: Command(entity, std::vector<Value::Type>(), docstring),
getterMethod_(getterMethod)
{}
template <class E, typename T>
Value Getter<E, T>::doExecute()
{
E& entity = static_cast<E&>(owner());
T value = (entity.*getterMethod_)();
return Value(value);
}
} // namespace command
} // namespace dynamicgraph
#endif // DYNAMIC_GRAPH_COMMAND_GETTER_T_CPP
......@@ -11,267 +11,313 @@
#include <boost/assign/list_of.hpp>
#include "dynamic-graph/linear-algebra.h"
namespace dynamicgraph {
class Entity;
namespace command {
//
// Template specialization: bool
//
template <class E>
class Setter<E, bool> : public Command {
public:
/// Pointer to method that sets parameter of type bool
typedef void (E::*SetterMethod)(const bool&);
/// Constructor
Setter(E& entity, SetterMethod setterMethod, const std::string& docString);
protected:
virtual Value doExecute();
private:
SetterMethod setterMethod_;
}; // Class Setter
template <class E>
Setter<E, bool>::Setter(E& entity, SetterMethod setterMethod, const std::string& docString)
: Command(entity, boost::assign::list_of(Value::BOOL), docString), setterMethod_(setterMethod) {}
template <class E>
Value Setter<E, bool>::doExecute() {
const std::vector<Value>& values = getParameterValues();
// Get parameter
bool value = values[0].value();
E& entity = static_cast<E&>(owner());
(entity.*setterMethod_)(value);
return Value();
}
//
// Template specialization: unsigned
//
template <class E>
class Setter<E, unsigned> : public Command {
public:
/// Pointer to method that sets parameter of type unsigned
typedef void (E::*SetterMethod)(const unsigned&);
/// Constructor
Setter(E& entity, SetterMethod setterMethod, const std::string& docString);
protected:
virtual Value doExecute();
private:
SetterMethod setterMethod_;
}; // Class Setter
template <class E>
Setter<E, unsigned>::Setter(E& entity, SetterMethod setterMethod, const std::string& docString)
: Command(entity, boost::assign::list_of(Value::UNSIGNED), docString), setterMethod_(setterMethod) {}
template <class E>
Value Setter<E, unsigned>::doExecute() {
const std::vector<Value>& values = getParameterValues();
// Get parameter
unsigned value = values[0].value();
E& entity = static_cast<E&>(owner());
(entity.*setterMethod_)(value);
return Value();
}
//
// Template specialization: int
//
template <class E>
class Setter<E, int> : public Command {
public:
/// Pointer to method that sets parameter of type int
typedef void (E::*SetterMethod)(const int&);
/// Constructor
Setter(E& entity, SetterMethod setterMethod, const std::string& docString);
protected:
virtual Value doExecute();
private:
SetterMethod setterMethod_;
}; // Class Setter
template <class E>
Setter<E, int>::Setter(E& entity, SetterMethod setterMethod, const std::string& docString)
: Command(entity, boost::assign::list_of(Value::INT), docString), setterMethod_(setterMethod) {}
template <class E>
Value Setter<E, int>::doExecute() {
const std::vector<Value>& values = getParameterValues();
// Get parameter
int value = values[0].value();
E& entity = static_cast<E&>(owner());
(entity.*setterMethod_)(value);
return Value();
}
//
// Template specialization: float
//
template <class E>
class Setter<E, float> : public Command {
public:
/// Pointer to method that sets parameter of type float
typedef void (E::*SetterMethod)(const float&);
/// Constructor
Setter(E& entity, SetterMethod setterMethod, const std::string& docString);
protected:
virtual Value doExecute();
private:
SetterMethod setterMethod_;
}; // Class Setter
template <class E>
Setter<E, float>::Setter(E& entity, SetterMethod setterMethod, const std::string& docString)
: Command(entity, boost::assign::list_of(Value::FLOAT), docString), setterMethod_(setterMethod) {}
template <class E>
Value Setter<E, float>::doExecute() {
const std::vector<Value>& values = getParameterValues();
// Get parameter
float value = values[0].value();
E& entity = static_cast<E&>(owner());
(entity.*setterMethod_)(value);
return Value();
}
//
// Template specialization: double
//
template <class E>
class Setter<E, double> : public Command {
public:
/// Pointer to method that sets parameter of type double
typedef void (E::*SetterMethod)(const double&);
/// Constructor
Setter(E& entity, SetterMethod setterMethod, const std::string& docString);
protected:
virtual Value doExecute();
private:
SetterMethod setterMethod_;
}; // Class Setter
template <class E>
Setter<E, double>::Setter(E& entity, SetterMethod setterMethod, const std::string& docString)
: Command(entity, boost::assign::list_of(Value::DOUBLE), docString), setterMethod_(setterMethod) {}
template <class E>
Value Setter<E, double>::doExecute() {
const std::vector<Value>& values = getParameterValues();
// Get parameter
double value = values[0].value();
E& entity = static_cast<E&>(owner());
(entity.*setterMethod_)(value);
return Value();
}
//
// Template specialization: std::string
//
template <class E>
class Setter<E, std::string> : public Command {
public:
/// Pointer to method that sets parameter of type std::string
typedef void (E::*SetterMethod)(const std::string&);
/// Constructor
Setter(E& entity, SetterMethod setterMethod, const std::string& docString);
protected:
virtual Value doExecute();
private:
SetterMethod setterMethod_;
}; // Class Setter
template <class E>
Setter<E, std::string>::Setter(E& entity, SetterMethod setterMethod, const std::string& docString)
: Command(entity, boost::assign::list_of(Value::STRING), docString), setterMethod_(setterMethod) {}
template <class E>
Value Setter<E, std::string>::doExecute() {
const std::vector<Value>& values = getParameterValues();
// Get parameter
std::string value = values[0].value();
E& entity = static_cast<E&>(owner());
(entity.*setterMethod_)(value);
return Value();
}
//
// Template specialization: Vector
//
template <class E>
class Setter<E, Vector> : public Command {
public:
/// Pointer to method that sets parameter of type Vector
typedef void (E::*SetterMethod)(const Vector&);
/// Constructor
Setter(E& entity, SetterMethod setterMethod, const std::string& docString);
protected:
virtual Value doExecute();
private:
SetterMethod setterMethod_;
}; // Class Setter
template <class E>
Setter<E, Vector>::Setter(E& entity, SetterMethod setterMethod, const std::string& docString)
: Command(entity, boost::assign::list_of(Value::VECTOR), docString), setterMethod_(setterMethod) {}
template <class E>
Value Setter<E, Vector>::doExecute() {
const std::vector<Value>& values = getParameterValues();
// Get parameter
Vector value = values[0].value();
E& entity = static_cast<E&>(owner());
(entity.*setterMethod_)(value);
return Value();
}
//
// Template specialization: Matrix
//
template <class E>
class Setter<E, Matrix> : public Command {
public:
/// Pointer to method that sets parameter of type Matrix
typedef void (E::*SetterMethod)(const Matrix&);
/// Constructor
Setter(E& entity, SetterMethod setterMethod, const std::string& docString);
protected:
virtual Value doExecute();
private:
SetterMethod setterMethod_;
}; // Class Setter
template <class E>
Setter<E, Matrix>::Setter(E& entity, SetterMethod setterMethod, const std::string& docString)
: Command(entity, boost::assign::list_of(Value::MATRIX), docString), setterMethod_(setterMethod) {}
template <class E>
Value Setter<E, Matrix>::doExecute() {
const std::vector<Value>& values = getParameterValues();
// Get parameter
Matrix value = values[0].value();
E& entity = static_cast<E&>(owner());
(entity.*setterMethod_)(value);
return Value();
}
} // namespace command
namespace dynamicgraph
{
class Entity;
namespace command
{
//
// Template specialization: bool
//
template <class E>
class Setter<E, bool> : public Command
{
public:
/// Pointer to method that sets parameter of type bool
typedef void (E::*SetterMethod)(const bool&);
/// Constructor
Setter(E& entity, SetterMethod setterMethod,
const std::string& docString);
protected:
virtual Value doExecute();
private:
SetterMethod setterMethod_;
}; // Class Setter
template <class E>
Setter<E, bool>::Setter
(E& entity, SetterMethod setterMethod,
const std::string& docString)
: Command(entity, boost::assign::list_of(Value::BOOL), docString),
setterMethod_(setterMethod)
{}
template <class E>
Value Setter<E, bool>::doExecute()
{
const std::vector<Value>& values = getParameterValues();
// Get parameter
bool value = values[0].value();
E& entity = static_cast<E&>(owner());
(entity.*setterMethod_)(value);
return Value();
}
//
// Template specialization: unsigned
//
template <class E>
class Setter<E, unsigned> : public Command
{
public:
/// Pointer to method that sets parameter of type unsigned
typedef void (E::*SetterMethod)(const unsigned&);
/// Constructor
Setter(E& entity, SetterMethod setterMethod,
const std::string& docString);
protected:
virtual Value doExecute();
private:
SetterMethod setterMethod_;
}; // Class Setter
template <class E>
Setter<E, unsigned>::Setter
(E& entity, SetterMethod setterMethod,
const std::string& docString)
:
Command(entity, boost::assign::list_of(Value::UNSIGNED), docString),
setterMethod_(setterMethod) {}
template <class E>
Value Setter<E, unsigned>::doExecute()
{
const std::vector<Value>& values = getParameterValues();
// Get parameter
unsigned value = values[0].value();
E& entity = static_cast<E&>(owner());
(entity.*setterMethod_)(value);
return Value();
}
//
// Template specialization: int
//
template <class E>
class Setter<E, int> : public Command
{
public:
/// Pointer to method that sets parameter of type int
typedef void (E::*SetterMethod)(const int&);
/// Constructor
Setter(E& entity, SetterMethod setterMethod,
const std::string& docString);
protected:
virtual Value doExecute();
private:
SetterMethod setterMethod_;
}; // Class Setter
template <class E>
Setter<E, int>::Setter(E& entity, SetterMethod setterMethod,
const std::string& docString)
: Command(entity, boost::assign::list_of(Value::INT), docString),
setterMethod_(setterMethod) {}
template <class E>
Value Setter<E, int>::doExecute()
{
const std::vector<Value>& values = getParameterValues();
// Get parameter
int value = values[0].value();
E& entity = static_cast<E&>(owner());
(entity.*setterMethod_)(value);
return Value();
}