command-getter.t.cpp 778 Bytes
Newer Older
florent's avatar
florent committed
1 2 3 4 5 6 7 8 9
//
// Copyright 2010 CNRS
//
// Author: Florent Lamiraux
//

#ifndef DYNAMIC_GRAPH_COMMAND_GETTER_T_CPP
#define DYNAMIC_GRAPH_COMMAND_GETTER_T_CPP

Guilhem Saurel's avatar
Guilhem Saurel committed
10
#include "dynamic-graph/command-getter.h"
florent's avatar
florent committed
11 12
#include <sstream>

13 14 15
namespace dynamicgraph {
class Entity;
namespace command {
florent's avatar
florent committed
16

17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
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