26 #ifndef OutPortBase_cpp 27 #define OutPortBase_cpp 29 #include <cppunit/ui/text/TestRunner.h> 30 #include <cppunit/TextOutputter.h> 31 #include <cppunit/extensions/TestFactoryRegistry.h> 32 #include <cppunit/extensions/HelperMacros.h> 33 #include <cppunit/TestAssert.h> 35 #include <rtm/idl/BasicDataTypeSkel.h> 36 #include <rtm/idl/DataPortSkel.h> 73 "ON_BUFFER_WRITE_TIMEOUT",
74 "ON_BUFFER_OVERWRITE",
79 "ON_RECEIVER_TIMEOUT",
87 "ON_BUFFER_READ_TIMEOUT",
112 const RTC::TimedLong&
data)
114 std::cout <<
"------------------------------" << std::endl;
115 std::cout <<
"Data Listener: " <<
m_name << std::endl;
116 std::cout <<
"Profile::name: " << info.
name << std::endl;
117 std::cout <<
"------------------------------" << std::endl;
138 std::cout <<
"------------------------------" << std::endl;
139 std::cout <<
"Connector Listener: " <<
m_name << std::endl;
140 std::cout <<
"Profile::name: " << info.
name << std::endl;
141 std::cout <<
"------------------------------" << std::endl;
155 PublisherA(std::string& footPrints) : m_footPrints(footPrints) {};
176 PublisherB(std::string& footPrints) : m_footPrints(footPrints) {};
193 PublisherC(std::string& footPrints) : m_footPrints(footPrints) {};
210 PublisherD(std::string& footPrints) : m_footPrints(footPrints) {};
224 void log(
const std::string& msg)
226 m_log.push_back(msg);
232 for (
int i = 0; i < (int) m_log.size(); ++i)
234 if (m_log[i] == msg) ++count;
251 template <
class DataType>
260 logger.
log(
"RingBufferMock::Constructor");
261 m_read_return_value = BUFFER_OK;
274 m_read_return_value = value;
297 return ::RTC::BufferStatus::BUFFER_OK;
305 return ::RTC::BufferStatus::BUFFER_OK;
311 virtual DataType*
wptr(
long int n = 0)
321 return ::RTC::BufferStatus::BUFFER_OK;
329 return ::RTC::BufferStatus::BUFFER_OK;
336 long int sec = -1,
long int nsec = -1)
338 return ::RTC::BufferStatus::BUFFER_OK;
360 virtual DataType*
rptr(
long int n = 0)
370 return ::RTC::BufferStatus::BUFFER_OK;
378 return ::RTC::BufferStatus::BUFFER_OK;
384 virtual DataType&
get()
393 long int sec = -1,
long int nsec = -1)
395 if (m_logger != NULL)
397 m_logger->log(
"RingBufferMock::read");
400 return m_read_return_value;
434 template <
class DataType>
467 return createProvider(cprof, prop);
475 return createConsumer(cprof, prop);
484 return createConnector(cprof,prop,provider);
492 return publishInterfaces(connector_profile);
500 return subscribeInterfaces(connector_profile);
508 return m_consumerTypes;
516 return m_providerTypes;
557 template <
class DataType>
570 return publishInterfaces(connector_profile);
578 return subscribeInterfaces(connector_profile);
614 if (m_logger != NULL)
616 m_logger->log(
"InPortCorbaCdrConsumerMock::init");
694 public virtual ::POA_OpenRTM::OutPortCdr,
695 public virtual PortableServer::RefCountServantBase
701 setInterfaceType(
"corba_cdr");
713 if (m_logger != NULL)
715 m_logger->log(
"OutPortCorbaCdrProviderMock::init");
725 if (m_logger != NULL)
727 m_logger->log(
"OutPortCorbaCdrProviderMock::setBuffer");
746 virtual ::OpenRTM::PortStatus
get(::OpenRTM::CdrData_out
data)
748 return ::OpenRTM::PORT_OK;
823 :
public CppUnit::TestFixture
827 CPPUNIT_TEST(test_constructor);
828 CPPUNIT_TEST(test_initConsumers);
829 CPPUNIT_TEST(test_initConsumers2);
830 CPPUNIT_TEST(test_initProviders);
831 CPPUNIT_TEST(test_initProviders2);
832 CPPUNIT_TEST(test_init_properties);
833 CPPUNIT_TEST(test_name);
834 CPPUNIT_TEST(test_connectors_getConnectorXX);
835 CPPUNIT_TEST(test_activateInterfaces_deactivateInterfaces);
836 CPPUNIT_TEST(test_publishInterfaces);
837 CPPUNIT_TEST(test_publishInterfaces2);
838 CPPUNIT_TEST(test_publishInterfaces3);
839 CPPUNIT_TEST(test_publishInterfaces4);
840 CPPUNIT_TEST(test_publishInterfaces5);
841 CPPUNIT_TEST(test_subscribeInterfaces);
842 CPPUNIT_TEST(test_subscribeInterfaces2);
843 CPPUNIT_TEST(test_subscribeInterfaces3);
844 CPPUNIT_TEST(test_subscribeInterfaces4);
845 CPPUNIT_TEST(test_subscribeInterfaces5);
846 CPPUNIT_TEST(test_ConnectorListener);
848 CPPUNIT_TEST_SUITE_END();
864 : rtclog(
"The unit test for OutPortBase")
868 m_pORB = CORBA::ORB_init(argc, argv);
869 m_pPOA = PortableServer::POA::_narrow(
870 m_pORB->resolve_initial_references(
"RootPOA"));
871 m_pPOA->the_POAManager()->activate();
894 addFactory(
"corba_cdr",
907 addFactory(
"corba_cdr",
969 addFactory(
"corba_cdr",
982 addFactory(
"corba_cdr",
1005 toTypename<RTC::TimedFloat>());
1012 CPPUNIT_ASSERT_EQUAL(std::string(
"DataOutPort"),
1013 prop[
"port.port_type"] );
1014 CPPUNIT_ASSERT_EQUAL(std::string(toTypename<RTC::TimedFloat>()),
1015 prop[
"dataport.data_type"] );
1016 CPPUNIT_ASSERT_EQUAL(std::string(
""),
1017 prop[
"dataport.subscription_type"]);
1029 toTypename<RTC::TimedFloat>());
1036 CPPUNIT_ASSERT_EQUAL(std::string(
"DataOutPort"),
1037 prop[
"port.port_type"] );
1038 CPPUNIT_ASSERT_EQUAL(std::string(toTypename<RTC::TimedFloat>()),
1039 prop[
"dataport.data_type"] );
1040 CPPUNIT_ASSERT_EQUAL(std::string(
"flush"),
1041 prop[
"dataport.subscription_type"]);
1054 toTypename<RTC::TimedFloat>());
1061 CPPUNIT_ASSERT_EQUAL(std::string(
"DataOutPort"),
1062 prop[
"port.port_type"] );
1063 CPPUNIT_ASSERT_EQUAL(std::string(toTypename<RTC::TimedFloat>()),
1064 prop[
"dataport.data_type"] );
1065 CPPUNIT_ASSERT_EQUAL(std::string(
"flush,new"),
1066 prop[
"dataport.subscription_type"]);
1078 toTypename<RTC::TimedFloat>());
1085 CPPUNIT_ASSERT_EQUAL(std::string(
"DataOutPort"),
1086 prop[
"port.port_type"] );
1087 CPPUNIT_ASSERT_EQUAL(std::string(toTypename<RTC::TimedFloat>()),
1088 prop[
"dataport.data_type"] );
1089 CPPUNIT_ASSERT_EQUAL(std::string(
"flush,new,periodic"),
1090 prop[
"dataport.subscription_type"]);
1114 toTypename<RTC::TimedFloat>());
1121 addFactory(
"corba_cdr",
1128 addFactory(
"corba_cdr",
1136 CPPUNIT_ASSERT_EQUAL(std::string(
""),
1137 prop[
"dataport.dataflow_type"]);
1138 CPPUNIT_ASSERT_EQUAL(std::string(
""),
1139 prop[
"dataport.interface_type"]);
1142 CPPUNIT_ASSERT_EQUAL((
size_t)0, cstr.size());
1150 CPPUNIT_ASSERT_EQUAL(std::string(
"push"),
1151 prop[
"dataport.dataflow_type"]);
1152 CPPUNIT_ASSERT_EQUAL(std::string(
"corba_cdr"),
1153 prop[
"dataport.interface_type"]);
1157 CPPUNIT_ASSERT((
size_t)0!= cstr.size());
1158 CPPUNIT_ASSERT_EQUAL(std::string(
"corba_cdr"),
1182 toTypename<RTC::TimedFloat>());
1189 addFactory(
"corba_cdr",
1197 CPPUNIT_ASSERT_EQUAL(std::string(
""),
1198 prop[
"dataport.dataflow_type"]);
1199 CPPUNIT_ASSERT_EQUAL(std::string(
""),
1200 prop[
"dataport.interface_type"]);
1203 CPPUNIT_ASSERT_EQUAL((
size_t)0, cstr.size());
1211 CPPUNIT_ASSERT_EQUAL(std::string(
""),
1212 prop[
"dataport.dataflow_type"]);
1213 CPPUNIT_ASSERT_EQUAL(std::string(
""),
1214 prop[
"dataport.interface_type"]);
1218 CPPUNIT_ASSERT((
size_t)0== cstr.size());
1241 toTypename<RTC::TimedFloat>());
1248 addFactory(
"corba_cdr",
1255 addFactory(
"corba_cdr",
1263 CPPUNIT_ASSERT_EQUAL(std::string(
""),
1264 prop[
"dataport.dataflow_type"]);
1265 CPPUNIT_ASSERT_EQUAL(std::string(
""),
1266 prop[
"dataport.interface_type"]);
1269 CPPUNIT_ASSERT_EQUAL((
size_t)0, cstr.size());
1277 CPPUNIT_ASSERT_EQUAL(std::string(
"pull"),
1278 prop[
"dataport.dataflow_type"]);
1279 CPPUNIT_ASSERT_EQUAL(std::string(
"corba_cdr"),
1280 prop[
"dataport.interface_type"]);
1284 CPPUNIT_ASSERT((
size_t)0!= cstr.size());
1285 CPPUNIT_ASSERT_EQUAL(std::string(
"corba_cdr"),
1309 toTypename<RTC::TimedFloat>());
1316 addFactory(
"corba_cdr",
1324 CPPUNIT_ASSERT_EQUAL(std::string(
""),
1325 prop[
"dataport.dataflow_type"]);
1326 CPPUNIT_ASSERT_EQUAL(std::string(
""),
1327 prop[
"dataport.interface_type"]);
1330 CPPUNIT_ASSERT_EQUAL((
size_t)0, cstr.size());
1338 CPPUNIT_ASSERT_EQUAL(std::string(
""),
1339 prop[
"dataport.dataflow_type"]);
1340 CPPUNIT_ASSERT_EQUAL(std::string(
""),
1341 prop[
"dataport.interface_type"]);
1345 CPPUNIT_ASSERT((
size_t)0== cstr.size());
1355 OutPortBaseMock outPort(
"OutPortBaseTest", toTypename<RTC::TimedDouble>());
1358 prop[
"dataport.interface_type"] =
"corba_cdr";
1359 prop[
"dataport.dataflow_type"] =
"pull";
1360 prop[
"dataport.subscription_type"] =
"new";
1368 CPPUNIT_ASSERT_EQUAL(prop.
size(), prop2.
size());
1370 CPPUNIT_ASSERT_EQUAL(prop[
"dataport.interface_type"],
1371 prop2[
"dataport.interface_type"]);
1372 CPPUNIT_ASSERT_EQUAL(prop[
"dataport.dataflow_type"],
1373 prop2[
"dataport.dataflow_type"]);
1374 CPPUNIT_ASSERT_EQUAL(prop[
"dataport.subscription_type"],
1375 prop2[
"dataport.subscription_type"]);
1378 CPPUNIT_ASSERT_EQUAL(prop.
size(), prop2.
size());
1380 CPPUNIT_ASSERT_EQUAL(prop[
"dataport.interface_type"],
1381 prop2[
"dataport.interface_type"]);
1382 CPPUNIT_ASSERT_EQUAL(prop[
"dataport.dataflow_type"],
1383 prop2[
"dataport.dataflow_type"]);
1384 CPPUNIT_ASSERT_EQUAL(prop[
"dataport.subscription_type"],
1385 prop2[
"dataport.subscription_type"]);
1396 OutPortBaseMock outPort(
"Hello, World!", toTypename<RTC::TimedDouble>());
1401 CPPUNIT_ASSERT_EQUAL(std::string(
"unknown.Hello, World!"), std::string(outPort.
getName()));
1411 RTC::TimedDouble inbindValue;
1414 OutPortBaseMock outPort(
"OutPortBaseTest", toTypename<RTC::TimedDouble>());
1420 RTC::ConnectorProfile inprof;
1421 inprof.ports.length(1);
1432 inprof.connector_id =
"id0";
1433 inprof.name = CORBA::string_dup(
"bar");
1437 outPort.
init(dummy);
1441 std::string vstrid[10] = {
"id0",
"id1",
"id2",
"id3",
"id4",
1442 "id5",
"id6",
"id7",
"id8",
"id9"};
1443 std::string vstrname[10] = {
"foo0",
"foo1",
"foo2",
"foo3",
"foo4",
1444 "foo5",
"foo6",
"foo7",
"foo8",
"foo9"};
1446 std::string vstrinterface[10] = {
"corba_cdr",
"corba_cdr",
"corba_cdr",
1447 "corba_cdr",
"corba_cdr",
"corba_cdr",
1448 "corba_cdr",
"corba_cdr",
"corba_cdr",
1450 std::string vstrdataflow[10] = {
"push",
"push",
"push",
1451 "push",
"push",
"push",
1452 "pull",
"pull",
"pull",
"pull"};
1454 std::string vstrsubscription[10] = {
"flush",
"flush",
"flush",
1455 "flush",
"flush",
"flush",
1456 "flush",
"flush",
"flush",
"flush"};
1461 for(
int ic(0);ic<10;++ic)
1463 RTC::ConnectorProfile prof;
1464 prof.ports.length(1);
1468 vstrinterface[ic].c_str()));
1471 vstrdataflow[ic].c_str()));
1474 vstrsubscription[ic].c_str()));
1477 NVUtil::toString(inprof.properties,
"dataport.corba_cdr.inport_ior").c_str()));
1478 prof.connector_id = vstrid[ic].c_str();
1479 prof.name = CORBA::string_dup(vstrname[ic].c_str());
1485 prop << conn_prop.getNode(
"dataport");
1489 std::vector<RTC::OutPortConnector*> objs = outPort.
connectors();
1491 CPPUNIT_ASSERT_EQUAL((
size_t)(ic+1), objs.size());
1492 CPPUNIT_ASSERT_EQUAL(vstrid[ic], std::string(objs[ic]->
id()));
1493 CPPUNIT_ASSERT_EQUAL(vstrname[ic], std::string(objs[ic]->name()));
1500 CPPUNIT_ASSERT_EQUAL((
size_t)10, list.size());
1501 for(
int ic(0);ic<10;++ic)
1503 CPPUNIT_ASSERT_EQUAL(vstrid[ic], std::string(list[ic].
id));
1504 CPPUNIT_ASSERT_EQUAL(vstrname[ic], std::string(list[ic].name));
1505 CPPUNIT_ASSERT_EQUAL((
size_t)1, list[ic].ports.size());
1507 CPPUNIT_ASSERT_EQUAL(vstrinterface[ic],
1508 list[ic].properties[
"interface_type"]);
1509 CPPUNIT_ASSERT_EQUAL(vstrdataflow[ic],
1510 list[ic].properties[
"dataflow_type"]);
1511 CPPUNIT_ASSERT_EQUAL(vstrsubscription[ic],
1512 list[ic].properties[
"subscription_type"]);
1520 CPPUNIT_ASSERT_EQUAL((
size_t)10, ids.size());
1521 for(
int ic(0);ic<10;++ic)
1523 CPPUNIT_ASSERT_EQUAL(vstrid[ic], ids[ic]);
1530 CPPUNIT_ASSERT_EQUAL((
size_t)10, names.size());
1531 for(
int ic(0);ic<10;++ic)
1533 CPPUNIT_ASSERT_EQUAL(vstrname[ic], names[ic]);
1540 CPPUNIT_ASSERT(oc == 0);
1542 CPPUNIT_ASSERT(oc != 0);
1544 CPPUNIT_ASSERT(oc != 0);
1550 CPPUNIT_ASSERT(oc == 0);
1552 CPPUNIT_ASSERT(oc != 0);
1554 CPPUNIT_ASSERT(oc != 0);
1559 for(
int ic(0);ic<10;++ic)
1564 CPPUNIT_ASSERT(ret);
1565 CPPUNIT_ASSERT_EQUAL(vstrinterface[ic],
1567 CPPUNIT_ASSERT_EQUAL(vstrdataflow[ic],
1569 CPPUNIT_ASSERT_EQUAL(vstrsubscription[ic],
1575 CPPUNIT_ASSERT(!ret);
1577 CPPUNIT_ASSERT(!ret);
1583 for(
int ic(0);ic<10;++ic)
1588 CPPUNIT_ASSERT(ret);
1589 CPPUNIT_ASSERT_EQUAL(vstrinterface[ic],
1591 CPPUNIT_ASSERT_EQUAL(vstrdataflow[ic],
1593 CPPUNIT_ASSERT_EQUAL(vstrsubscription[ic],
1599 CPPUNIT_ASSERT(!ret);
1601 CPPUNIT_ASSERT(!ret);
1608 RTC::ConnectorProfile outprof;
1610 CPPUNIT_ASSERT(ret);
1614 NVUtil::find(outprof.properties,
"dataport.data_type") >>= value;
1615 CPPUNIT_FAIL(
"dataport.data_type fialure.");
1617 catch(std::string ex) {
1620 CPPUNIT_FAIL(
"dataport.data_type failure.");
1634 RTC::TimedDouble inbindValue;
1637 OutPortBaseMock outPort(
"out:OutPortBaseTest", toTypename<RTC::TimedDouble>());
1643 RTC::ConnectorProfile inprof;
1644 inprof.ports.length(1);
1655 inprof.connector_id =
"id0";
1656 inprof.name = CORBA::string_dup(
"bar");
1659 outPort.
init(dummy);
1663 std::string vstrid[10] = {
"id0",
"id1",
"id2",
"id3",
"id4",
1664 "id5",
"id6",
"id7",
"id8",
"id9"};
1665 std::string vstrname[10] = {
"foo0",
"foo1",
"foo2",
"foo3",
"foo4",
1666 "foo5",
"foo6",
"foo7",
"foo8",
"foo9"};
1668 std::string vstrinterface[10] = {
"corba_cdr",
"corba_cdr",
"corba_cdr",
1669 "corba_cdr",
"corba_cdr",
"corba_cdr",
1670 "corba_cdr",
"corba_cdr",
"corba_cdr",
1672 std::string vstrdataflow[10] = {
"push",
"push",
"push",
1673 "push",
"push",
"push",
1674 "push",
"push",
"push",
"push"};
1676 std::string vstrsubscription[10] = {
"flush",
"flush",
"flush",
1677 "flush",
"flush",
"flush",
1678 "flush",
"flush",
"flush",
"flush"};
1681 for(
int ic(0);ic<10;++ic)
1683 RTC::ConnectorProfile prof;
1684 prof.ports.length(1);
1688 vstrinterface[ic].c_str()));
1691 vstrdataflow[ic].c_str()));
1694 vstrsubscription[ic].c_str()));
1697 NVUtil::toString(inprof.properties,
"dataport.corba_cdr.inport_ior").c_str()));
1698 prof.connector_id = vstrid[ic].c_str();
1699 prof.name = CORBA::string_dup(vstrname[ic].c_str());
1708 CPPUNIT_ASSERT_EQUAL(logcnt+10,
1709 ::
RTC::logger.countLog(
"OutPortPushConnector::activate"));
1714 CPPUNIT_ASSERT_EQUAL(logcnt+10,
1715 ::
RTC::logger.countLog(
"OutPortPushConnector::deactivate"));
1734 addFactory(
"corba_cdr",
1747 addFactory(
"corba_cdr",
1755 toTypename<RTC::TimedFloat>());
1759 RTC::ConnectorProfile prof;
1760 prof.connector_id =
"id0";
1761 prof.name = CORBA::string_dup(
"OutPortBaseTest0");
1762 prof.ports.length(1);
1774 outPort.
init(dummy);
1782 prof.connector_id =
"id1";
1783 prof.name = CORBA::string_dup(
"OutPortBaseTest1");
1807 addFactory(
"corba_cdr",
1820 addFactory(
"corba_cdr",
1828 toTypename<RTC::TimedFloat>());
1832 RTC::ConnectorProfile prof;
1833 prof.connector_id =
"id0";
1834 prof.name = CORBA::string_dup(
"OutPortBaseTest0");
1835 prof.ports.length(1);
1847 outPort.
init(dummy);
1874 addFactory(
"corba_cdr",
1887 addFactory(
"corba_cdr",
1895 toTypename<RTC::TimedFloat>());
1899 RTC::ConnectorProfile prof;
1900 prof.connector_id =
"id0";
1901 prof.name = CORBA::string_dup(
"OutPortBaseTest0");
1902 prof.ports.length(1);
1914 outPort.
init(dummy);
1947 addFactory(
"corba_cdr",
1955 toTypename<RTC::TimedFloat>());
1959 RTC::ConnectorProfile prof;
1960 prof.connector_id =
"id0";
1961 prof.name = CORBA::string_dup(
"OutPortBaseTest0");
1962 prof.ports.length(1);
1974 outPort.
init(dummy);
1998 addFactory(
"corba_cdr",
2011 addFactory(
"corba_cdr",
2019 toTypename<RTC::TimedFloat>());
2023 RTC::ConnectorProfile prof;
2024 prof.connector_id =
"id0";
2025 prof.name = CORBA::string_dup(
"OutPortBaseTest0");
2026 prof.ports.length(1);
2041 outPort.
init(dummy);
2064 addFactory(
"corba_cdr",
2077 addFactory(
"corba_cdr",
2085 toTypename<RTC::TimedFloat>());
2090 RTC::ConnectorProfile prof;
2091 prof.connector_id =
"id0";
2092 prof.name = CORBA::string_dup(
"OutPortBaseTest0");
2093 prof.ports.length(1);
2105 outPort.
init(dummy);
2113 prof.connector_id =
"id1";
2114 prof.name = CORBA::string_dup(
"OutPortBaseTest1");
2134 addFactory(
"corba_cdr",
2147 addFactory(
"corba_cdr",
2155 toTypename<RTC::TimedFloat>());
2160 RTC::ConnectorProfile prof;
2161 prof.connector_id =
"id0";
2162 prof.name = CORBA::string_dup(
"OutPortBaseTest0");
2163 prof.ports.length(1);
2195 addFactory(
"corba_cdr",
2208 addFactory(
"corba_cdr",
2216 toTypename<RTC::TimedFloat>());
2221 RTC::ConnectorProfile prof;
2222 prof.connector_id =
"id0";
2223 prof.name = CORBA::string_dup(
"OutPortBaseTest0");
2224 prof.ports.length(1);
2256 addFactory(
"corba_cdr",
2270 toTypename<RTC::TimedFloat>());
2275 RTC::ConnectorProfile prof;
2276 prof.connector_id =
"id0";
2277 prof.name = CORBA::string_dup(
"OutPortBaseTest0");
2278 prof.ports.length(1);
2310 addFactory(
"corba_cdr",
2323 addFactory(
"corba_cdr",
2331 toTypename<RTC::TimedFloat>());
2336 RTC::ConnectorProfile prof;
2337 prof.connector_id =
"id0";
2338 prof.name = CORBA::string_dup(
"OutPortBaseTest0");
2339 prof.ports.length(1);
2354 outPort.
init(dummy);
2374 OutPortBaseMock outPort(
"OutPortBaseTest", toTypename<RTC::TimedLong>());
2380 RTC::ConnectorProfile prof;
2381 prof.ports.length(2);
2393 prof.connector_id =
"id0";
2394 prof.name = CORBA::string_dup(
"test");
2397 outPort.
init(dummy);
2400 for (
int i(0); i<
cdl_len; ++i)
2406 for (
int i(0); i<
cl_len; ++i)
2412 for (
int i(0); i<
cdl_len; ++i)
2415 m_datalisteners[i],
true);
2419 for (
int i(0); i<
cl_len; ++i)
2422 m_connlisteners[i],
true);
2439 CPPUNIT_ASSERT( bret );
2451 for (
int i(0); i<
cdl_len; ++i)
2454 m_datalisteners[i]);
2458 for (
int i(0); i<
cl_len; ++i)
2461 m_connlisteners[i]);
2487 OutPortPushConnector::OutPortPushConnector(ConnectorInfo info,
2488 InPortConsumer* consumer,
2489 ConnectorListeners& listeners,
2492 m_consumer(consumer), m_publisher(0), m_listeners(listeners), m_buffer(buffer)
2494 if(info.properties[
"OutPortBaseTests"]==
"bad_alloc")
2496 throw std::bad_alloc();
2498 m_publisher = createPublisher(info);
2499 m_publisher->init(info.properties);
2500 m_publisher->setListener(m_profile, &m_listeners);
2507 OutPortPushConnector::~OutPortPushConnector()
2518 if (m_publisher != 0)
2521 pfactory.deleteObject(m_publisher);
2538 void OutPortPushConnector::activate()
2546 void OutPortPushConnector::deactivate()
2555 OutPortPushConnector::write(
const cdrMemoryStream&
data)
2563 PublisherBase* OutPortPushConnector::createPublisher(ConnectorInfo& info)
2571 CdrBufferBase* OutPortPushConnector::createBuffer(ConnectorInfo& info)
2580 void OutPortPushConnector::onConnect()
2582 m_listeners.connector_[
ON_CONNECT].notify(m_profile);
2588 void OutPortPushConnector::onDisconnect()
2602 OutPortPullConnector::OutPortPullConnector(ConnectorInfo info,
2604 ConnectorListeners& listeners,
2610 if(info.properties[
"OutPortBaseTests"]==
"bad_alloc")
2612 throw std::bad_alloc();
2619 OutPortPullConnector::~OutPortPullConnector()
2627 OutPortPullConnector::write(
const cdrMemoryStream& data)
2656 int main(
int argc,
char* argv[])
2669 std::string arg(argv[i]);
2670 std::string next_arg;
2671 if (i + 1 < argc) next_arg = argv[i + 1];
2674 if (arg ==
"--text") { format =
TEXT_OUT;
break; }
2687 ofs.open(fname.c_str());
2689 if ( arg ==
"--compiler" ) { format =
COMPILER_OUT;
break; }
2690 if ( arg ==
"--cerr" ) { target = 1;
break; }
2691 if ( arg ==
"--xsl" )
2693 if (next_arg ==
"") xsl =
"default.xsl";
2694 else xsl = next_arg;
2696 if ( arg ==
"--namespace" )
2700 std::cerr <<
"no namespace specified" << std::endl;
2710 CppUnit::TextUi::TestRunner runner;
2712 runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());
2714 runner.addTest(CppUnit::TestFactoryRegistry::getRegistry(ns).makeTest());
2715 CppUnit::Outputter* outputter = 0;
2716 std::ostream* stream = target ? &std::cerr : &std::cout;
2720 outputter =
new CppUnit::TextOutputter(&runner.result(),*stream);
2723 std::cout <<
"XML_OUT" << std::endl;
2724 outputter =
new CppUnit::XmlOutputter(&runner.result(),
2726 static_cast<CppUnit::XmlOutputter*
>(outputter)->setStyleSheet(xsl);
2729 outputter =
new CppUnit::CompilerOutputter(&runner.result(),*stream);
2732 runner.setOutputter(outputter);
2737 #endif // OutPortBase_cpp SDOPackage::NameValue newNV(const char *name, Value value)
Create NameValue.
virtual ReturnCode read(DataType &value, long int sec=-1, long int nsec=-1)
Read data from the buffer.
virtual RTC::ReturnCode_t publishInterfaces_public(RTC::ConnectorProfile &connector_profile)
OutPortConnector * getConnectorById(const char *id)
Getting ConnectorProfile by ID.
ConnectorListeners class.
InPortConsumer abstract class.
#define RTC_ERROR(fmt)
Error log output macro.
void test_subscribeInterfaces3(void)
subscribeInterfaces()メソッドのテスト
int main(int argc, char **argv)
void setLogger(Logger *logger)
ConnectorInfoList getConnectorProfiles()
ConnectorProfile list.
virtual ReturnCode length(size_t n)
Set the buffer length.
void addConnectorDataListener(ConnectorDataListenerType listener_type, ConnectorDataListener *listener, bool autoclean=true)
Adding BufferDataListener type listener.
void initConsumers_public(void)
BufferBase< cdrMemoryStream > CdrBufferBase
PortableServer::POA_ptr m_pPOA
BUFFERSTATUS_ENUM RingBufferMock(long int length=8)
OutPortConnector base class.
coil::Properties properties
Connection properties.
coil::vstring getConnectorNames()
Connector name list.
void test_publishInterfaces2(void)
publishInterfaces()メソッドのテスト
coil::vstring getConnectorIds()
ConnectorId list.
void test_subscribeInterfaces2(void)
subscribeInterfaces()メソッドのテスト
virtual ReturnCode write(const DataType &value, long int sec=-1, long int nsec=-1)
Write data into the buffer.
OutPortConnector * getConnectorByName(const char *name)
Getting Connector by name.
void setListener(RTC::ConnectorInfo &info, RTC::ConnectorListeners *listeners)
Set the listener.
OutPortCorbaCdrProviderMock(void)
bool unsubscribeFromRef(const SDOPackage::NVList &properties)
PublisherA(std::string &footPrints)
virtual void setUp()
Test initialization.
void test_initConsumers()
initConsumers()メソッドのテスト
void test_initConsumers2()
initConsumers()メソッドのテスト
RTC::InPortConsumer::ReturnCode put(const cdrMemoryStream &data)
Send data to the destination port.
void addConnectorListener(ConnectorListenerType callback_type, ConnectorListener *listener, bool autoclean=true)
Adding ConnectorListener type listener.
virtual RTC::ReturnCode_t publishInterfaces_public(RTC::ConnectorProfile &connector_profile)
void test_activateInterfaces_deactivateInterfaces(void)
activateInterfaces(),deactivateInterfaces()メソッドのテスト
void test_subscribeInterfaces5(void)
subscribeInterfaces()メソッドのテスト
RT component logger class.
void unsubscribeInterface(const SDOPackage::NVList &properties)
AbstractClass * Creator()
Creator template.
bool subscribeInterface(const SDOPackage::NVList &properties)
std::vector< std::pair< std::string, std::string > > NVList
virtual void init(const coil::Properties &prop)
Set the buffer.
void log(const std::string &msg)
RTC::InPortConsumer * createCondumer_public(RTC::ConnectorProfile &cprof, coil::Properties &prop)
void test_subscribeInterfaces4(void)
subscribeInterfaces()メソッドのテスト
void test_initProviders()
initProviders()メソッドのテスト
void init(coil::Properties &prop)
Initializing configuration.
RTC::ReturnCode_t ret(RTC::Local::ReturnCode_t r)
void unsubscribeInterface(const SDOPackage::NVList &properties)
Unsubscribe the data send notification.
void removeConnectorListener(ConnectorListenerType callback_type, ConnectorListener *listener)
Removing BufferDataListener type listener.
const char * getName() const
Get the name of this Port.
static const char * str_cl[]
RTC::ConnectorListeners m_listeners
void test_publishInterfaces4(void)
publishInterfaces()メソッドのテスト
virtual size_t length(void) const
Get the buffer length.
bool unsubscribeFromIor(const SDOPackage::NVList &properties)
static const char * str_cdl[]
std::vector< ConnectorInfo > ConnectorInfoList
std::string & m_footPrints
virtual RTC::ReturnCode_t subscribeInterfaces_public(RTC::ConnectorProfile &connector_profile)
static GlobalFactory< AbstractClass, Identifier, Compare, Creator, Destructor > & instance()
Create instance.
void test_initProviders2()
initProviders()メソッドのテスト
bool isLittleEndian()
return it whether endian setting.
std::string & m_footPrints
virtual RTC::ReturnCode_t subscribeInterfaces_public(RTC::ConnectorProfile &connector_profile)
void initProviders_public(void)
Enum
DataPortStatus return codes.
OutPortBaseMock(const char *name, const char *data_type)
virtual size_t readable() const
Write data into the buffer.
bool subscribeInterface(const SDOPackage::NVList &properties)
Subscribe the data send notification.
void publishInterfaceProfile(SDOPackage::NVList &properties)
Publish InterfaceProfile information.
std::vector< std::string > vstring
ConnectorDataListenerType
The types of ConnectorDataListener.
#define BUFFERSTATUS_ENUM
Importing RTC::BufferStatus macro.
RingBufferMock< cdrMemoryStream > CdrRingBufferMock
void setBuffer(RTC::CdrBufferBase *buffer)
Setting outside buffer's pointer.
bool subscribeFromIor(const SDOPackage::NVList &properties)
void removeConnectorDataListener(ConnectorDataListenerType listener_type, ConnectorDataListener *listener)
Removing BufferDataListener type listener.
void test_name()
name()メソッドのテスト
RTC::InPortConsumer::ReturnCode put(const cdrMemoryStream &data)
void copyToProperties(coil::Properties &prop, const SDOPackage::NVList &nv)
Copy NVList to the Proeprties.
std::string toString(const SDOPackage::NVList &nv, const char *name)
Get NVList of specifid name as string.
virtual DataType * wptr(long int n=0)
Get the writing pointer.
void test_ConnectorListener(void)
addConnectorDataListener(), removeConnectorDataListener(), addConnectorListener(), removeConnectorListener(), isLittleEndian(), connect() メソッドのテスト
ConnectorDataListenerT class.
void registerPort(PortBase &port)
Regsiter the Port.
ConnectorList get_m_connectors()
DataListener(const char *name)
const CORBA::Any & find(const SDOPackage::NVList &nv, const char *name)
Return the value specified by name from NVList.
virtual ReturnCode advanceWptr(long int n=1)
Forward n writing pointers.
bool getConnectorProfileById(const char *id, ConnectorInfo &prof)
Getting ConnectorProfile by name.
::RTC::BufferStatus::Enum m_read_return_value
Push type connector class.
PublisherB(std::string &footPrints)
virtual ReturnCode put(const DataType &value)
Write data into the buffer.
PublisherC(std::string &footPrints)
virtual ~InPortCorbaCdrConsumerMock(void)
std::string name
Connection name.
coil::Properties get_m_properties()
void init(coil::Properties &prop)
Initializing properties.
void publishInterfaceProfile(SDOPackage::NVList &properties)
Publish InterfaceProfile information.
std::string & m_footPrints
virtual ReturnCode_t connect(ConnectorProfile &connector_profile)
[CORBA interface] Connect the Port
virtual ReturnCode advanceRptr(long int n=1)
Forward n reading pointers.
void setConnector(RTC::OutPortConnector *connector)
set Connector
bool setLevel(const char *level)
Set log level by string.
OutPortBaseTests()
Constructor.
::RTC::BufferStatus::Enum ReturnCode
prop
Organization::get_organization_property ();.
virtual PortProfile * get_port_profile()
[CORBA interface] Get the PortProfile of the Port
const char * toTypename()
void test_publishInterfaces(void)
publishInterfaces()メソッドのテスト
void test_publishInterfaces3(void)
publishInterfaces()メソッドのテスト
coil::Properties toProperties(const SDOPackage::NVList &nv)
Transform NVList to the properties.
virtual DataType * rptr(long int n=0)
Get the reading pointer.
void Destructor(AbstractClass *&obj)
Destructor template.
ConnectorListenerType
The types of ConnectorListener.
Class represents a set of properties.
void setLogger(Logger *logger)
std::vector< DataType > m_buffer
virtual void operator()(const RTC::ConnectorInfo &info, const RTC::TimedLong &data)
Virtual Callback method.
void test_init_properties()
init(),properties()メソッドのテスト
int size(void) const
Get the number of Properties.
OutPortPull type connector class.
InPortCorbaCdrConsumerMock(void)
int countLog(const std::string &msg)
virtual bool empty(void) const
Check on whether the buffer is empty.
virtual void activateInterfaces()
Activate all Port interfaces.
bool getConnectorProfileByName(const char *name, ConnectorInfo &prof)
Getting ConnectorProfile by name.
RTC::OutPortConnector * createConnector_public(const RTC::ConnectorProfile &cprof, coil::Properties &prop, RTC::OutPortProvider *provider)
void test_publishInterfaces5(void)
publishInterfaces()メソッドのテスト
void init(coil::Properties &prop)
Initializing configuration.
virtual ~OutPortCorbaCdrProviderMock(void)
CPPUNIT_TEST_SUITE_REGISTRATION(OutPortBase::OutPortBaseTests)
::OutPortBase::Logger logger
void push_back(CorbaSequence &seq, SequenceElement elem)
Push the new element back to the CORBA sequence.
std::vector< ConnectorBase * > ConnectorList
coil::GlobalFactory< PublisherBase > PublisherFactory
void deletePort(PortBase &port)
Unregister the Port registration.
bool subscribeFromRef(const SDOPackage::NVList &properties)
virtual void operator()(const RTC::ConnectorInfo &info)
Virtual Callback method.
void init(coil::Properties &prop)
Initializing properties.
virtual ReturnCode_t disconnect_all()
[CORBA interface] Disconnect the All Ports
const std::vector< OutPortConnector * > & connectors()
Connector list.
coil::vstring get_m_consumerTypes()
void test_constructor()
コンスラクタのテスト
bool publishInterface(SDOPackage::NVList &prop)
Publish interface information.
BufferBase abstract class.
InPortMock(const char *name, DataType &value)
virtual size_t writable() const
Get a writable number.
virtual ReturnCode reset()
Reset the buffer status.
virtual void tearDown()
Test finalization.
std::string & m_footPrints
virtual ~RingBufferMock(void)
virtual void deactivateInterfaces()
Deactivate all Port interfaces.
void test_connectors_getConnectorXX(void)
connectors(),getConnectorProfiles()メソッドのテスト
ConnListener(const char *name)
virtual bool full(void) const
Check on whether the buffer is full.
void setLogger(Logger *logger)
RTC's Port administration class.
~OutPortBaseTests()
Destructor.
void test_subscribeInterfaces(void)
subscribeInterfaces()メソッドのテスト
std::vector< std::string > m_log
coil::vstring get_m_providerTypes()
PublisherD(std::string &footPrints)
bool read()
It is a virtual method that is called from RTObject_impl::readAll(). This method reads out data from ...
const PortProfile & getPortProfile() const
Get the PortProfile of the Port.
coil::Properties & properties()
Get properties.
RTC::OutPortProvider * createProvider_public(RTC::ConnectorProfile &cprof, coil::Properties &prop)
void set_read_return_value(::RTC::BufferStatus::Enum value)