10 #include <dynamic-graph/factory.h> 11 #include <dynamic-graph/pool.h> 27 outputStreamPtr(NULL),
30 "Sequencer(" + name +
")::output(dummy)::trigger") {
57 : sotEventAbstract(
name), taskPtr(task), defaultTaskName(
"NULL") {}
59 void init(std::istringstream &cmdArgs) {
64 sotDEBUG(15) <<
"Add task " << taskname << std::endl;
69 virtual void display(std::ostream &os)
const {
75 virtual const std::string &
getName()
const {
79 return defaultTaskName;
87 eventType = EVENT_ADD;
92 sotDEBUG(45) <<
"Sot = " << sotptr <<
". Task = " << taskPtr <<
"." 94 if ((NULL != sotptr) && (NULL != taskPtr)) sotptr->
push(*taskPtr);
98 virtual void display(std::ostream &os)
const {
109 eventType = EVENT_RM;
114 sotDEBUG(45) <<
"Sot = " << sotptr <<
". Task = " << taskPtr <<
"." 116 if ((NULL != sotptr) && (NULL != taskPtr)) sotptr->
remove(*taskPtr);
120 virtual void display(std::ostream &os)
const {
133 : sotEventAbstract(cmdLine +
"<cmd>"), cmd(cmdLine) {
134 eventType = EVENT_CMD;
138 void init(std::istringstream &args) {
140 std::stringbuf *pbuf = args.rdbuf();
141 const unsigned int size = (
unsigned int)(pbuf->in_avail());
142 char *buffer =
new char[size + 1];
143 pbuf->sgetn(buffer, size);
151 virtual void display(std::ostream &os)
const { os <<
"Run: " << cmd; }
153 std::ostringstream onull;
154 onull.clear(std::ios::failbit);
155 std::istringstream iss(cmd);
168 TaskMap::iterator listKey =
taskMap.find(timeSpec);
169 if (
taskMap.end() == listKey) {
170 sotDEBUG(15) <<
"New element at " << timeSpec << std::endl;
171 taskMap[timeSpec].push_back(task);
180 const unsigned int time) {
181 TaskMap::iterator listKey =
taskMap.find(time);
185 for (TaskList::iterator itL = tl.begin(); itL != tl.end(); ++itL) {
186 if ((*itL)->getEventType() == eventType && (*itL)->getName() ==
name) {
193 if (tl.empty())
taskMap.erase(listKey);
199 TaskMap::iterator itM;
201 TaskList::iterator itL;
203 for (itL = currentMap.begin(); itL != currentMap.end(); ++itL)
222 if (
taskMap.end() != listKey) {
224 <<
": we've got a task to do!" << std::endl;
226 for (TaskList::iterator iter = tl.begin(); iter != tl.end(); ++iter) {
228 (*iter)->operator()(
sotPtr);
230 (*outputStreamPtr) <<
"At time t=" << timeSpec <<
": ";
232 (*outputStreamPtr) << std::endl;
250 <<
",mode=" << ((
playMode) ?
"play" :
"pause") <<
"): " << std::endl;
251 for (TaskMap::const_iterator iterMap =
taskMap.begin();
252 iterMap !=
taskMap.end(); iterMap++) {
253 os <<
" - t=" << (iterMap->first) <<
":\t";
254 const TaskList &tl = iterMap->second;
255 for (TaskList::const_iterator iterList = tl.begin(); iterList != tl.end();
257 (*iterList)->display(os);
SignalArray< int > sotNOSIGNAL(0)
void signalRegistration(const SignalArray< int > &signals)
#define sotDEBUGOUT(level)
void setNeedUpdateFromAllChildren(const bool b=true)
const std::string defaultTaskName
virtual const std::string & getName() const
std::ostream * outputStreamPtr
void init(std::istringstream &cmdArgs)
void operator()(Sot *sotptr)
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(FeaturePosture, "FeaturePosture")
#define sotDEBUGIN(level)
virtual void push(TaskAbstract &task)
Push the task in the stack. It has a lowest priority than the previous ones. If this is the first tas...
sotEventAddATask(const std::string name="", TaskAbstract *task=NULL)
int & trigger(int &dummy, const int &time)
const std::string & getEventCmd() const
#define sotDEBUGINOUT(level)
void rmTask(int eventType, const std::string &name, const unsigned int time)
virtual void remove(const TaskAbstract &task)
Remove a task regardless to its position in the stack. It removes also the signals connected to the o...
Entity & getEntity(const std::string &name)
void init(std::istringstream &args)
static PoolStorage * getInstance()
virtual void display(std::ostream &os) const
virtual void display(std::ostream &os) const
Sequencer(const std::string &name)
const std::string & getName() const
void addTask(sotEventAbstract *task, const unsigned int time)
This class implements the Stack of Task. It allows to deal with the priority of the controllers throu...
virtual void display(std::ostream &os) const
std::list< sotEventAbstract * > TaskList
void operator()(Sot *sotptr)
dynamicgraph::SignalTimeDependent< int, int > triggerSOUT
sotEventRemoveATask(const std::string name="", TaskAbstract *task=NULL)
virtual void display(std::ostream &os) const
virtual void operator()(Sot *)
virtual void display(std::ostream &os) const
sotEventTaskBased(const std::string name="", TaskAbstract *task=NULL)
sotEventCmd(const std::string cmdLine="")