43 #include "../../types/Types.hpp" 44 #include "../../internal/DataSources.hpp" 45 #include "../../internal/DataSourceCommand.hpp" 46 #include "../../SendStatus.hpp" 47 #include "../../Handle.hpp" 53 CorbaOperationCallerFactory::CorbaOperationCallerFactory(
const std::string &method_name, corba::CService_ptr fact, PortableServer::POA_ptr the_poa )
55 mfact(corba::
CService::_duplicate(fact) ),
56 mpoa(PortableServer::POA::_duplicate(the_poa)),
62 mfact(corba::
CService::_duplicate(fact) ),
63 mpoa(PortableServer::POA::_duplicate(the_poa)),
64 method(operation.name.in()),
72 return mdescription->arguments.length();
74 return mfact->getArity( method.c_str() );
79 return mdescription->collect_types.length();
81 return mfact->getCollectArity( method.c_str() );
89 tname = mdescription->result_type.in();
90 }
else if (i <= mdescription->arguments.length()) {
91 tname = mdescription->arguments[i-1].type.in();
99 std::string::size_type separator = tname.find(
' ');
100 if ( separator != std::string::npos ) {
101 tname = tname.substr(0, separator);
106 tname = mfact->getArgumentType( method.c_str(), i);
111 log(
Error) <<
"CorbaOperationCallerFactory::getArgumentType: Wrong arg nbr: " << wae.
which_arg <<
" max is " << wae.
max_arg <<endlog();
115 if (tname.empty())
return 0;
117 if (
Types()->type( tname ) != 0 )
118 return Types()->type( tname );
121 log(
Warning) <<
"CorbaOperationCallerFactory: remote operation's "<< method <<
" return type " << tname <<
" is unknown in this process." << endlog();
123 log(
Warning) <<
"CorbaOperationCallerFactory: remote operation's "<< method <<
" argument "<< i <<
" of type " << tname <<
" is unknown in this process." << endlog();
130 if (mdescription && i < mdescription->collect_types.length()) {
131 return Types()->type( mdescription->collect_types[i].in() );
136 CORBA::String_var tname = mfact->getCollectType( method.c_str(), i);
137 return Types()->type( tname.in() );
149 return mdescription->result_type.in();
152 CORBA::String_var result = mfact->getResultType( method.c_str() );
153 return std::string( result.in() );
157 return std::string();
166 return mdescription->description.in();
169 CORBA::String_var result = mfact->getDescription( method.c_str() );
170 return std::string( result.in() );
174 return std::string();
178 corba::CArgumentDescriptions_var result;
182 result_ptr = &(mdescription->arguments);
185 result = mfact->getArguments( method.c_str() );
186 result_ptr = &(result.in());
193 ret.reserve( result_ptr->length() );
194 for (
size_t i=0; i!= result_ptr->length(); ++i)
196 std::string( (*result_ptr)[i].description.in() ),
197 std::string( (*result_ptr)[i].type.in() ) ));
213 std::vector<base::DataSourceBase::shared_ptr> margs;
216 corba::CAnyArguments_var nargs;
218 CorbaTypeTransporter* mctt;
224 std::vector<base::DataSourceBase::shared_ptr>
const& args,
226 CorbaTypeTransporter* ctt,
228 : mfact(
CService::_duplicate(fact)), mop(op), margs(args), mcaller(caller), mresult(result), mctt(ctt), mdocall(docall), moneway(oneway)
236 nargs->length( margs.size() );
237 for (
size_t i=0; i < margs.size(); ++i ) {
241 ctt->updateAny(margs[i], nargs[i]);
248 CORBA::Any_var any = mfact->callOperation( mop.c_str(), nargs.inout() );
249 for (
size_t i=0; i < margs.size(); ++i ) {
253 ctt->updateFromAny( &nargs[i], margs[i] );
257 return mctt->updateFromAny(&any.in(), mresult);
260 CSendHandle_var sh = mfact->sendOperation( mop.c_str(), nargs.in() );
266 mfact->sendOperationOneway( mop.c_str(), nargs.in() );
278 throw std::runtime_error(std::string(e.
what.in()));
282 ActionInterface*
clone()
const {
return new CorbaOperationCallerCall(CService::_duplicate( mfact.in() ), mop, margs, mcaller, mctt, mresult, mdocall, moneway); }
284 virtual ActionInterface*
copy( std::map<const DataSourceBase*, DataSourceBase*>& alreadyCloned )
const {
285 vector<DataSourceBase::shared_ptr> argcopy( margs.size() );
287 for (vector<DataSourceBase::shared_ptr>::iterator it = argcopy.begin(); it != argcopy.end(); ++it, ++v)
288 argcopy[v] = (*it)->copy(alreadyCloned);
290 return new CorbaOperationCallerCall(CService::_duplicate( mfact.in() ), mop, argcopy, mcaller, mctt, result, mdocall, moneway);
295 #ifndef RTT_CORBA_NO_CHECK_OPERATIONS 297 nargs->length( args.size() );
301 for (
size_t i=0; i < args.size(); ++i ) {
313 #ifndef RTT_CORBA_NO_CHECK_OPERATIONS 315 mfact->checkOperation(method.c_str(), nargs.in() );
320 if ( ti !=
Types()->type(
"void") ) {
347 #ifndef RTT_CORBA_NO_CHECK_OPERATIONS 349 nargs->length( args.size() );
350 for (
size_t i=0; i < args.size(); ++i ) {
361 #ifndef RTT_CORBA_NO_CHECK_OPERATIONS 363 mfact->checkOperation(method.c_str(), nargs.inout() );
367 #ifdef RTT_CORBA_SEND_ONEWAY_OPERATIONS 368 bool oneway = (mdescription && mdescription->send_oneway);
399 std::vector<base::DataSourceBase::shared_ptr> margs;
404 std::vector<base::DataSourceBase::shared_ptr>
const& args,
424 corba::CAnyArguments_var nargs;
425 if ( misblocking->get() ) {
426 mss =
SendStatus( static_cast<int>(msh->collect( nargs.out() ) ) - 2 );
428 mss =
SendStatus( static_cast<int>(msh->collectIfDone( nargs.out() ) ) - 2 );
432 assert( nargs->length() == margs.size() );
433 for (
size_t i=0; i < margs.size(); ++i ) {
447 throw std::runtime_error(std::string(e.
what.in()));
453 virtual DataSource<SendStatus>*
copy( std::map<const DataSourceBase*, DataSourceBase*>& alreadyCloned )
const {
454 vector<DataSourceBase::shared_ptr> argcopy( margs.size() );
456 for (vector<DataSourceBase::shared_ptr>::iterator it = argcopy.begin(); it != argcopy.end(); ++it, ++v)
457 argcopy[v] = (*it)->
copy(alreadyCloned);
464 unsigned int expected = 0;
466 expected = mdescription->collect_types.length();
468 expected = mfact->getCollectArity(method.c_str());
470 if (args.size() != expected + 1) {
474 std::vector<base::DataSourceBase::shared_ptr> cargs( ++args.begin(), args.end() );
483 nargs->length( cargs.size() );
484 for (
size_t i=0; i < cargs.size(); ++i ) {
491 ds->get()->checkArguments( nargs.in() );
501 #ifdef ORO_SIGNALLING_OPERATIONS 503 log(
Error) <<
"Can not attach Signal to remote Corba Operation '"<<method <<
"'" <<endlog();
DataSource is a base class representing a generic way to read data of type T.
SendStatus const & rvalue() const
Get a const reference to the value of this DataSource.
Is thrown when an operation does not exist.
Is thrown when a wrong type of arguments is provided.
virtual const types::TypeInfo * getCollectType(unsigned int i) const
Returns the type information of the n'th collectable argument.
virtual base::DataSourceBase::shared_ptr produceHandle() const
Create an empty SendHandle object for this operation.
virtual unsigned int collectArity() const
Returns the number of collectable arguments of this operation's function.
Is thrown when a wrong argument number is queried.
const std::string & getTypeName() const
Return the type name which was first registered.
sequence< any > CAnyArguments
virtual void set(param_t t)=0
Set this DataSource with a value.
Exception thrown when a factory is requested to create an object with an unknown name.
virtual std::string getName() const
Returns the name of this operation.
virtual unsigned int arity() const
Returns the arity (number of arguments) of this operation.
CorbaOperationCallerCall(CService_ptr fact, std::string op, std::vector< base::DataSourceBase::shared_ptr > const &args, ExecutionEngine *caller, CorbaTypeTransporter *ctt, base::DataSourceBase::shared_ptr result, bool docall, bool oneway)
virtual ActionInterface * copy(std::map< const DataSourceBase *, DataSourceBase * > &alreadyCloned) const
virtual 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.
base::DataSourceBase::shared_ptr buildActionAlias(base::ActionInterface *action, base::DataSourceBase::shared_ptr source) const
Returns a DataSource that first executes an action and returns the result of another data source...
An Orocos Service which hosts operations, attributes and properties.
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.
virtual std::string description() const
Returns the description of this operation.
virtual std::vector< ArgumentDescription > getArgumentList() const
Get a description of the desired arguments in the ArgumentDescription format.
DataSource< SendStatus > * clone() const
Return a shallow clone of this DataSource.
virtual ~CorbaOperationCallerFactory()
Convenient short notation for every sub-namespace of RTT.
SendStatus value() const
Return the result of the last evaluate() function.
CorbaOperationCallerCollect(CSendHandle_ptr sh, std::vector< base::DataSourceBase::shared_ptr > const &args, DataSource< bool >::shared_ptr isblocking)
CorbaOperationCallerFactory(const std::string &method_name, corba::CService_ptr fact, PortableServer::POA_ptr the_poa)
A DataSource which is used to execute an action and then return the value of another DataSource...
Description of one Argument of a Command.
Returned when the result of the send() could not be collected.
A handler object that allows us to collect the results of a send.
Based on the software pattern 'command', this interface allows execution of action objects...
A class for representing a user type, and which can build instances of that type. ...
This class defines the interface for creating operation objects without using C++ templates...
TypeInfoRepository::shared_ptr Types()
Obtain a pointer to the global type system.
ActionInterface * clone() const
virtual std::string resultType() const
Return the result (return) type of this operation.
virtual base::DataSourceBase::shared_ptr produceSend(const std::vector< base::DataSourceBase::shared_ptr > &args, ExecutionEngine *caller) const
Create a DataSource for a given send operation.
boost::intrusive_ptr< DataSource< T > > shared_ptr
boost::intrusive_ptr< AssignableDataSource< T > > shared_ptr
Use this type to store a pointer to an AssignableDataSource.
Returned when the send() succeeded, but the operation has not yet been executed by the receiving comp...
A internal::DataSource which holds an any value and returns it in its get() method.
Is thrown when a wrong number of arguments is provided.
static AssignableDataSource< T > * narrow(base::DataSourceBase *db)
This method narrows a base::DataSourceBase to a typeded AssignableDataSource, possibly returning a ne...
TypeTransporter * getProtocol(int protocol_id) const
Returns this type's transport for a given protocol.
A class that wraps a Command in a internal::DataSource<bool> interface.
std::vector< ArgumentDescription > CArgumentDescriptions
#define ORO_CORBA_PROTOCOL_ID
base::DataSourceBase::shared_ptr buildValue() const
Build a internal::ValueDataSource of this type.
static DataSource< T > * narrow(base::DataSourceBase *db)
This method narrows a base::DataSourceBase to a typeded DataSource, possibly returning a new object...
Exception thrown when a factory is requested to create an object, but a wrong argument type was given...
virtual bool updateFromAny(const CORBA::Any *blob, base::DataSourceBase::shared_ptr target) const =0
Update an assignable datasource target with the contents of blob.
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.
sequence< CArgumentDescription > CArgumentDescriptions
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
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...
~CorbaOperationCallerCollect()
virtual DataSource< SendStatus > * copy(std::map< const DataSourceBase *, DataSourceBase * > &alreadyCloned) const
virtual bool updateAny(base::DataSourceBase::shared_ptr source, CORBA::Any &any) const =0
Evaluate source and update an any which contains the value of source.
virtual const types::TypeInfo * getArgumentType(unsigned int i) const
Returns the type information of the n'th argument, with argument zero being the return value...
Extends the TypeTransporter in order to allow the creation of channel elements or output halves for a...
virtual base::DataSourceBase::shared_ptr produce(const std::vector< base::DataSourceBase::shared_ptr > &args, ExecutionEngine *caller) const
Create a DataSource for a given callable operation.