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()),
90 }
else if (i <= mdescription->arguments.length()) {
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);
107 }
catch ( CNoSuchNameException& ) {
110 catch ( CWrongArgumentException& wae){
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()) {
136 CORBA::String_var tname =
mfact->getCollectType(
method.c_str(), i);
137 return Types()->type( tname.in() );
152 CORBA::String_var result =
mfact->getResultType(
method.c_str() );
153 return std::string( result.in() );
154 }
catch ( corba::CNoSuchNameException& nsn ) {
157 return std::string();
169 CORBA::String_var result =
mfact->getDescription(
method.c_str() );
170 return std::string( result.in() );
171 }
catch ( corba::CNoSuchNameException& nsn ) {
174 return std::string();
178 corba::CArgumentDescriptions_var result;
179 const corba::CArgumentDescriptions *result_ptr = 0;
186 result_ptr = &(result.in());
187 }
catch ( corba::CNoSuchNameException& nsn ) {
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;
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)
235 nargs =
new corba::CAnyArguments();
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() );
271 }
catch ( corba::CNoSuchNameException& ) {
273 }
catch ( corba::CWrongNumbArgException& ) {
275 }
catch ( corba::CWrongTypeArgException& ) {
277 }
catch ( corba::CCallError& e) {
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 296 corba::CAnyArguments_var nargs =
new corba::CAnyArguments();
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") ) {
336 }
catch ( corba::CNoSuchNameException& nsn ) {
338 }
catch ( corba::CWrongNumbArgException& wa ) {
340 }
catch ( corba::CWrongTypeArgException& wta ) {
347 #ifndef RTT_CORBA_NO_CHECK_OPERATIONS 348 corba::CAnyArguments_var nargs =
new corba::CAnyArguments();
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 373 }
catch ( corba::CNoSuchNameException& nsn ) {
375 }
catch ( corba::CWrongNumbArgException& wa ) {
377 }
catch ( corba::CWrongTypeArgException& wta ) {
399 std::vector<base::DataSourceBase::shared_ptr>
margs;
404 std::vector<base::DataSourceBase::shared_ptr>
const& args,
406 : msh( CSendHandle::_duplicate(sh)), margs(args), misblocking(isblocking), mss(
SendFailure)
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 ) {
442 }
catch ( corba::CWrongNumbArgException& ) {
444 }
catch ( corba::CWrongTypeArgException& ) {
446 }
catch ( corba::CCallError& e) {
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;
470 if (args.size() != expected + 1) {
474 std::vector<base::DataSourceBase::shared_ptr> cargs( ++args.begin(), args.end() );
482 corba::CAnyArguments_var nargs =
new corba::CAnyArguments();
483 nargs->length( cargs.size() );
484 for (
size_t i=0; i < cargs.size(); ++i ) {
491 ds->get()->checkArguments( nargs.in() );
492 }
catch ( CWrongNumbArgException& wna) {
494 }
catch ( CWrongTypeArgException& wta) {
501 #ifdef ORO_SIGNALLING_OPERATIONS
SendStatus const & rvalue() const
virtual const types::TypeInfo * getCollectType(unsigned int i) const
virtual base::DataSourceBase::shared_ptr produceHandle() const
virtual unsigned int collectArity() const
const std::string & getTypeName() const
PortableServer::POA_var mpoa
std::vector< base::DataSourceBase::shared_ptr > margs
virtual void set(param_t t)=0
virtual std::string getName() const
corba::CService_var mfact
virtual unsigned int arity() const
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
base::DataSourceBase::shared_ptr buildActionAlias(base::ActionInterface *action, base::DataSourceBase::shared_ptr source) const
virtual DataSource< T > * copy(std::map< const base::DataSourceBase *, base::DataSourceBase * > &alreadyCloned) const =0
virtual std::string description() const
virtual std::vector< ArgumentDescription > getArgumentList() const
corba::CAnyArguments_var nargs
DataSource< SendStatus > * clone() const
virtual ~CorbaOperationCallerFactory()
base::DataSourceBase::shared_ptr mresult
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)
Description of one Argument of a Command.
Based on the software pattern 'command', this interface allows execution of action objects...
static AssignableDataSource< T > * narrow(base::DataSourceBase *db)
TypeInfoRepository::shared_ptr Types()
DataSource< bool >::shared_ptr misblocking
ActionInterface * clone() const
virtual std::string resultType() const
virtual base::DataSourceBase::shared_ptr produceSend(const std::vector< base::DataSourceBase::shared_ptr > &args, ExecutionEngine *caller) const
boost::intrusive_ptr< DataSource< T > > shared_ptr
boost::intrusive_ptr< AssignableDataSource< T > > shared_ptr
CorbaTypeTransporter * mctt
std::vector< base::DataSourceBase::shared_ptr > margs
static DataSource< T > * narrow(base::DataSourceBase *db)
TypeTransporter * getProtocol(int protocol_id) const
std::vector< ArgumentDescription > CArgumentDescriptions
#define ORO_CORBA_PROTOCOL_ID
base::DataSourceBase::shared_ptr buildValue() const
boost::shared_ptr< COperation const > mdescription
virtual bool updateFromAny(const CORBA::Any *blob, base::DataSourceBase::shared_ptr target) const =0
boost::intrusive_ptr< DataSourceBase > shared_ptr
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
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
static Logger::LogFunction endlog()
ExecutionEngine * mcaller
virtual const types::TypeInfo * getArgumentType(unsigned int i) const
virtual base::DataSourceBase::shared_ptr produce(const std::vector< base::DataSourceBase::shared_ptr > &args, ExecutionEngine *caller) const