39 #ifndef ORO_CALL_FUNCTION_HPP 40 #define ORO_CALL_FUNCTION_HPP 42 #include "../base/ActionInterface.hpp" 43 #include "../base/DisposableInterface.hpp" 44 #include "../internal/DataSources.hpp" 46 #include "../internal/DataSource.hpp" 47 #include "../ExecutionEngine.hpp" 48 #include "../Logger.hpp" 49 #include <boost/shared_ptr.hpp> 50 #include <boost/bind.hpp> 53 {
namespace scripting {
54 using namespace detail;
67 boost::shared_ptr<ProgramInterface>
_foo;
76 return (!maccept || _foo->inError() || _foo->isStopped());
85 if ( _foo->inError() ) {
87 }
else if ( _foo->isStopped() ) {
103 boost::shared_ptr<ProgramInterface>
foo,
107 mrunner(p), mcaller(caller),
108 _foo( foo ), maccept(false)
133 if (!minit->
execute())
return false;
134 _foo->loaded(mrunner);
136 if ( _foo->needsStart() )
139 if ( mrunner->
isSelf() ) {
148 this->executeAndDispose();
149 if ( checkIfDone() )
return true;
150 log(
Warning) <<
"Execution of function '" << _foo->getName() <<
" did not finish in one cycle " 151 "and paused in line " << _foo->getLineNumber() <<
", e.g. because of a yield statement." <<
nlog()
152 <<
"As it was called from the executing thread, execution will continue immediately to avoid a dead-lock." <<
nlog()
153 <<
"This behavior might be unexpected and can cause busy-wait loops." <<
endlog();
166 maccept = mrunner->
process(
this );
167 if ( !maccept )
return false;
171 }
while( !checkIfDone() );
180 maccept = mrunner->
process(
this );
181 if ( !maccept )
return false;
185 if ( checkIfDone() )
return true;
194 if ( !maccept )
return false;
198 if ( checkIfDone() )
return true;
215 if ( _foo->execute() == false ) {
247 boost::shared_ptr<ProgramInterface> fcpy( _foo->copy(alreadyCloned) );
248 return new CallFunction( minit->
copy(alreadyCloned), fcpy , mrunner, mcaller );
static Logger::LogFunction nlog()
base::ActionInterface * clone() const
ExecutionEngine * mrunner
bool checkIfDoneOrYielded()
void waitForMessages(const boost::function< bool(void)> &pred)
virtual void readArguments()=0
virtual void executeAndDispose()
CallFunction(base::ActionInterface *init_com, boost::shared_ptr< ProgramInterface > foo, ExecutionEngine *p, ExecutionEngine *caller)
virtual bool valid() const
virtual ActionInterface * clone() const =0
virtual void readArguments()
Based on the software pattern 'command', this interface allows execution of action objects...
base::ActionInterface * copy(std::map< const base::DataSourceBase *, base::DataSourceBase * > &alreadyCloned) const
An object that is executable and is freed after execution.
base::ActionInterface * minit
boost::shared_ptr< ProgramInterface > _foo
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
virtual bool process(base::DisposableInterface *c)
virtual bool runFunction(base::ExecutableInterface *f)
ExecutionEngine * mcaller
static Logger::LogFunction endlog()
virtual ActionInterface * copy(std::map< const DataSourceBase *, DataSourceBase * > &alreadyCloned) const