Command Class Template Reference
[Task Context InterfaceCommand Interface]

#include <rtt/Command.hpp>

List of all members.


Detailed Description

template<class CommandT>
class RTT::Command< CommandT >

A Command is a function which can be sent to a task for execution and be queried for its execution status.

The sending is also called the 'invocation' of the Command object.

It is good practice that the receiving task defines the commands it can execute, but this class allows otherwise as well.

Parameters:
CommandT The function signature of the command. For example, bool( int, Frame, double)
     class X : public TaskContext
     {
     public:
       // ....
       bool command_1(int i, Frame f, double d) {
         // ....
       }
       bool condition_1(int i, Frame f, double d) {
         // ....
       }
     };
     X x;
     Command<bool(int, Frame, double)> mycom("Command1",&X::command_1,&X::condition_1, &x);

     // Invoke the command:
     Frame f = //...
     mycom(3, f, 9.0);


Public Types

typedef CommandT Signature
typedef DispatchInterface::Status Status
 The status progressions of a Command.

Public Member Functions

 Command ()
 Create an empty, nameless command object.
 Command (std::string name)
 Create an empty command object.
 Command (const Command &c)
 Command objects are copy constructible.
Commandoperator= (const Command &c)
 Command objects may be assigned to each other.
template<class CommandF, class ConditionF, class ObjectT>
 Command (std::string name, CommandF com, ConditionF con, ObjectT t, bool invert=false)
 Create a Command object which executes a member function of a class that inherits from a TaskContext.
template<class CommandF, class ConditionF, class ObjectT>
 Command (std::string name, CommandF com, ConditionF con, ObjectT t, CommandProcessor *commandp, bool invert=false)
 Create a Command object which executes a member function of a class that is not a TaskContext.
template<class CommandF, class ConditionF>
 Command (std::string name, CommandF com, ConditionF con, CommandProcessor *commandp, bool invert=false)
 Create a Command object which executes a plain 'C' function.
 Command (DispatchInterface *implementation)
 Construct a Command which uses a ready-made implementation.
 ~Command ()
 Cleanup the command.
Commandoperator= (DispatchInterface *implementation)
 A Command objects may be assigned to an implementation.
bool ready () const
 Returns true if the command is ready for invocation.
bool done () const
 Returns true if the command is executed and the completion condition returns true as well.
void reset ()
 After reset(), another attempt to dispatch the command will be done when invoked.
bool sent () const
 Returns true if the command was sent to the CommandProcessor.
bool accepted () const
 Returns true if the command was accepted when sent to the CommandProcessor.
bool executed () const
 Returns true if the command function was executed by the CommandProcessor.
bool valid () const
 Returns true if the command was valid, i.e.
const std::string & getName () const
 Returns the name of this Command object.
detail::CommandBase< CommandT > * getCommandImpl () const
 The Command class is just a wrapper around an implementation, this function returns the implementation.
void setCommandImpl (detail::CommandBase< CommandT > *new_impl) const
 Change the implementation of this Command, delete the old one.

Protected Types

typedef detail::InvokerSignature<
boost::function_traits< CommandT
>::arity, CommandT, detail::CommandBase<
CommandT > * > 
Base

Protected Member Functions

 BOOST_STATIC_ASSERT ((boost::is_same< typename boost::function_traits< CommandT >::result_type, bool >::value))

Protected Attributes

std::string mname


Constructor & Destructor Documentation

Command (  )  [inline]

Create an empty, nameless command object.

Use assignment to initialise it.

Command ( std::string  name  )  [inline]

Create an empty command object.

Use assignment to initialise it.

Parameters:
name The name of the command.

Command ( std::string  name,
CommandF  com,
ConditionF  con,
ObjectT  t,
bool  invert = false 
) [inline]

Create a Command object which executes a member function of a class that inherits from a TaskContext.

Parameters:
name The name of this command.
com A pointer to the member function to execute when the command is invoked.
con A pointer to the member function that evaluates if the command is done.
t A pointer to an object of this class, which will receive and process the command.
invert Invert the result of con when evaluating the completion of the command.

Command ( std::string  name,
CommandF  com,
ConditionF  con,
ObjectT  t,
CommandProcessor commandp,
bool  invert = false 
) [inline]

Create a Command object which executes a member function of a class that is not a TaskContext.

Parameters:
name The name of this command.
com A pointer to the member function to execute when the command is invoked.
con A pointer to the member function that evaluates if the command is done.
t A pointer to an object of the class which has com and con.
commandp The CommandProcessor which will execute this Command.
invert Invert the result of con when evaluating the completion of the command.

Command ( std::string  name,
CommandF  com,
ConditionF  con,
CommandProcessor commandp,
bool  invert = false 
) [inline]

Create a Command object which executes a plain 'C' function.

Parameters:
name The name of this command.
com A pointer to the 'C' function to execute when the command is invoked.
con A pointer to the 'C' function that evaluates if the command is done.
commandp The CommandProcessor which will execute this Command.
invert Invert the result of con when evaluating the completion of the command.

Command ( DispatchInterface implementation  )  [inline]

Construct a Command which uses a ready-made implementation.

If the implementation is of the wrong type, it is freed.

Parameters:
implementation An implementation which will be owned by the command. If it is unusable, it is freed.


Member Function Documentation

Command& operator= ( DispatchInterface implementation  )  [inline]

A Command objects may be assigned to an implementation.

If the implementation is of the wrong type, it is freed.

Parameters:
implementation An implementation which will be owned by the command. If it is unusable, it is freed.

bool ready (  )  const [inline]

Returns true if the command is ready for invocation.

If ready() returns true, this command may be invoked, otherwise, invocation will fail.

bool sent (  )  const [inline]

Returns true if the command was sent to the CommandProcessor.

You can use this flag to check whether this command was invoked.

bool accepted (  )  const [inline]

Returns true if the command was accepted when sent to the CommandProcessor.

A Command is accepted when the CommandProcessor was running and its queue was not full.

bool executed (  )  const [inline]

Returns true if the command function was executed by the CommandProcessor.

When executed() is true, you can check if it was found valid().

bool valid (  )  const [inline]

Returns true if the command was valid, i.e.

the command function itself was executed and returned true.

const std::string& getName (  )  const [inline]

Returns the name of this Command object.

Returns:
the name.

detail::CommandBase<CommandT>* getCommandImpl (  )  const [inline]

The Command class is just a wrapper around an implementation, this function returns the implementation.

Make a clone() if you want to keep the pointer.

Returns:
The implementation

void setCommandImpl ( detail::CommandBase< CommandT > *  new_impl  )  const [inline]

Change the implementation of this Command, delete the old one.

Parameters:
new_impl The new implementation.


The documentation for this class was generated from the following file:
Generated on Fri May 11 11:19:31 2007 for Orocos by  doxygen 1.5.1