dynamic-graph  4.1.0-8-gdab7-dirty
Dynamic graph library
command-getter.t.cpp
1 //
2 // Copyright 2010 CNRS
3 //
4 // Author: Florent Lamiraux
5 //
6 
7 #ifndef DYNAMIC_GRAPH_COMMAND_GETTER_T_CPP
8 #define DYNAMIC_GRAPH_COMMAND_GETTER_T_CPP
9 
10 #include "dynamic-graph/command-getter.h"
11 #include <sstream>
12 
13 namespace dynamicgraph {
14 class Entity;
15 namespace command {
16 
17 template <class E, typename T>
18 Getter<E, T>::Getter(E &entity, GetterMethod getterMethod,
19  const std::string &docstring)
20  : Command(entity, std::vector<Value::Type>(), docstring),
21  getterMethod_(getterMethod) {}
22 
23 template <class E, typename T> Value Getter<E, T>::doExecute() {
24  E &entity = static_cast<E &>(owner());
25  T value = (entity.*getterMethod_)();
26  return Value(value);
27 }
28 } // namespace command
29 } // namespace dynamicgraph
30 
31 #endif // DYNAMIC_GRAPH_COMMAND_GETTER_T_CPP
Entity & owner()
Get a reference to the Entity owning this command.
This class implements a variant design pattern to handle basic types in Command.
Definition: value.h:46
Getter(E &entity, GetterMethod getterMethod, const std::string &docString)
Constructor.
virtual Value doExecute()
Specific action performed by the command.