43 std::vector<base::DataSourceBase::shared_ptr> args;
46 BOOST_CHECK_EQUAL( -1.0, dsd->
get());
49 dsb = tc->provides(
"methods")->produce(
"m1", args, caller->engine());
51 BOOST_CHECK_EQUAL( -2.0, dsd->
get());
54 dsb = tc->provides(
"methods")->produce(
"m2", args, caller->engine());
56 BOOST_CHECK_EQUAL( -3.0, dsd->
get());
59 dsb = tc->provides(
"methods")->produce(
"m3", args, caller->engine());
61 BOOST_CHECK_EQUAL( -4.0, dsd->
get());
63 args =
GenerateDataSource().operator()<int,double,bool,std::string>(1,2.0,
true,
"hello");
64 dsb = tc->provides(
"methods")->produce(
"m4", args, caller->engine());
66 BOOST_CHECK_EQUAL( -5.0, dsd->
get());
68 args =
GenerateDataSource().operator()<int,double,bool,std::string,
float>(1,2.0,
true,
"hello", 5.0f);
69 dsb = tc->provides(
"methods")->produce(
"m5", args, caller->engine());
71 BOOST_CHECK_EQUAL( -6.0, dsd->
get());
73 args =
GenerateDataSource().operator()<int,double,bool,std::string,
float>(1,2.0,
true,
"hello", 5.0f,
'a');
74 dsb = tc->provides(
"methods")->produce(
"m6", args, caller->engine());
76 BOOST_CHECK_EQUAL( -7.0, dsd->
get());
78 args =
GenerateDataSource().operator()<int,double,bool,std::string,
float>(1,2.0,
true,
"hello", 5.0f,
'a', (
unsigned int)7);
79 dsb = tc->provides(
"methods")->produce(
"m7", args, caller->engine());
81 BOOST_CHECK_EQUAL( -8.0, dsd->
get());
85 dsb = tc->provides(
"methods")->produce(
"m1r", args, caller->engine());
87 BOOST_CHECK_EQUAL( 20.0, dsd->
get());
88 BOOST_CHECK_EQUAL( 20.0, d );
95 std::vector<base::DataSourceBase::shared_ptr> args;
98 BOOST_CHECK_EQUAL( -1.0, dsd->
get());
101 dsb = tc->provides(
"methods")->produce(
"o1", args, caller->engine());
103 BOOST_CHECK_EQUAL( -2.0, dsd->
get());
106 dsb = tc->provides(
"methods")->produce(
"o2", args, caller->engine());
108 BOOST_CHECK_EQUAL( -3.0, dsd->
get());
111 dsb = tc->provides(
"methods")->produce(
"o3", args, caller->engine());
113 BOOST_CHECK_EQUAL( -4.0, dsd->
get());
115 args =
GenerateDataSource().operator()<int,double,bool,std::string>(1,2.0,
true,
"hello");
116 dsb = tc->provides(
"methods")->produce(
"o4", args, caller->engine());
118 BOOST_CHECK_EQUAL( -5.0, dsd->
get());
120 args =
GenerateDataSource().operator()<int,double,bool,std::string,
float>(1,2.0,
true,
"hello", 5.0f);
121 dsb = tc->provides(
"methods")->produce(
"o5", args, caller->engine());
123 BOOST_CHECK_EQUAL( -6.0, dsd->
get());
125 args =
GenerateDataSource().operator()<int,double,bool,std::string,float,
char>(1,2.0,
true,
"hello", 5.0f,
'a');
126 dsb = tc->provides(
"methods")->produce(
"o6", args, caller->engine());
128 BOOST_CHECK_EQUAL( -7.0, dsd->
get());
130 args =
GenerateDataSource().operator()<int,double,bool,std::string,float,char,
unsigned int>(1,2.0,
true,
"hello", 5.0f,
'a', (
unsigned int)7);
131 dsb = tc->provides(
"methods")->produce(
"o7", args, caller->engine());
133 BOOST_CHECK_EQUAL( -8.0, dsd->
get());
139 BOOST_REQUIRE( tc->isRunning() );
140 BOOST_REQUIRE( caller->isRunning() );
153 std::vector<base::DataSourceBase::shared_ptr> args;
161 dsb = tc->provides(
"methods")->produceSend(
"o0", args, caller->engine());
162 dsh= tc->provides(
"methods")->produceHandle(
"o0");
164 args.push_back( dsh );
165 args.push_back( dsr );
169 update = dsh->updateAction( dsb.
get() );
177 BOOST_CHECK( h0.ready() );
181 dsb = tc->provides(
"methods")->produceSend(
"o1", args, caller->engine());
182 dsh= tc->provides(
"methods")->produceHandle(
"o1");
184 args.push_back( dsh );
185 args.push_back( dsr );
189 update = dsh->updateAction( dsb.get() );
197 BOOST_CHECK( h1.
ready() );
202 dsb = tc->provides(
"methods")->produceSend(
"o2", args, caller->engine());
203 dsh= tc->provides(
"methods")->produceHandle(
"o2");
206 update = dsh->updateAction( dsb.get() );
214 BOOST_CHECK( h2.
ready() );
218 dsb = tc->provides(
"methods")->produceSend(
"o3", args, caller->engine());
219 dsh= tc->provides(
"methods")->produceHandle(
"o3");
222 update = dsh->updateAction( dsb.get() );
229 BOOST_CHECK( h3.
ready() );
231 args =
GenerateDataSource().operator()<int,double,bool,std::string>(1,2.0,
true,
"hello");
233 dsb = tc->provides(
"methods")->produceSend(
"o4", args, caller->engine());
234 dsh= tc->provides(
"methods")->produceHandle(
"o4");
236 update = dsh->updateAction( dsb.get() );
243 BOOST_CHECK( h4.
ready() );
245 args =
GenerateDataSource().operator()<int,double,bool,std::string,
float>(1,2.0,
true,
"hello",5.0f);
247 dsb = tc->provides(
"methods")->produceSend(
"o5", args, caller->engine());
248 dsh= tc->provides(
"methods")->produceHandle(
"o5");
250 update = dsh->updateAction( dsb.get() );
257 BOOST_CHECK( h5.
ready() );
259 args =
GenerateDataSource().operator()<int,double,bool,std::string,float,
char>(1,2.0,
true,
"hello",5.0f,
'a');
261 dsb = tc->provides(
"methods")->produceSend(
"o6", args, caller->engine());
262 dsh= tc->provides(
"methods")->produceHandle(
"o6");
264 update = dsh->updateAction( dsb.get() );
271 BOOST_CHECK( h6.
ready() );
273 args =
GenerateDataSource().operator()<int,double,bool,std::string,float,char,
unsigned int>(1,2.0,
true,
"hello",5.0f,
'a',(
unsigned int)7);
275 dsb = tc->provides(
"methods")->produceSend(
"o7", args, caller->engine());
276 dsh= tc->provides(
"methods")->produceHandle(
"o7");
278 update = dsh->updateAction( dsb.get() );
285 BOOST_CHECK( h7.
ready() );
290 dsb = tc->provides(
"methods")->produceSend(
"o1r", args, caller->engine());
291 dsh = tc->provides(
"methods")->produceHandle(
"o1r");
293 update = dsh->updateAction( dsb.get() );
300 BOOST_CHECK( h1r.
ready() );
306 BOOST_CHECK_EQUAL( dsr->
get(), -1.0 );
307 BOOST_CHECK_EQUAL(
SendSuccess, h0.collect(retn) );
308 BOOST_CHECK_EQUAL( retn, -1.0 );
310 BOOST_CHECK_EQUAL( retn, -2.0 );
312 BOOST_CHECK_EQUAL( retn, -3.0 );
314 BOOST_CHECK_EQUAL( retn, -4.0 );
316 BOOST_CHECK_EQUAL( retn, -5.0 );
318 BOOST_CHECK_EQUAL( retn, -6.0 );
320 BOOST_CHECK_EQUAL( retn, -7.0 );
322 BOOST_CHECK_EQUAL( retn, -8.0 );
324 BOOST_CHECK_EQUAL( retn, 20.0 );
325 BOOST_CHECK_EQUAL( rarg, 20.0 );
329 BOOST_CHECK_EQUAL(
SendSuccess, h0.collectIfDone(retn) );
330 BOOST_CHECK_EQUAL( retn, -1.0 );
331 BOOST_CHECK_EQUAL(
SendSuccess, h1.collectIfDone(retn) );
332 BOOST_CHECK_EQUAL( retn, -2.0 );
333 BOOST_CHECK_EQUAL(
SendSuccess, h2.collectIfDone(retn) );
334 BOOST_CHECK_EQUAL( retn, -3.0 );
335 BOOST_CHECK_EQUAL(
SendSuccess, h3.collectIfDone(retn) );
336 BOOST_CHECK_EQUAL( retn, -4.0 );
337 BOOST_CHECK_EQUAL(
SendSuccess, h4.collectIfDone(retn) );
338 BOOST_CHECK_EQUAL( retn, -5.0 );
339 BOOST_CHECK_EQUAL(
SendSuccess, h5.collectIfDone(retn) );
340 BOOST_CHECK_EQUAL( retn, -6.0 );
341 BOOST_CHECK_EQUAL(
SendSuccess, h6.collectIfDone(retn) );
342 BOOST_CHECK_EQUAL( retn, -7.0 );
343 BOOST_CHECK_EQUAL(
SendSuccess, h7.collectIfDone(retn) );
344 BOOST_CHECK_EQUAL( retn, -8.0 );
345 BOOST_CHECK_EQUAL(
SendSuccess, h1r.collectIfDone(retn,rarg) );
346 BOOST_CHECK_EQUAL( retn, 20.0 );
347 BOOST_CHECK_EQUAL( rarg, 20.0 );
350 BOOST_CHECK_EQUAL( -1.0, h0.ret() );
351 BOOST_CHECK_EQUAL( -2.0, h1.ret(1) );
352 BOOST_CHECK_EQUAL( -3.0, h2.ret(1, 2.0) );
353 BOOST_CHECK_EQUAL( -4.0, h3.ret(1, 2.0,
true) );
354 BOOST_CHECK_EQUAL( -5.0, h4.ret(1, 2.0,
true,
"hello") );
355 BOOST_CHECK_EQUAL( -6.0, h5.ret(1, 2.0,
true,
"hello", 5.0f) );
356 BOOST_CHECK_EQUAL( -7.0, h6.ret(1, 2.0,
true,
"hello", 5.0f,
'a') );
357 BOOST_CHECK_EQUAL( -8.0, h7.ret(1, 2.0,
true,
"hello", 5.0f,
'a', (
unsigned int)7) );
359 BOOST_CHECK_EQUAL( -2.0, h1.ret() );
360 BOOST_CHECK_EQUAL( -3.0, h2.ret() );
361 BOOST_CHECK_EQUAL( -4.0, h3.ret() );
362 BOOST_CHECK_EQUAL( -5.0, h4.ret() );
363 BOOST_CHECK_EQUAL( -6.0, h5.ret() );
364 BOOST_CHECK_EQUAL( -7.0, h6.ret() );
365 BOOST_CHECK_EQUAL( -8.0, h7.ret() );
366 BOOST_CHECK_EQUAL( 20.0, h1r.ret() );
368 #ifdef ORO_REMOTING_OLD 376 m0.
calls(&FunctorsTest::m0,
this);
378 m1.
calls(&FunctorsTest::m1,
this);
380 m2.
calls(&FunctorsTest::m2,
this);
393 BOOST_CHECK( mm0.getOperationCallerImpl() );
394 BOOST_CHECK( mm0.ready() );
399 BOOST_CHECK( mm1.getOperationCallerImpl() );
400 BOOST_CHECK( mm1.ready() );
403 BOOST_CHECK( mm2.getOperationCallerImpl() );
404 BOOST_CHECK( mm2.ready() );
407 BOOST_CHECK_EQUAL( -1.0, mm0() );
409 BOOST_CHECK_EQUAL( -2.0, mm1(1) );
410 BOOST_CHECK_EQUAL( -3.0, mm2(1, 2.0) );
422 BOOST_CHECK( mvoid.
ready() == false );
427 BOOST_CHECK( mvoid.ready() == false );
430 BOOST_CHECK( mvoid.ready() == false );
447 BOOST_CHECK_EQUAL( -3.3, m0r() );
448 BOOST_CHECK_EQUAL( -3.3, m0cr() );
451 BOOST_CHECK_EQUAL( 5.3*2, m1r(value) );
452 BOOST_CHECK_EQUAL( 5.3*2, value );
453 BOOST_CHECK_EQUAL( 5.3, m1cr(5.3) );
469 to.
addOperation( &m3,
"desc",
"a1",
"d1",
"a2",
"d2",
"a3",
"d3");
470 to.
addOperation( &m4,
"desc",
"a1",
"d1",
"a2",
"d2",
"a3",
"d3",
"a4",
"d4");
484 BOOST_CHECK( mc0.execute() );
485 BOOST_CHECK_EQUAL(-1.0, ret);
486 BOOST_CHECK( mc1.execute() );
487 BOOST_CHECK_EQUAL(-2.0, ret);
488 BOOST_CHECK( mc2.execute() );
489 BOOST_CHECK_EQUAL(-3.0, ret);
490 BOOST_CHECK( mc3.execute() );
491 BOOST_CHECK_EQUAL(-4.0, ret);
492 BOOST_CHECK( mc4.execute() );
493 BOOST_CHECK_EQUAL(-5.0, ret);
506 meth0.
calls( boost::bind(&FunctorsTest::m0, _1));
511 meth1.
calls(boost::bind(&FunctorsTest::m1, _1,_2));
516 boost::shared_ptr<FunctorsTest> ptr(
new FunctorsTest() );
519 BOOST_CHECK( to.
addOperationDS( wp.
get(), meth1).doc(
"desc").arg(
"a1",
"d1" ).ready() );
526 BOOST_CHECK( c0.execute() );
527 BOOST_CHECK_EQUAL( -1.0, ret );
529 BOOST_CHECK( c1.execute() );
530 BOOST_CHECK_EQUAL( -2.0, ret );
533 #endif // defined(ORO_REMOTING)
#define BOOST_FIXTURE_TEST_SUITE(suite_name, F)
virtual result_t get() const =0
#define BOOST_AUTO_TEST_SUITE_END()
Operation< Signature > & addOperation(Operation< Signature > &op)
virtual void readArguments()=0
BOOST_AUTO_TEST_CASE(testClientThreadFunctor)
The SendHandle is used to collect the result values of an asynchronous invocation. The template argument Signature must have the same type as the method being invoked.
Based on the software pattern 'command', this interface allows execution of action objects...
OperationCallerC & ret(base::AttributeBase *r)
Operation & calls(boost::function< Signature > func, ExecutionThread et=ClientThread, ExecutionEngine *ownerEngine=NULL)
DataSource< T >::result_t get() const
OperationCallerC & argC(const ArgT a)
OperationInterfacePart * getOperation(std::string name)
SendStatus collect() const
Operation< typename internal::GetSignatureDS< Func >::Signature > & addOperationDS(const std::string &name, Func func, internal::DataSource< boost::shared_ptr< ObjT > > *sp, ExecutionThread et=ClientThread)
boost::intrusive_ptr< DataSourceBase > shared_ptr
void setOwner(TaskContext *new_owner)
internal::OperationCallerC create(std::string name, ExecutionEngine *caller)
static bool update(TaskContext *tc)
boost::intrusive_ptr< ValueDataSource< T > > shared_ptr