Skip to content

Commit ea42800

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

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

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

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,40 @@ Value Setter<E, int>::doExecute() {
120120
return Value();
121121
}
122122

123+
//
124+
// Template specialization: int64_t
125+
//
126+
template <class E>
127+
class Setter<E, int64_t> : public Command {
128+
public:
129+
/// Pointer to method that sets parameter of type int64_t
130+
typedef void (E::*SetterMethod)(const int64_t &);
131+
/// Constructor
132+
Setter(E &entity, SetterMethod setterMethod, const std::string &docString);
133+
134+
protected:
135+
virtual Value doExecute();
136+
137+
private:
138+
SetterMethod setterMethod_;
139+
}; // Class Setter
140+
141+
template <class E>
142+
Setter<E, int64_t>::Setter(E &entity, SetterMethod setterMethod,
143+
const std::string &docString)
144+
: Command(entity, boost::assign::list_of(Value::LONGINT), docString),
145+
setterMethod_(setterMethod) {}
146+
147+
template <class E>
148+
Value Setter<E, int64_t>::doExecute() {
149+
const std::vector<Value> &values = getParameterValues();
150+
// Get parameter
151+
int64_t value = values[0].value();
152+
E &entity = static_cast<E &>(owner());
153+
(entity.*setterMethod_)(value);
154+
return Value();
155+
}
156+
123157
//
124158
// Template specialization: float
125159
//

0 commit comments

Comments
 (0)