A Command which can be bound to a function using boost::bind. More...
#include <rtt/CommandFunctor.hpp>
Public Types | |
| typedef F | Function |
|
typedef boost::shared_ptr < ActionInterface > | shared_ptr |
| Use this type for shared pointer storage of an ActionInterface object. | |
Public Member Functions | |
| CommandFunctor (const Function &func) | |
| Create a command calling a function. | |
| virtual void | readArguments () |
| This is invoked some time before execute() at a time when the action may read its function arguments. | |
| virtual bool | execute () |
| Execute the functionality of this action. | |
| virtual CommandInterface * | clone () const |
| The Clone Software Pattern. | |
| virtual void | reset () |
| Reset this action. | |
| virtual bool | valid () const |
| Inspect if this action was executed and valid. | |
| virtual ActionInterface * | copy (std::map< const DataSourceBase *, DataSourceBase * > &alreadyCloned) const |
| When copying an Orocos program, we want identical DataSource's to be mapped to identical DataSources, in order for the program to work correctly. | |
A Command which can be bound to a function using boost::bind.
See the boost::bind documentation (www.boost.org) for more examples. execute() will always return true. To have it return the boolean result of the bound function, a boost::function<bool(void)> object must be given. See the Commandfunctor specialisation class.
Usage :
* void myFun(void);
* bool myFun( ClassA* a );
* ClassA* _class;
*
* // Watch the 'newCommandFunctor' _function_ :
* CommandInterface* c,d;
* c = newCommandFunctor( boost::bind( &myFun ) );
* c->execute(); // calls myFun();
* d = newCommandFunctor( boost::bind(&myFun2, _class) );
* d->execute(); // calls myFun2( _class );
* Definition at line 70 of file CommandFunctor.hpp.
| virtual ActionInterface* RTT::ActionInterface::copy | ( | std::map< const DataSourceBase *, DataSourceBase * > & | alreadyCloned | ) | const [virtual, inherited] |
When copying an Orocos program, we want identical DataSource's to be mapped to identical DataSources, in order for the program to work correctly.
This is different from the clone function, where we simply want a new Action that can replace the old one directly.
This function takes a map that maps the old DataSource's onto their new replacements. This way, it is possible to check before cloning a DataSource, whether it has already been copied, and if so, reuse the existing copy.
To keep old source working, the standard implementation of this function simply calls the clone function. If your ActionInterface uses a DataSource, it is important that you reimplement this function correctly though.
Reimplemented in RTT::AsynchCommandDecorator, RTT::CommandComposite, RTT::CommandDataSource, RTT::CommandDataSourceBool, RTT::CommandDispatch, RTT::CommandExecFunction, RTT::Corba::CommandProxy, RTT::detail::DataSourceArgsCommand< CommandT, CommandF >, RTT::detail::DataSourceArgsEvent< SignatureT, FunctorT >, RTT::DispatchAction, RTT::DispatchInterface, RTT::TryCommand, and RTT::EvalCommand.
| virtual bool RTT::CommandFunctor< F >::execute | ( | ) | [inline, virtual] |
Execute the functionality of this action.
Implements RTT::ActionInterface.
Definition at line 86 of file CommandFunctor.hpp.
| virtual void RTT::ActionInterface::reset | ( | ) | [virtual, inherited] |
Reset this action.
Must be used after execute() failed.
Reimplemented in RTT::AsynchCommandDecorator, RTT::CommandCounter, RTT::CommandDataSource, RTT::CommandDataSourceBool, RTT::CommandDispatch, RTT::CommandExecFunction, RTT::Corba::CommandProxy, RTT::detail::DataSourceArgsCommand< CommandT, CommandF >, RTT::DispatchAction, RTT::DispatchInterface, RTT::TryCommand, and RTT::EvalCommand.
| virtual bool RTT::ActionInterface::valid | ( | ) | const [virtual, inherited] |
Inspect if this action was executed and valid.
This method may not be called before execute(). The default implementation returns always true, i.e. after execute(), it was executed. Override this method if it has more complex state semantics.
Reimplemented in RTT::CommandComposite, RTT::CommandDispatch, RTT::CommandExecFunction, RTT::Corba::CommandProxy, RTT::detail::DataSourceArgsCommand< CommandT, CommandF >, RTT::DispatchAction, RTT::DispatchInterface, and RTT::TryCommand.
1.6.1