1 |
|
|
/* |
2 |
|
|
* Copyright 2010, |
3 |
|
|
* Florent Lamiraux |
4 |
|
|
* |
5 |
|
|
* CNRS |
6 |
|
|
* |
7 |
|
|
*/ |
8 |
|
|
|
9 |
|
|
#ifndef TASK_COMMAND_H |
10 |
|
|
#define TASK_COMMAND_H |
11 |
|
|
|
12 |
|
|
#include <dynamic-graph/command-getter.h> |
13 |
|
|
#include <dynamic-graph/command-setter.h> |
14 |
|
|
#include <dynamic-graph/command.h> |
15 |
|
|
|
16 |
|
|
#include <boost/assign/list_of.hpp> |
17 |
|
|
|
18 |
|
|
namespace dynamicgraph { |
19 |
|
|
namespace sot { |
20 |
|
|
namespace command { |
21 |
|
|
namespace task { |
22 |
|
|
using ::dynamicgraph::command::Command; |
23 |
|
|
using ::dynamicgraph::command::Value; |
24 |
|
|
|
25 |
|
|
// Command ListFeatures |
26 |
|
|
class ListFeatures : public Command { |
27 |
|
|
public: |
28 |
|
24 |
virtual ~ListFeatures() {} |
29 |
|
|
/// Create command and store it in Entity |
30 |
|
|
/// \param entity instance of Entity owning this command |
31 |
|
|
/// \param docstring documentation of the command |
32 |
|
8 |
ListFeatures(Task &entity, const std::string &docstring) |
33 |
✓✗ |
8 |
: Command(entity, std::vector<Value::Type>(), docstring) {} |
34 |
|
|
virtual Value doExecute() { |
35 |
|
|
typedef Task::FeatureList_t FeatureList_t; |
36 |
|
|
Task &task = static_cast<Task &>(owner()); |
37 |
|
|
const FeatureList_t &fl = task.getFeatureList(); |
38 |
|
|
std::string result("["); |
39 |
|
|
for (FeatureList_t::const_iterator it = fl.begin(); it != fl.end(); it++) { |
40 |
|
|
result += "'" + (*it)->getName() + "',"; |
41 |
|
|
} |
42 |
|
|
result += "]"; |
43 |
|
|
return Value(result); |
44 |
|
|
} |
45 |
|
|
}; // class ListFeatures |
46 |
|
|
} // namespace task |
47 |
|
|
} // namespace command |
48 |
|
|
} /* namespace sot */ |
49 |
|
|
} /* namespace dynamicgraph */ |
50 |
|
|
|
51 |
|
|
#endif // TASK_COMMAND_H |