Unverified Commit 9cfb5ba2 authored by olivier stasse's avatar olivier stasse Committed by GitHub
Browse files

Merge pull request #44 from jmirabel/master

Add command Task.list to list the features
parents 74a73169 d29563eb
......@@ -32,30 +32,32 @@ namespace dynamicgraph { namespace sot {
using ::dynamicgraph::command::Command;
using ::dynamicgraph::command::Value;
// Command AddFeature
class AddFeature : public Command
// Command ListFeatures
class ListFeatures : public Command
{
public:
virtual ~AddFeature() {}
virtual ~ListFeatures() {}
/// Create command and store it in Entity
/// \param entity instance of Entity owning this command
/// \param docstring documentation of the command
AddFeature(Task& entity, const std::string& docstring) :
Command(entity, boost::assign::list_of(Value::STRING), docstring)
ListFeatures(Task& entity, const std::string& docstring) :
Command(entity, std::vector<Value::Type> (), docstring)
{
}
virtual Value doExecute()
{
Task& task = static_cast<Task&>(owner());
std::vector<Value> values = getParameterValues();
std::string featureName = values[0].value();
FeatureAbstract& feature =
PoolStorage::getInstance()->getFeature(featureName);
task.addFeature(feature);
// return void
return Value();
typedef Task::FeatureList_t FeatureList_t;
Task& task = static_cast<Task&>(owner());
const FeatureList_t& fl = task.getFeatureList();
std::string result("[");
for (FeatureList_t::const_iterator it = fl.begin ();
it != fl.end (); it++) {
result += "'" + (*it)->getName() + "',";
}
result += "]";
return Value(result);
}
}; // class AddFeature
}; // class ListFeatures
} // namespace task
} // namespace command
} /* namespace sot */} /* namespace dynamicgraph */
......
......@@ -106,6 +106,13 @@ void Task::initCommands( void )
addCommand("clear",
makeCommandVoid0(*this,&Task::clearFeatureList, docstring));
// List features
docstring = " \n"
" Returns the list of features of the task\n"
" \n";
addCommand("list",
new command::task::ListFeatures (*this, docstring));
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment