41 #include "../ExecutionEngine.hpp" 42 #include "../internal/GlobalEngine.hpp" 51 #include "../internal/mystd.hpp" 54 #include "../Attribute.hpp" 56 #include "../internal/DataSourceCommand.hpp" 57 #include "../FactoryExceptions.hpp" 58 #include "../../Handle.hpp" 62 using namespace detail;
66 : func(pi), proc(procs) {}
69 return func->getResult() ? func->getResult()->getDataSource()->getTypeName() :
"void";
73 return func->getName();
77 return "Orocos Program Script Function.";
82 std::vector<AttributeBase*> origlist = func->getArguments();
83 std::vector< ArgumentDescription > mlist;
84 for ( std::vector<AttributeBase*>::const_iterator it = origlist.begin();
85 it != origlist.end(); ++it)
86 mlist.push_back(
ArgumentDescription(
"arg",
"Function Argument", (*it)->getDataSource()->getType() ) );
92 return func->getArguments().size();
97 return func->getResult() ? 1 : 0;
103 if ( func->getResult() )
104 return func->getResult()->getDataSource()->getTypeInfo();
108 std::vector<AttributeBase*> origlist = func->getArguments();
109 if ( arg > origlist.size() )
111 return origlist[arg - 1]->getDataSource()->getTypeInfo();
116 return func->getResult()->getDataSource()->getTypeInfo();
121 const std::vector<DataSourceBase::shared_ptr>& args
126 boost::shared_ptr<ProgramInterface> orig = func;
127 std::vector<AttributeBase*> origlist = orig->getArguments();
128 if ( args.size() != origlist.size() )
133 std::map<const DataSourceBase*, DataSourceBase*> replacementdss;
135 boost::shared_ptr<ProgramInterface> fcopy( orig->copy( replacementdss ) );
141 origlist = fcopy->getArguments();
142 std::vector<DataSourceBase::shared_ptr>::const_iterator dit = args.begin();
143 std::vector<AttributeBase*>::const_iterator tit = origlist.begin();
146 for (; dit != args.end(); ++dit, ++tit)
147 icom->
add( (*tit)->getDataSource()->updateAction( dit->get() ) );
151 int parnb = (dit - args.begin()) + 1;
155 for (; dit != args.end(); ++dit, ++tit) {
156 ActionInterface* ret = (*tit)->getDataSource()->updateAction( dit->get() );
191 if (args.size() != 2) {
192 log(
Error) <<
"Invalid number of arguments. Script functions can only collect the return value." <<endlog();
197 #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.
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.
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 DataSourceBase::shared_ptr getDataSource() const =0
Return a internal::DataSource which contains the same contents.
boost::shared_ptr< ProgramInterface > ProgramInterfacePtr
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...
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.
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.
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.
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.
virtual void add(base::ActionInterface *com)
add a command to the vect
Exception thrown when a factory is requested to create an object, but a wrong argument type was given...
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.
An action which calls a FunctionFraph for execution in a ExecutionEngine.
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)