30 #include <boost/function_types/function_type.hpp> 32 #include <rtt-config.h> 41 tc->addService( this->createOperationCallerFactory() );
52 SimulationThread::Instance()->stop();
82 boost::shared_ptr<ActionInterface> implementation(
new detail::RemoteOperationCaller<
double(
void)>(tc->provides(
"methods"),
"m0") );
84 BOOST_CHECK( m0.
ready() );
87 implementation.reset(
new detail::RemoteOperationCaller<
double(
int)>(tc->provides(
"methods"),
"m1") );
89 BOOST_CHECK( m1.ready() );
91 BOOST_CHECK_EQUAL( -2.0, m1(1) );
92 BOOST_CHECK_EQUAL( -1.0, m0() );
99 mc = tc->provides(
"methods")->create(
"m0").
ret( r );
100 BOOST_CHECK( mc.execute() );
101 BOOST_CHECK( r == -1.0 );
103 mc = tc->provides(
"methods")->create(
"m2").
argC(1).
argC(1.0).
ret( r );
104 BOOST_CHECK( mc.execute() );
105 BOOST_CHECK( r == -3.0 );
107 mc = tc->provides(
"methods")->create(
"m3").
ret( r ).
argC(1).
argC(1.0).
argC(
true);
108 BOOST_CHECK( mc.execute() );
109 BOOST_CHECK( r == -4.0 );
112 +
" set r = methods.m0()\n" 113 +
" do methods.assert( r == -1.0 )\n" 114 +
" set r = methods.m1(1)\n" 115 +
" do methods.assert( r == -2.0 )\n" 116 +
" set r = methods.m2(1, 1.0)\n" 117 +
" do methods.assert( r == -3.0 )\n" 118 +
" set r = methods.m3(1, 1.0, true)\n" 119 +
" do methods.assert( r == -4.0 )\n" 120 +
" set r = methods.m4(1, 1.0, true, \"hello\")\n" 121 +
" do methods.assert( r == -5.0 )\n" 133 BOOST_CHECK_EQUAL( -1.0, m0() );
134 BOOST_CHECK_EQUAL( -2.0, m1(1) );
135 BOOST_CHECK_EQUAL( -3.0, m2(1, 2.0) );
136 BOOST_CHECK_EQUAL( -4.0, m3(1, 2.0,
false) );
137 BOOST_CHECK_EQUAL( -5.0, m4(1, 2.0,
false,
"hello") );
151 BOOST_CHECK( to.addOperationCaller(&m0) );
152 BOOST_CHECK( ! to.addOperationCaller(&m0) );
153 BOOST_CHECK( to.addOperationCaller(&m1) );
154 BOOST_CHECK( to.addOperationCaller(&m2) );
158 BOOST_CHECK( mm0.getOperationCallerImpl() );
159 BOOST_CHECK( mm0.ready() );
163 mm1 = to.getOperationCaller<double(
int)>(
"m1");
164 BOOST_CHECK( mm1.getOperationCallerImpl() );
165 BOOST_CHECK( mm1.ready() );
168 BOOST_CHECK( mm2.getOperationCallerImpl() );
169 BOOST_CHECK( mm2.ready() );
172 BOOST_CHECK( tsim->start()) ;
174 BOOST_CHECK_EQUAL( -1.0, mm0() );
176 BOOST_CHECK_EQUAL( -2.0, mm1(1) );
177 BOOST_CHECK_EQUAL( -3.0, mm2(1, 2.0) );
182 BOOST_CHECK(to.addOperationCaller( &mvoid ) ==
false);
184 BOOST_CHECK(to.addOperationCaller( &mvoid ) ==
false);
187 mvoid = to.getOperationCaller<void(
void)>(
"m1");
188 BOOST_CHECK( mvoid.
ready() == false );
190 mvoid = to.getOperationCaller<void(
bool)>(
"m1");
192 mvoid = to.getOperationCaller<double(
void)>(
"m0");
193 BOOST_CHECK( mvoid.ready() == false );
195 mvoid = to.getOperationCaller<void(
void)>(
"voidm");
196 BOOST_CHECK( mvoid.ready() == false );
213 BOOST_CHECK_EQUAL( -3.3, m0r() );
214 BOOST_CHECK_EQUAL( -3.3, m0cr() );
217 BOOST_CHECK_EQUAL( 5.3*2, m1r(value) );
218 BOOST_CHECK_EQUAL( 5.3*2, value );
219 BOOST_CHECK_EQUAL( 5.3, m1cr(5.3) );
235 to.
addOperation( &m2 ).doc(
"desc").arg(
"a1",
"d1").arg(
"a2",
"d2");
236 to.
addOperation( &m3 ).doc(
"desc").arg(
"a1",
"d1").arg(
"a2",
"d2").arg(
"a3",
"d3");
237 to.
addOperation( &m4 ).doc(
"desc").arg(
"a1",
"d1").arg(
"a2",
"d2").arg(
"a3",
"d3").arg(
"a4",
"d4");
251 BOOST_CHECK( mc0.execute() );
252 BOOST_CHECK_EQUAL(-1.0, ret);
253 BOOST_CHECK( mc1.execute() );
254 BOOST_CHECK_EQUAL(-2.0, ret);
255 BOOST_CHECK( mc2.execute() );
256 BOOST_CHECK_EQUAL(-3.0, ret);
257 BOOST_CHECK( mc3.execute() );
258 BOOST_CHECK_EQUAL(-4.0, ret);
259 BOOST_CHECK( mc4.execute() );
260 BOOST_CHECK_EQUAL(-5.0, ret);
285 BOOST_CHECK( to.addOperationCallerDS( wp.
get(), meth0,
"desc" ) );
286 BOOST_CHECK( to.addOperationCallerDS( wp.
get(), meth1,
"desc",
"a1",
"d1" ) );
291 BOOST_CHECK( tsim->start()) ;
295 BOOST_CHECK( c0.execute() );
296 BOOST_CHECK_EQUAL( -1.0, ret );
298 BOOST_CHECK( c1.execute() );
299 BOOST_CHECK_EQUAL( -2.0, ret );
301 BOOST_CHECK( tsim->stop()) ;
314 BOOST_CHECK_EQUAL( -1.0, m0() );
315 BOOST_CHECK_EQUAL( -2.0, m1(1) );
316 BOOST_CHECK_EQUAL( -3.0, m2(1, 2.0) );
317 BOOST_CHECK_EQUAL( -4.0, m3(1, 2.0,
false) );
318 BOOST_CHECK_EQUAL( -5.0, m4(1, 2.0,
false,
"hello") );
#define BOOST_FIXTURE_TEST_SUITE(suite_name, F)
double m1cr(const double &a)
Service * createOperationCallerFactory()
BOOST_AUTO_TEST_CASE(testRemoteOperationCaller)
#define BOOST_AUTO_TEST_SUITE_END()
Operation< Signature > & addOperation(Operation< Signature > &op)
bool comstr(const std::string &cs)
OperationCallerC & ret(base::AttributeBase *r)
DataSource< T >::result_t get() const
OperationCallerC & argC(const ArgT a)
double m3(int i, double d, bool c)
double m4(int i, double d, bool c, std::string s)
internal::OperationCallerC create(std::string name, ExecutionEngine *caller)
double m2(int i, double d)