Orocos Real-Time Toolkit  2.8.3
Public Types | Public Member Functions | List of all members
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

Public Types

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

Public Member Functions

 TryCommand (base::ActionInterface *command, internal::AssignableDataSource< bool >::shared_ptr storage=0)
 Try a command. More...
 
 ~TryCommand ()
 
bool execute ()
 Execute the functionality of this action. More...
 
void reset ()
 Reset this action. More...
 
bool valid () const
 Inspect if this action was executed and valid. More...
 
void readArguments ()
 This is invoked some time before execute() at a time when the action may read its function arguments. More...
 
base::ActionInterfacetheCommand () const
 
internal::AssignableDataSource< bool >::shared_ptr result ()
 
TryCommandclone () const
 The Clone Software Pattern. More...
 
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. More...
 

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 Typedef Documentation

typedef boost::shared_ptr<ActionInterface> RTT::base::ActionInterface::shared_ptr
inherited

Use this type for shared pointer storage of an ActionInterface object.

Definition at line 78 of file ActionInterface.hpp.

Constructor & Destructor Documentation

RTT::TryCommand::TryCommand ( base::ActionInterface command,
internal::AssignableDataSource< bool >::shared_ptr  storage = 0 
)

Try a command.

Definition at line 48 of file TryCommand.cpp.

Referenced by clone(), and copy().

RTT::TryCommand::~TryCommand ( )

Definition at line 53 of file TryCommand.cpp.

Member Function Documentation

TryCommand * RTT::TryCommand::clone ( ) const
virtual

The Clone Software Pattern.

Implements RTT::base::ActionInterface.

Definition at line 100 of file TryCommand.cpp.

References RTT::base::ActionInterface::clone(), and TryCommand().

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::readArguments ( )
virtual

This is invoked some time before execute() at a time when the action may read its function arguments.

Implements RTT::base::ActionInterface.

Definition at line 82 of file TryCommand.cpp.

References RTT::base::ActionInterface::readArguments(), 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().

AssignableDataSource< bool >::shared_ptr RTT::TryCommand::result ( )

Definition at line 96 of file TryCommand.cpp.

Referenced by RTT::scripting::ProgramGraphParser::parseFunction().

ActionInterface * RTT::TryCommand::theCommand ( ) const

Definition at line 92 of file TryCommand.cpp.

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: