41 #include "../ExecutionEngine.hpp" 42 #include "../internal/GlobalEngine.hpp" 52 #include "../internal/mystd.hpp" 55 #include "../Attribute.hpp" 57 #include "../internal/DataSourceCommand.hpp" 58 #include "../FactoryExceptions.hpp" 59 #include "../../Handle.hpp" 63 using namespace detail;
70 typedef boost::intrusive_ptr<CmdFunctionWrapper>
shared_ptr;
89 return alias->
value();
109 : func(pi), proc(procs) {}
112 return func->getResult() ? func->getResult()->getDataSource()->getTypeName() :
"void";
116 return func->getName();
120 return "Orocos Program Script Function.";
125 std::vector<AttributeBase*> origlist = func->getArguments();
126 std::vector< ArgumentDescription > mlist;
127 for ( std::vector<AttributeBase*>::const_iterator it = origlist.begin();
128 it != origlist.end(); ++it)
129 mlist.push_back(
ArgumentDescription(
"arg",
"Function Argument", (*it)->getDataSource()->getType() ) );
135 return func->getArguments().size();
140 return func->getResult() ? 1 : 0;
146 if ( func->getResult() )
147 return func->getResult()->getDataSource()->getTypeInfo();
151 std::vector<AttributeBase*> origlist = func->getArguments();
152 if ( arg > origlist.size() )
154 return origlist[arg - 1]->getDataSource()->getTypeInfo();
159 return func->getResult()->getDataSource()->getTypeInfo();
164 const std::vector<DataSourceBase::shared_ptr>& args
168 return produceHelper(args, caller, issend);
172 const std::vector<DataSourceBase::shared_ptr>& args
176 boost::shared_ptr<ProgramInterface> orig = func;
177 std::vector<AttributeBase*> origlist = orig->getArguments();
178 if ( args.size() != origlist.size() )
183 std::map<const DataSourceBase*, DataSourceBase*> replacementdss;
185 boost::shared_ptr<ProgramInterface> fcopy( orig->copy( replacementdss ) );
191 origlist = fcopy->getArguments();
192 std::vector<DataSourceBase::shared_ptr>::const_iterator dit = args.begin();
193 std::vector<AttributeBase*>::const_iterator tit = origlist.begin();
196 for (; dit != args.end(); ++dit, ++tit)
197 icom->
add( (*tit)->getDataSource()->updateAction( dit->get() ) );
201 int parnb = (dit - args.begin()) + 1;
205 for (; dit != args.end(); ++dit, ++tit) {
206 ActionInterface* ret = (*tit)->getDataSource()->updateAction( dit->get() );
221 if (issend ==
false) {
230 return new CmdFunction( icom, fcopy, proc, caller );
239 return produceHelper(args, caller,
true);
243 if (blocking->
get() == true )
246 if (args.size() >= 1) {
247 if ( dynamic_cast<CmdFunction* > (args[0].
get()) != 0 ) {
251 }
else if ( dynamic_cast<CmdFunctionWrapper* > (args[0].
get()) != 0 ) {
255 log(
Error) <<
"FunctionFactory: Please define your SendHandle with 'var SendHandle' for script functions." <<endlog();
260 log(
Error) <<
"FunctionFactory: Must provide an argument in produceCollect." <<endlog();
263 #ifdef ORO_SIGNALLING_OPERATIONS DataSource is a base class representing a generic way to read data of type T.
std::string resultType() const
Return the result (return) type of this operation.
const types::TypeInfo * getCollectType(unsigned int arg) const
Returns the type information of the n'th collectable argument.
virtual result_t get() const =0
Return the data as type T.
std::string getName() const
Returns the name of this operation.
unsigned int collectArity() const
Returns the number of collectable arguments of this operation's function.
virtual CmdFunctionWrapper * copy(std::map< const base::DataSourceBase *, base::DataSourceBase * > &alreadyCloned) const
Create a deep copy of this internal::DataSource, unless it is already cloned.
base::DataSourceBase::shared_ptr produceCollect(const std::vector< base::DataSourceBase::shared_ptr > &args, internal::DataSource< bool >::shared_ptr blocking) const
Create a DataSource for collecting the results of a Send.
virtual CmdFunctionWrapper * clone() const
Return a shallow clone of this DataSource.
virtual DataSourceBase::shared_ptr getDataSource() const =0
Return a internal::DataSource which contains the same contents.
boost::shared_ptr< ProgramInterface > ProgramInterfacePtr
DataSource< SendStatus >::result_t value() const
Return the result of the last evaluate() function.
This exception is thrown if the target and source type of an assignment of a DataSource with a base::...
An execution engine serialises (executes one after the other) the execution of all commands...
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.
const types::TypeInfo * getArgumentType(unsigned int arg) const
Returns the type information of the n'th argument, with argument zero being the return value...
An attribute is a minimalistic, named placeholder for data.
virtual void reset()
Reset the data to initial values.
static const types::TypeInfo * getTypeInfo()
Return the typeinfo object.
static RTT_API ExecutionEngine * Instance()
This is an overloaded member function, provided for convenience. It differs from the above function o...
Description of one Argument of a Command.
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...
base::DataSourceBase::shared_ptr produce(const std::vector< base::DataSourceBase::shared_ptr > &args, ExecutionEngine *caller) const
Create a DataSource for a given callable operation.
std::string description() const
Returns the description of this operation.
A class for representing a user type, and which can build instances of that type. ...
std::vector< ArgumentDescription > getArgumentList() const
Get a description of the desired arguments in the ArgumentDescription format.
boost::intrusive_ptr< CmdFunctionWrapper > shared_ptr
unsigned int arity() const
Returns the arity (number of arguments) of this operation.
base::DataSourceBase::shared_ptr produceSend(const std::vector< base::DataSourceBase::shared_ptr > &args, ExecutionEngine *caller) const
Create a DataSource for a given send operation.
base::DataSourceBase::shared_ptr produceHandle() const
Create an empty SendHandle object for this operation.
A class that wraps a Command in a internal::DataSource<bool> interface.
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.
virtual void add(base::ActionInterface *com)
add a command to the vect
bool evaluate() const
Force an evaluation of the DataSourceBase.
Exception thrown when a factory is requested to create an object, but a wrong argument type was given...
virtual result_t value() const =0
Return the result of the last evaluate() function.
Exception thrown when a factory is requested to create an object but the wrong number of arguments wa...
boost::intrusive_ptr< DataSourceBase > shared_ptr
Use this type to store a pointer to a DataSourceBase.
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
DataSource< SendStatus >::const_reference_t rvalue() const
Get a const reference to the value of this DataSource.
CmdFunctionWrapper(DataSource< SendStatus > *ds)
An action which calls a FunctionFraph for execution in a ExecutionEngine.
virtual bool evaluate() const
Force an evaluation of the DataSourceBase.
A simple, yet very useful DataSource, which keeps a value, and returns it in its get() method...
The Handle holds the information, and allows manipulation, of a connection between a internal::Signal...
Based on the software pattern 'composite', this class RTT_SCRIPTING_API allows composing command obje...
Exception thrown when a factory is requested to produce an asynchronous object while it is not availa...
FunctionFactory(ProgramInterfacePtr func, ExecutionEngine *procs)