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
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) {
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
std::string resultType() const
const types::TypeInfo * getCollectType(unsigned int arg) const
virtual result_t get() const =0
std::string getName() const
unsigned int collectArity() const
virtual CmdFunctionWrapper * copy(std::map< const base::DataSourceBase *, base::DataSourceBase * > &alreadyCloned) const
base::DataSourceBase::shared_ptr produceCollect(const std::vector< base::DataSourceBase::shared_ptr > &args, internal::DataSource< bool >::shared_ptr blocking) const
base::DataSourceBase::shared_ptr produceHelper(const std::vector< base::DataSourceBase::shared_ptr > &args, ExecutionEngine *caller, bool issend) const
virtual CmdFunctionWrapper * clone() const
virtual DataSourceBase::shared_ptr getDataSource() const =0
boost::shared_ptr< ProgramInterface > ProgramInterfacePtr
DataSource< SendStatus >::result_t value() const
virtual DataSource< T > * copy(std::map< const base::DataSourceBase *, base::DataSourceBase * > &alreadyCloned) const =0
const types::TypeInfo * getArgumentType(unsigned int arg) const
static RTT_API ExecutionEngine * Instance()
Description of one Argument of a Command.
virtual const_reference_t rvalue() const =0
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
std::string description() const
std::vector< ArgumentDescription > getArgumentList() const
boost::intrusive_ptr< CmdFunctionWrapper > shared_ptr
DataSource< SendStatus >::shared_ptr alias
unsigned int arity() const
static const types::TypeInfo * getTypeInfo()
base::DataSourceBase::shared_ptr produceSend(const std::vector< base::DataSourceBase::shared_ptr > &args, ExecutionEngine *caller) const
base::DataSourceBase::shared_ptr produceHandle() const
virtual void add(base::ActionInterface *com)
virtual result_t value() const =0
boost::intrusive_ptr< DataSourceBase > shared_ptr
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
DataSource< SendStatus >::const_reference_t rvalue() const
CmdFunctionWrapper(DataSource< SendStatus > *ds)
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...
static Logger::LogFunction endlog()
FunctionFactory(ProgramInterfacePtr func, ExecutionEngine *procs)
virtual bool evaluate() const