Skip to content

Commit a432add

Browse files
Florent Lamirauxflorent-lamiraux
authored andcommitted
[Command] Implement setter command for uint64_t.
1 parent ea42800 commit a432add

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

include/dynamic-graph/command-setter.t.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,41 @@ Value Setter<E, unsigned>::doExecute() {
8686
return Value();
8787
}
8888

89+
//
90+
// Template specialization: unsigned long
91+
//
92+
template <class E>
93+
class Setter<E, unsigned long> : public Command {
94+
public:
95+
/// Pointer to method that sets parameter of type unsigned long
96+
typedef void (E::*SetterMethod)(const unsigned long &);
97+
/// Constructor
98+
Setter(E &entity, SetterMethod setterMethod, const std::string &docString);
99+
100+
protected:
101+
virtual Value doExecute();
102+
103+
private:
104+
SetterMethod setterMethod_;
105+
}; // Class Setter
106+
107+
template <class E>
108+
Setter<E, unsigned long>::Setter(E &entity, SetterMethod setterMethod,
109+
const std::string &docString)
110+
: Command(entity, boost::assign::list_of(Value::UNSIGNEDLONGINT),
111+
docString),
112+
setterMethod_(setterMethod) {}
113+
114+
template <class E>
115+
Value Setter<E, unsigned long>::doExecute() {
116+
const std::vector<Value> &values = getParameterValues();
117+
// Get parameter
118+
unsigned long value = values[0].value();
119+
E &entity = static_cast<E &>(owner());
120+
(entity.*setterMethod_)(value);
121+
return Value();
122+
}
123+
89124
//
90125
// Template specialization: int
91126
//

0 commit comments

Comments
 (0)