1 #ifndef ORO_CMD_FUNCTION_HPP 2 #define ORO_CMD_FUNCTION_HPP 4 #include "../SendStatus.hpp" 5 #include "../base/ActionInterface.hpp" 6 #include "../base/DisposableInterface.hpp" 8 #include "../internal/DataSources.hpp" 10 #include "../internal/DataSource.hpp" 11 #include "../ExecutionEngine.hpp" 12 #include <boost/shared_ptr.hpp> 13 #include <boost/bind.hpp> 18 {
namespace scripting {
19 using namespace detail;
32 boost::shared_ptr<ProgramInterface> _foo;
34 mutable bool isqueued;
46 boost::shared_ptr<ProgramInterface> foo,
50 mrunner(p), mcaller(caller),
51 _foo( foo ), ss(
SendFailure), isqueued(false), maccept(false)
63 if (isqueued ==
false ) {
67 minit->readArguments();
68 maccept = minit->execute() && mrunner->
runFunction( _foo.get() );
70 if ( _foo->needsStart() ) {
77 if ( _foo->inError() ) {
80 if ( _foo->isStopped() ) {
84 cout <<
"CmdFunction threw an exception" <<
endl;
111 return new CmdFunction( minit->clone(), _foo, mrunner, mcaller );
114 CmdFunction*
copy( std::map<const base::DataSourceBase*, base::DataSourceBase*>& alreadyCloned )
const 117 if ( alreadyCloned[
this] == 0 ) {
118 boost::shared_ptr<ProgramInterface> fcpy( _foo->copy(alreadyCloned) );
119 alreadyCloned[
this] =
new CmdFunction( minit->copy(alreadyCloned), fcpy , mrunner, mcaller);
122 assert ( dynamic_cast<CmdFunction*>( alreadyCloned[
this] ) == static_cast<CmdFunction*>( alreadyCloned[
this] ) );
123 return static_cast<CmdFunction*
>( alreadyCloned[
this] );
DataSource is a base class representing a generic way to read data of type T.
void reset()
Some conditions need to be reset at some points.
virtual CmdCollectCondition * copy(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 Da...
virtual SendStatus const & rvalue() const
Get a const reference to the value of this DataSource.
CmdFunction * copy(std::map< const base::DataSourceBase *, base::DataSourceBase * > &alreadyCloned) const
Create a deep copy of this internal::DataSource, unless it is already cloned.
virtual bool removeFunction(base::ExecutableInterface *f)
Remove a running function added with runFunction.
The base class for all internal data representations.
virtual CmdCollectCondition * clone() const
The Clone Software Pattern.
This interface represents the concept of a condition which can be evaluated and return true or false...
virtual void reset()
Reset the data to initial values.
CmdFunction * clone() const
Return a shallow clone of this DataSource.
bool evaluate()
Evaluate the Condition and return the outcome.
#define RTT_SCRIPTING_API
basic_ostreams & endl(basic_ostreams &s)
Flush and newline.
An execution engine serialises (executes one after the other) the execution of all commands...
SendStatus
Returns the status of a send() or collect() invocation.
virtual DataSource< T > * copy(std::map< const base::DataSourceBase *, base::DataSourceBase * > &alreadyCloned) const =0
Create a deep copy of this internal::DataSource, unless it is already cloned.
printstream cout
Console Output.
virtual SendStatus value() const
Return the result of the last evaluate() function.
Returned when the result of the send() could not be collected.
virtual const_reference_t rvalue() const =0
Get a const reference to the value of this DataSource.
Based on the software pattern 'command', this interface allows execution of action objects...
virtual bool evaluate() const
Force an evaluation of the DataSourceBase.
DataSource< SendStatus >::shared_ptr collectds
Returned when the send() succeeded, but the operation has not yet been executed by the receiving comp...
A DataSource which sends a FunctionFraph for execution in a ExecutionEngine.
Returned when the send() failed to deliver the operation call to the receiving component.
CmdFunction(base::ActionInterface *init_com, boost::shared_ptr< ProgramInterface > foo, ExecutionEngine *p, ExecutionEngine *caller)
Create a Command to send a function to a ExecutionEngine.
CmdCollectCondition(DataSource< SendStatus >::shared_ptr ds)
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
virtual bool runFunction(base::ExecutableInterface *f)
Run a given function in step() or loop().
A DataSource that collects the result of a CmdFunction.