File tree 3 files changed +41
-2
lines changed
3 files changed +41
-2
lines changed Original file line number Diff line number Diff line change @@ -81,11 +81,10 @@ namespace dynamicgraph {
81
81
return CLASS_NAME;
82
82
}
83
83
84
- protected:
85
-
86
84
/* ! \brief Defines a type for a list of tasks */
87
85
typedef std::list<TaskAbstract*> StackType;
88
86
87
+ protected:
89
88
90
89
/* ! \brief This field is a list of controllers
91
90
managed by the stack of tasks. */
@@ -149,6 +148,7 @@ namespace dynamicgraph {
149
148
/* ! \name Methods to handle the stack.
150
149
@{
151
150
*/
151
+ virtual const StackType& tasks () const { return stack; }
152
152
153
153
/* ! \brief Push the task in the stack.
154
154
It has a lowest priority than the previous ones.
Original file line number Diff line number Diff line change @@ -183,6 +183,38 @@ namespace dynamicgraph { namespace sot {
183
183
}
184
184
}; // class Display
185
185
186
+ // Command List
187
+ class List : public Command
188
+ {
189
+ public:
190
+ virtual ~List () {}
191
+ // / Create command and store it in Entity
192
+ // / \param entity instance of Entity owning this command
193
+ // / \param docstring documentation of the command
194
+ List (Sot& entity, const std::string& docstring) :
195
+ Command (entity, std::vector<Value::Type> (), docstring)
196
+ {
197
+ }
198
+ virtual Value doExecute ()
199
+ {
200
+ Sot& sot = static_cast <Sot&>(owner ());
201
+ typedef Sot::StackType StackType;
202
+ const StackType& stack = sot.tasks ();
203
+
204
+ std::stringstream returnString;
205
+ returnString << " ( " ;
206
+ for (StackType::const_iterator it = stack.begin ();
207
+ it != stack.end (); ++it)
208
+ {
209
+ returnString << ' "' << (*it)->getName () << " \" , " ;
210
+ }
211
+ returnString << " )" ;
212
+
213
+ // return the stack
214
+ return Value (returnString.str ());
215
+ }
216
+ }; // class List
217
+
186
218
// Command Clear
187
219
class Clear : public Command
188
220
{
Original file line number Diff line number Diff line change @@ -161,6 +161,13 @@ Sot( const std::string& name )
161
161
addCommand (" clear" ,
162
162
new command::classSot::Clear (*this , docstring));
163
163
164
+ // List
165
+ docstring =" \n "
166
+ " returns the list of tasks pushed inside the stack.\n "
167
+ " \n " ;
168
+ addCommand (" list" ,
169
+ new command::classSot::List (*this , docstring));
170
+
164
171
165
172
}
166
173
You can’t perform that action at this time.
0 commit comments