73 #include "../../rtt-detail-fwd.hpp" 74 #include "../../internal/OperationCallerC.hpp" 75 #include "../../internal/SendHandleC.hpp" 76 #include "../../Logger.hpp" 77 #include "../../internal/GlobalEngine.hpp" 78 #include "../../plugin/PluginLoader.hpp" 85 : mhandle(sh), morig(sh), mofp(ofp)
88 for (
unsigned int i = 1; i <= mofp->
collectArity(); ++i) {
92 mhandle.
arg( cargs.back() );
94 assert( mhandle.
ready() );
119 anys.length( sources.size() );
120 for(
unsigned int i = 0; i != sources.size(); ++i) {
121 const TypeInfo* ti = sources[i]->getTypeInfo();
129 ::RTT::corba::CAnyArguments_out args)
138 }
catch(std::runtime_error& e) {
139 throw ::RTT::corba::CCallError(e.what());
144 ::RTT::corba::CAnyArguments_out args)
153 }
catch(std::runtime_error& e) {
154 throw ::RTT::corba::CCallError(e.what());
173 if ( cargs.size() > 0) {
178 return new CORBA::Any();
179 }
catch(std::runtime_error& e) {
180 throw ::RTT::corba::CCallError(e.what());
188 SendHandleC shc(morig);
189 for (
unsigned int i = 0; i != mofp->
collectArity(); ++i) {
196 shc.setAutoCollect(
false);
199 throw ::RTT::corba::CNoSuchNameException(nnf.
name.c_str());
201 throw ::RTT::corba::CWrongNumbArgException(wna.
wanted, wna.
received);
210 PortableServer::POA_var mPOA = _default_POA();
211 PortableServer::ObjectId_var oid = mPOA->servant_to_id(
this);
212 mPOA->deactivate_object( oid.in() );
218 : mfact(gmf), mpoa( PortableServer::POA::_duplicate(the_poa)),
220 loadPluginOperationPart(&loadPluginOperation)
222 loadPluginOperation.
doc(
"Loads a RTT plugin.").
arg(
"plugin_path",
"The path to the shared library containing the plugin.");
227 return PortableServer::POA::_duplicate(mpoa);
241 vector<string> flist = mfact->
getNames();
242 flist.push_back(loadPluginOperationPart.
getName());
243 rlist->length( flist.size() );
245 for (
size_t i=0; i != flist.size(); ++i)
248 rlist[i - drops].name = CORBA::string_dup( flist[i].c_str() );
249 rlist[i - drops].description = CORBA::string_dup( op->
description().c_str() );
250 ::RTT::corba::CArgumentDescriptions_var arguments =
getArguments( flist[i].c_str() );
251 rlist[i - drops].arguments = arguments;
252 ::RTT::corba::CTypeList_var collect_types =
getCollectTypes( flist[i].c_str() );
253 rlist[i - drops].collect_types = collect_types;
254 rlist[i - drops].result_type = CORBA::string_dup( op->
resultType().c_str() );
255 rlist[i - drops].send_oneway = (op->
collectArity() == 0);
260 rlist->length( flist.size() - drops);
261 return rlist._retn();
265 const char * operation)
271 ret->length( args.size() );
272 for (
size_t i =0; i != args.size(); ++i) {
273 ret[i].name = CORBA::string_dup( args[i].name.c_str() );
274 ret[i].description = CORBA::string_dup( args[i].description.c_str() );
275 ret[i].type = CORBA::string_dup( args[i].type.c_str() );
281 const char * operation)
295 const char * operation)
298 return CORBA::string_dup( mofp->
resultType().c_str() );
302 const char* operation,
306 if ( nbr > mofp->
arity() )
307 throw ::RTT::corba::CWrongArgumentException( nbr, mofp->
arity() );
312 const char* operation,
317 throw ::RTT::corba::CWrongArgumentException( nbr, mofp->
collectArity() );
323 const char * operation)
326 return mofp->
arity();
330 const char * operation)
337 const char * operation)
340 return CORBA::string_dup( mofp->
description().c_str() );
344 const char * operation,
351 for (
unsigned int i = 0; i < mofp->
arity() && i < args.length(); ++i) {
361 <<
" could not create data source from Any (argument "<< i+1
362 <<
"): calling operation '"<< operation <<
"' will fail." <<endlog();
370 throw ::RTT::corba::CNoSuchNameException(operation);
372 throw ::RTT::corba::CNoSuchNameException(nnf.
name.c_str());
374 throw ::RTT::corba::CWrongNumbArgException(wna.
wanted, wna.
received);
381 const char * operation,
389 vector<DataSourceBase::shared_ptr> results;
390 for (
size_t i =0; i != args.length(); ++i) {
395 orig.
arg( results[i] );
397 if ( orig.
ready() ) {
402 const TypeInfo* ti = ds->getTypeInfo();
405 log(
Warning) <<
"Could not return results of call to " << operation <<
": unknown return type by CORBA transport."<<endlog();
407 retany =
new CORBA::Any();
413 for (
size_t i =0; i != args.length(); ++i) {
423 throw ::RTT::corba::CNoSuchNameException( operation );
425 throw ::RTT::corba::CNoSuchNameException( operation );
427 throw ::RTT::corba::CWrongNumbArgException( wna.
wanted, wna.
received );
430 }
catch (std::runtime_error& e){
431 throw ::RTT::corba::CCallError(e.what());
433 return new ::CORBA::Any();
437 const char * operation,
446 for (
size_t i =0; i != args.length(); ++i) {
451 if ( orig.
ready() ) {
461 throw ::RTT::corba::CNoSuchNameException( operation );
463 throw ::RTT::corba::CNoSuchNameException( operation );
465 throw ::RTT::corba::CWrongNumbArgException( wna.
wanted, wna.
received );
473 const char * operation,
479 CSendHandle_var ret = ret_i->_this();
480 ret_i->_remove_ref();
483 return CSendHandle::_nil();
488 const char * operation,
494 ret_i = sendOperationInternal(operation, args);
497 log(
Error) <<
"Sending the '" << operation <<
"'' operation failed (SendFailure)." << endlog();
499 }
catch(std::exception &e) {
500 log(
Error) <<
"Sending the '" << operation <<
"'' operation failed:" << e.what() << endlog();
503 if (ret_i) ret_i->_remove_ref();
508 string operation_str(operation);
510 if ( !mofp && (operation_str ==
"loadPlugin") )
511 mofp = &loadPluginOperationPart;
513 throw ::RTT::corba::CNoSuchNameException( operation );
517 bool RTT_corba_COperationInterface_i::loadPlugin(
const string &pluginPath) {
virtual ::RTT::corba::CSendStatus collect(::RTT::corba::CAnyArguments_out args)
virtual ::RTT::corba::CSendStatus collectIfDone(::RTT::corba::CAnyArguments_out args)
Operation< Signature > & doc(const std::string &description)
Document this operation.
virtual char * getDescription(const char *operation)
virtual char * getResultType(const char *operation)
virtual const types::TypeInfo * getArgumentType(unsigned int arg) const =0
Returns the type information of the n'th argument, with argument zero being the return value...
bool ready() const
Returns true if this method is ready for execution.
const std::string & getTypeName() const
Return the type name which was first registered.
virtual char * getArgumentType(const char *, CORBA::UShort)
void check()
Checks if this method is ready for calling, will throw if not so.
sequence< any > CAnyArguments
virtual ~RTT_corba_CSendHandle_i(void)
SendHandleC send()
Send the contained method.
virtual ::RTT::corba::CSendStatus checkStatus(void)
Exception thrown when a factory is requested to create an object with an unknown name.
virtual CORBA::Any_ptr createAny(base::DataSourceBase::shared_ptr source) const =0
Evaluate source and create an any which contains the value of source.
virtual const types::TypeInfo * getCollectType(unsigned int arg) const =0
Returns the type information of the n'th collectable argument.
void setAutoCollect(bool on_off)
When set to 'on', the destruction of this SendHandleC will cause a call to collect() before all data ...
SendHandleC & arg(base::DataSourceBase::shared_ptr a)
Add a datasource argument to the SendHandle.
virtual ::CORBA::Any * callOperation(const char *operation,::RTT::corba::CAnyArguments &args)
SendStatus collect()
Collect the contained method.
virtual std::string description() const =0
Returns the description of this operation.
bool isSynchronous(const std::string &name) const
Query if a given operation is limited to sychronous invocation (own component thread) only...
virtual char * getCollectType(const char *, CORBA::UShort)
sequence< COperation > COperationDescriptions
virtual ::CORBA::Any * ret(void)
SendStatus
Returns the status of a send() or collect() invocation.
virtual ::CORBA::UShort getCollectArity(const char *operation)
virtual ::CORBA::UShort getArity(const char *operation)
virtual unsigned int arity() const =0
Returns the arity (number of arguments) of this operation.
virtual RTT::corba::COperationInterface::COperationDescriptions * getOperations(void)
OperationInterfacePart * getPart(const std::string &name)
Get a previously added part of this factory.
base::DataSourceBase::shared_ptr getCallDataSource()
Get the contained data source for 'call'.
std::vector< ArgumentDescription > Descriptions
The descriptions of an argumentlist.
Convenient short notation for every sub-namespace of RTT.
A template-less SendHandle manager.
virtual void sendOperationOneway(const char *operation, const ::RTT::corba::CAnyArguments &args)
bool anysequence_to_sourcevector(CAnyArguments const &anys, vector< DataSourceBase::shared_ptr > &sources)
Helper function to convert a sequence of anys to a vector of data sources.
A template-less manager for OperationCaller calls.
SendStatus collectIfDone()
Collect the contained method.
A class for representing a user type, and which can build instances of that type. ...
virtual void checkOperation(const char *operation, const ::RTT::corba::CAnyArguments &args)
bool ready() const
Returns true if this handle is ready for execution.
This class defines the interface for creating operation objects without using C++ templates...
Operation< Signature > & arg(const std::string &name, const std::string &description)
Document an argument of this operation.
virtual std::string resultType() const =0
Return the result (return) type of this operation.
Returned when the send() succeeded, but the operation has not yet been executed by the receiving comp...
PortableServer::POA_ptr _default_POA()
virtual std::string getName() const
Returns the name of this operation.
virtual std::vector< ArgumentDescription > getArgumentList() const =0
Get a description of the desired arguments in the ArgumentDescription format.
TypeTransporter * getProtocol(int protocol_id) const
Returns this type's transport for a given protocol.
std::vector< std::string > getNames() const
Get a list of all the names of the added operations.
RTT_corba_COperationInterface_i(RTT::OperationInterface *mfact, PortableServer::POA_ptr the_poa)
virtual unsigned int collectArity() const =0
Returns the number of collectable arguments of this operation's function.
#define ORO_CORBA_PROTOCOL_ID
virtual base::DataSourceBase::shared_ptr createDataSource(const CORBA::Any *any) const =0
Create a Data Source from an any.
base::DataSourceBase::shared_ptr buildValue() const
Build a internal::ValueDataSource of this type.
virtual ::RTT::corba::CTypeList * getCollectTypes(const char *operation)
bool sourcevector_to_anysequence(vector< DataSourceBase::shared_ptr > const &sources, CAnyArguments &anys)
Helper function to convert a vector of data sources to a sequence of anys.
Exception thrown when a factory is requested to create an object, but a wrong argument type was given...
static boost::shared_ptr< PluginLoader > Instance()
Create the instance of the PluginLoader.
OperationCallerC & arg(base::DataSourceBase::shared_ptr a)
Add a datasource argument to the OperationCaller.
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.
virtual ~RTT_corba_COperationInterface_i(void)
virtual ::RTT::corba::CArgumentDescriptions * getArguments(const char *operation)
virtual void checkArguments(const ::RTT::corba::CAnyArguments &args)
RTT_corba_CSendHandle_i(RTT::internal::SendHandleC const &sh, RTT::OperationInterfacePart *ofp)
sequence< string > CTypeList
Holds all exported operations of a component and is able to produce callers for these operations...
virtual ::RTT::corba::CSendHandle_ptr sendOperation(const char *operation, const ::RTT::corba::CAnyArguments &args)
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.
Exception thrown when a factory is requested to produce an asynchronous object while it is not availa...
Extends the TypeTransporter in order to allow the creation of channel elements or output halves for a...