File tree Expand file tree Collapse file tree 3 files changed +41
-2
lines changed Expand file tree Collapse file tree 3 files changed +41
-2
lines changed Original file line number Diff line number Diff line change @@ -81,11 +81,10 @@ namespace dynamicgraph {
8181 return CLASS_NAME;
8282 }
8383
84- protected:
85-
8684 /* ! \brief Defines a type for a list of tasks */
8785 typedef std::list<TaskAbstract*> StackType;
8886
87+ protected:
8988
9089 /* ! \brief This field is a list of controllers
9190 managed by the stack of tasks. */
@@ -149,6 +148,7 @@ namespace dynamicgraph {
149148 /* ! \name Methods to handle the stack.
150149 @{
151150 */
151+ virtual const StackType& tasks () const { return stack; }
152152
153153 /* ! \brief Push the task in the stack.
154154 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 {
183183 }
184184 }; // class Display
185185
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+
186218 // Command Clear
187219 class Clear : public Command
188220 {
Original file line number Diff line number Diff line change @@ -161,6 +161,13 @@ Sot( const std::string& name )
161161 addCommand (" clear" ,
162162 new command::classSot::Clear (*this , docstring));
163163
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+
164171
165172}
166173
You can’t perform that action at this time.
0 commit comments