Orocos Real-Time Toolkit  2.6.0
Public Types | Public Member Functions
RTT::scripting::TryCommand Class Reference

A command which tries another command and stores the result in a internal::DataSource<bool>. More...

#include <rtt/scripting/TryCommand.hpp>

Inheritance diagram for RTT::scripting::TryCommand:
RTT::base::ActionInterface

List of all members.

Public Types

typedef boost::shared_ptr
< ActionInterface
shared_ptr
 Use this type for shared pointer storage of an ActionInterface object.

Public Member Functions

 TryCommand (base::ActionInterface *command, internal::AssignableDataSource< bool >::shared_ptr storage=0)
 Try a command.
bool execute ()
 Execute the functionality of this action.
void reset ()
 Reset this action.
bool valid () const
 Inspect if this action was executed and valid.
void readArguments ()
 This is invoked some time before execute() at a time when the action may read its function arguments.
base::ActionInterfacetheCommand () const
internal::AssignableDataSource
< bool >::shared_ptr 
result ()
TryCommandclone () const
 The Clone Software Pattern.
TryCommandcopy (std::map< const base::DataSourceBase *, base::DataSourceBase * > &alreadyCloned) const
 When copying an Orocos program, we want identical internal::DataSource's to be mapped to identical DataSources, in order for the program to work correctly.

Detailed Description

A command which tries another command and stores the result in a internal::DataSource<bool>.

See also:
TryCommandResult.

Definition at line 59 of file TryCommand.hpp.


Member Function Documentation

TryCommand * RTT::TryCommand::copy ( std::map< const base::DataSourceBase *, base::DataSourceBase * > &  alreadyCloned) const [virtual]

When copying an Orocos program, we want identical internal::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 internal::DataSource's onto their new replacements. This way, it is possible to check before cloning a internal::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 internal::DataSource, it is important that you reimplement this function correctly though.

Reimplemented from RTT::base::ActionInterface.

Definition at line 105 of file TryCommand.cpp.

References RTT::base::ActionInterface::copy(), RTT::internal::AssignableDataSource< T >::copy(), and TryCommand().

bool RTT::TryCommand::execute ( ) [virtual]

Execute the functionality of this action.

Returns:
true if the action was accepted, false otherwise

Implements RTT::base::ActionInterface.

Definition at line 56 of file TryCommand.cpp.

References RTT::base::ActionInterface::execute(), RTT::internal::DataSource< T >::get(), and RTT::internal::AssignableDataSource< T >::set().

void RTT::TryCommand::reset ( ) [virtual]

Reset this action.

Must be used after execute() failed.

Reimplemented from RTT::base::ActionInterface.

Definition at line 70 of file TryCommand.cpp.

References RTT::base::ActionInterface::reset(), and RTT::internal::AssignableDataSource< T >::set().

bool RTT::TryCommand::valid ( ) const [virtual]

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 from RTT::base::ActionInterface.

Definition at line 75 of file TryCommand.cpp.

References RTT::internal::DataSource< T >::get(), and RTT::base::ActionInterface::valid().


The documentation for this class was generated from the following files: