sot-command.h
Go to the documentation of this file.
1 /*
2  * Copyright 2010,
3  * Florent Lamiraux
4  *
5  * CNRS
6  *
7  */
8 
9 #ifndef SOT_COMMAND_H
10 #define SOT_COMMAND_H
11 
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 classSot {
22 using ::dynamicgraph::command::Command;
23 using ::dynamicgraph::command::Value;
24 
25 // Command Push
26 class Push : public Command {
27  public:
28  virtual ~Push() {}
32  Push(Sot &entity, const std::string &docstring)
33  : Command(entity, boost::assign::list_of(Value::STRING), docstring) {}
34  virtual Value doExecute() {
35  Sot &sot = static_cast<Sot &>(owner());
36  std::vector<Value> values = getParameterValues();
37  std::string taskName = values[0].value();
38 
39  TaskAbstract &task = PoolStorage::getInstance()->getTask(taskName);
40  sot.push(task);
41  // return void
42  return Value();
43  }
44 }; // class Push
45 
46 // Command Remove
47 class Remove : public Command {
48  public:
49  virtual ~Remove() {}
53  Remove(Sot &entity, const std::string &docstring)
54  : Command(entity, boost::assign::list_of(Value::STRING), docstring) {}
55  virtual Value doExecute() {
56  Sot &sot = static_cast<Sot &>(owner());
57  std::vector<Value> values = getParameterValues();
58  std::string taskName = values[0].value();
59 
60  TaskAbstract &task = PoolStorage::getInstance()->getTask(taskName);
61  sot.remove(task);
62  // return void
63  return Value();
64  }
65 }; // class Remove
66 
67 // Command Up
68 class Up : public Command {
69  public:
70  virtual ~Up() {}
74  Up(Sot &entity, const std::string &docstring)
75  : Command(entity, boost::assign::list_of(Value::STRING), docstring) {}
76  virtual Value doExecute() {
77  Sot &sot = static_cast<Sot &>(owner());
78  std::vector<Value> values = getParameterValues();
79  std::string taskName = values[0].value();
80 
81  TaskAbstract &task = PoolStorage::getInstance()->getTask(taskName);
82  sot.up(task);
83  // return void
84  return Value();
85  }
86 }; // class Remove
87 
88 // Command Down
89 class Down : public Command {
90  public:
91  virtual ~Down() {}
95  Down(Sot &entity, const std::string &docstring)
96  : Command(entity, boost::assign::list_of(Value::STRING), docstring) {}
97  virtual Value doExecute() {
98  Sot &sot = static_cast<Sot &>(owner());
99  std::vector<Value> values = getParameterValues();
100  std::string taskName = values[0].value();
101 
102  TaskAbstract &task = PoolStorage::getInstance()->getTask(taskName);
103  sot.down(task);
104  // return void
105  return Value();
106  }
107 }; // class Down
108 
109 // Command Display
110 class Display : public Command {
111  public:
112  virtual ~Display() {}
116  Display(Sot &entity, const std::string &docstring)
117  : Command(entity, std::vector<Value::Type>(), docstring) {}
118  virtual Value doExecute() {
119  std::stringstream returnString;
120  Sot &sot = static_cast<Sot &>(owner());
121  sot.display(returnString);
122 
123  // return the stack
124  return Value(returnString.str());
125  }
126 }; // class Display
127 
128 // Command List
129 class List : public Command {
130  public:
131  virtual ~List() {}
135  List(Sot &entity, const std::string &docstring)
136  : Command(entity, std::vector<Value::Type>(), docstring) {}
137  virtual Value doExecute() {
138  Sot &sot = static_cast<Sot &>(owner());
139  typedef Sot::StackType StackType;
140  const StackType &stack = sot.tasks();
141 
142  std::stringstream returnString;
143  returnString << "( ";
144  for (StackType::const_iterator it = stack.begin(); it != stack.end();
145  ++it) {
146  returnString << '"' << (*it)->getName() << "\", ";
147  }
148  returnString << ")";
149 
150  // return the stack
151  return Value(returnString.str());
152  }
153 }; // class List
154 
155 // Command Clear
156 class Clear : public Command {
157  public:
158  virtual ~Clear() {}
161  Clear(Sot &entity, const std::string &docstring)
162  : Command(entity, std::vector<Value::Type>(), docstring) {}
163  virtual Value doExecute() {
164  std::stringstream returnString;
165  Sot &sot = static_cast<Sot &>(owner());
166  sot.clear();
167  // return the stack
168  return Value();
169  }
170 }; // class Clear
171 
172 } // namespace classSot
173 } // namespace command
174 } /* namespace sot */
175 } /* namespace dynamicgraph */
176 
177 #endif // SOT_COMMAND_H
dynamicgraph::sot::command::classSot::Display
Definition: sot-command.h:110
dynamicgraph::sot::Sot::clear
virtual void clear(void)
Remove all the tasks from the stack.
Definition: sot.cpp:311
dynamicgraph::sot::command::classSot::Up
Definition: sot-command.h:68
dynamicgraph::sot::command::classSot::Display::doExecute
virtual Value doExecute()
Definition: sot-command.h:118
dynamicgraph::sot::command::classSot::Up::doExecute
virtual Value doExecute()
Definition: sot-command.h:76
dynamicgraph
dynamicgraph::sot::command::classSot::Display::~Display
virtual ~Display()
Definition: sot-command.h:112
dynamicgraph::sot::command::classSot::Push::doExecute
virtual Value doExecute()
Definition: sot-command.h:34
command-getter.h
dynamicgraph::sot::command::classSot::Remove::Remove
Remove(Sot &entity, const std::string &docstring)
Definition: sot-command.h:53
boost
dynamicgraph::sot::command::classSot::List::List
List(Sot &entity, const std::string &docstring)
Definition: sot-command.h:135
dynamicgraph::sot::Sot::display
virtual void display(std::ostream &os) const
Definition: sot.cpp:648
dynamicgraph::command::Command::getParameterValues
const std::vector< Value > & getParameterValues() const
dynamicgraph::sot::command::classSot::Remove
Definition: sot-command.h:47
dynamicgraph::sot::command::classSot::Clear
Definition: sot-command.h:156
dynamicgraph::sot::command::classSot::Clear::Clear
Clear(Sot &entity, const std::string &docstring)
Definition: sot-command.h:161
dynamicgraph::sot::command::classSot::Push::~Push
virtual ~Push()
Definition: sot-command.h:28
dynamicgraph::sot::command::classSot::Down::~Down
virtual ~Down()
Definition: sot-command.h:91
dynamicgraph::sot::TaskAbstract
Definition: task-abstract.hh:51
dynamicgraph::sot::command::classSot::List::~List
virtual ~List()
Definition: sot-command.h:131
dynamicgraph::sot::command::classSot::Push
Definition: sot-command.h:26
dynamicgraph::sot::command::classSot::Down::doExecute
virtual Value doExecute()
Definition: sot-command.h:97
dynamicgraph::sot::Sot
This class implements the Stack of Task. It allows to deal with the priority of the controllers throu...
Definition: sot.hh:57
command-setter.h
dynamicgraph::sot::Sot::remove
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...
Definition: sot.cpp:236
dynamicgraph::sot::Sot::tasks
virtual const StackType & tasks() const
Definition: sot.hh:110
dynamicgraph::command::Command
dynamicgraph::sot::Sot::push
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...
Definition: sot.cpp:210
dynamicgraph::sot::command::classSot::Push::Push
Push(Sot &entity, const std::string &docstring)
Definition: sot-command.h:32
dynamicgraph::sot::command::classSot::Display::Display
Display(Sot &entity, const std::string &docstring)
Definition: sot-command.h:116
dynamicgraph::sot::command::classSot::Clear::~Clear
virtual ~Clear()
Definition: sot-command.h:158
dynamicgraph::sot::Sot::StackType
std::list< TaskAbstract * > StackType
Defines a type for a list of tasks.
Definition: sot.hh:67
dynamicgraph::sot::command::classSot::List
Definition: sot-command.h:129
dynamicgraph::sot::command::classSot::List::doExecute
virtual Value doExecute()
Definition: sot-command.h:137
dynamicgraph::sot::command::classSot::Clear::doExecute
virtual Value doExecute()
Definition: sot-command.h:163
dynamicgraph::sot::command::classSot::Down
Definition: sot-command.h:89
dynamicgraph::sot::command::classSot::Up::Up
Up(Sot &entity, const std::string &docstring)
Definition: sot-command.h:74
dynamicgraph::sot::command::classSot::Up::~Up
virtual ~Up()
Definition: sot-command.h:70
dynamicgraph::sot::Sot::up
virtual void up(const TaskAbstract &task)
This method makes the task to swap with the task having the immediate superior priority.
Definition: sot.cpp:259
dynamicgraph::PoolStorage::getInstance
static PoolStorage * getInstance()
Definition: pool.cpp:147
values
list values
dynamicgraph::sot::command::classSot::Remove::~Remove
virtual ~Remove()
Definition: sot-command.h:49
dynamicgraph::sot::command::classSot::Down::Down
Down(Sot &entity, const std::string &docstring)
Definition: sot-command.h:95
Type
Eigen::Block< Mat > Type
dynamicgraph::sot::command::classSot::Remove::doExecute
virtual Value doExecute()
Definition: sot-command.h:55
dynamicgraph::sot::Sot::down
virtual void down(const TaskAbstract &task)
This method makes the task to swap with the task having the immediate inferior priority.
Definition: sot.cpp:282
command.h
dynamicgraph::command::Value
dynamicgraph::command::Command::owner
Entity & owner()


sot-core
Author(s): Olivier Stasse, ostasse@laas.fr
autogenerated on Tue Oct 24 2023 02:26:31