RTT::Command< CommandT > Class Template Reference
[Task Context InterfaceCommand Interface]

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

#include <rtt/Command.hpp>

List of all members.

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

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);

Definition at line 93 of file Command.hpp.


Constructor & Destructor Documentation

template<class CommandT>
RTT::Command< CommandT >::Command (  )  [inline]

Create an empty, nameless command object.

Use assignment to initialise it.

Definition at line 114 of file Command.hpp.

template<class CommandT>
RTT::Command< CommandT >::Command ( std::string  name  )  [inline]

Create an empty command object.

Use assignment to initialise it.

Parameters:
name The name of the command.

Definition at line 124 of file Command.hpp.

template<class CommandT>
template<class CommandF , class ConditionF , class ObjectT >
RTT::Command< CommandT >::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.

Definition at line 163 of file Command.hpp.

template<class CommandT>
template<class CommandF , class ConditionF , class ObjectT >
RTT::Command< CommandT >::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.

Definition at line 183 of file Command.hpp.

template<class CommandT>
template<class CommandF , class ConditionF >
RTT::Command< CommandT >::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.

Definition at line 199 of file Command.hpp.

template<class CommandT>
RTT::Command< CommandT >::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.

Definition at line 212 of file Command.hpp.


Member Function Documentation

template<class CommandT>
bool RTT::Command< CommandT >::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.

Definition at line 292 of file Command.hpp.

template<class CommandT>
bool RTT::Command< CommandT >::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().

Definition at line 301 of file Command.hpp.

template<class CommandT>
detail::CommandBase<CommandT>* RTT::Command< 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

Definition at line 331 of file Command.hpp.

template<class CommandT>
const std::string& RTT::Command< CommandT >::getName (  )  const [inline]

Returns the name of this Command object.

Returns:
the name.

Definition at line 320 of file Command.hpp.

template<class CommandT>
Command& RTT::Command< CommandT >::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.

Definition at line 238 of file Command.hpp.

template<class CommandT>
bool RTT::Command< CommandT >::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.

Definition at line 256 of file Command.hpp.

template<class CommandT>
bool RTT::Command< CommandT >::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.

Definition at line 282 of file Command.hpp.

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

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

Parameters:
new_impl The new implementation.

Definition at line 340 of file Command.hpp.

template<class CommandT>
bool RTT::Command< CommandT >::valid (  )  const [inline]

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

the command function itself was executed and returned true.

Definition at line 310 of file Command.hpp.


The documentation for this class was generated from the following file:
Generated on Thu Dec 23 13:22:40 2010 for Orocos Real-Time Toolkit by  doxygen 1.6.3