This class implements an Orocos command processor. More...
#include <rtt/CommandProcessor.hpp>
Public Member Functions | |
CommandProcessor (int queue_size=ORONUM_EXECUTION_PROC_QUEUE_SIZE) | |
Constructs a new CommandProcessor. | |
virtual bool | initialize () |
The method that will be called before the first periodical execution of step() ( or non periodical execution of loop() ), when the thread is started. | |
virtual void | step () |
The method that will be periodically executed when this class RTT_API is run in a periodic thread. | |
virtual void | finalize () |
The method that will be called after the last periodical execution of step() ( or non periodical execution of loop() ), when the RunnableInterface is stopped. | |
virtual bool | hasWork () |
This method is for 'intelligent' activity implementations that wish to see if it is required to call step() (again). | |
virtual int | process (CommandInterface *c) |
Queue and execute (process) a given command. | |
virtual bool | isProcessed (int id) const |
Check if a given command id has been processed. | |
void | acceptCommands (bool true_false) |
Should the CommandProcessor accept or reject commands in process(). | |
ActivityInterface * | getActivity () const |
Query for the task this interface is run in. | |
virtual void | setActivity (ActivityInterface *task) |
Set the task this interface is run in. | |
virtual OS::ThreadInterface * | getThread () const |
Get the thread this object is run in. | |
virtual void | loop () |
The method that will be executed once when this class RTT_API is run in a non periodic thread. | |
virtual bool | breakLoop () |
This method is called by the framework to break out of the loop() method. | |
virtual void | setThread (ThreadInterface *t) |
Set the thread this object will be run in. | |
Protected Attributes | |
Queue< CommandInterface *, NonBlockingPolicy, NonBlockingPolicy > * | a_queue |
int | coms_processed |
Counting how much commands we processed. | |
bool | accept |
This class implements an Orocos command processor.
It executes external commands when running.
The default policy of the CommandProcessor is to dequeue one command in each step() and execute it. If you want to change this policy, subclass the CommandProcessor and override the virtual functions, such as step() or process(). The current command queue is non blocking for push and pop operations. process() fails when the queue is full; step() does nothing when the queue is empty. A subclass may install a new command queue with for example blocking semantics.
Definition at line 75 of file CommandProcessor.hpp.
RTT::CommandProcessor::CommandProcessor | ( | int | queue_size = ORONUM_EXECUTION_PROC_QUEUE_SIZE |
) |
Constructs a new CommandProcessor.
queue_size | The size of the command queue. |
void RTT::CommandProcessor::acceptCommands | ( | bool | true_false | ) | [inline] |
Should the CommandProcessor accept or reject commands in process().
true_false | true to accept, false to reject. |
Definition at line 121 of file CommandProcessor.hpp.
virtual bool RTT::OS::RunnableInterface::breakLoop | ( | ) | [virtual, inherited] |
This method is called by the framework to break out of the loop() method.
Reimplement this method to signal loop() to return and return true on success. When this method is not reimplemented by you, it will always return false, denoting that the loop can not be broken. If breakLoop() returns true, the caller will wait until loop() returns.
Reimplemented in RTT::EventProcessor, RTT::ExecutionEngine, and RTT::Timer.
ActivityInterface * RTT::RunnableInterface::getActivity | ( | ) | const [inline, inherited] |
Query for the task this interface is run in.
Zero denotes that no task is present to run it, and hence no detailed information is available.
Definition at line 106 of file RunnableInterface.hpp.
virtual OS::ThreadInterface* RTT::RunnableInterface::getThread | ( | ) | const [virtual, inherited] |
Get the thread this object is run in.
Reimplemented from RTT::OS::RunnableInterface.
virtual bool RTT::CommandProcessor::hasWork | ( | ) | [virtual] |
This method is for 'intelligent' activity implementations that wish to see if it is required to call step() (again).
By default, false is returned. You should only return true in case there is a temporary reason to (re-)run step.
Reimplemented from RTT::RunnableInterface.
virtual void RTT::OS::RunnableInterface::loop | ( | ) | [virtual, inherited] |
The method that will be executed once when this class RTT_API is run in a non periodic thread.
The default implementation calls step() once.
Reimplemented in RTT::Timer.
virtual int RTT::CommandProcessor::process | ( | CommandInterface * | c | ) | [virtual] |
Queue and execute (process) a given command.
The command is executed in step() or loop() directly after all other queued CommandInterface objects. The constructor parameter queue_size limits how many commands can be queued in between step()s or loop().
Referenced by RTT::detail::DataSourceArgsCommand< CommandT, CommandF >::dispatch(), and RTT::detail::LocalCommandImpl< CommandT >::invoke().
virtual void RTT::RunnableInterface::setActivity | ( | ActivityInterface * | task | ) | [virtual, inherited] |
Set the task this interface is run in.
A Zero means no task is running it.
task | The ActivityInterface running this interface. |
Reimplemented in RTT::ExecutionEngine.