InPortBase.cpp
Go to the documentation of this file.
1 // -*- C++ -*-
20 #include <algorithm>
21 #include <iterator>
22 
23 #include <rtm/CORBA_SeqUtil.h>
24 #include <rtm/NVUtil.h>
25 #include <rtm/InPortBase.h>
26 #include <rtm/CdrBufferBase.h>
27 #include <rtm/InPortProvider.h>
28 #include <rtm/OutPortConsumer.h>
31 
32 namespace RTC
33 {
34 
42  InPortBase::InPortBase(const char* name, const char* data_type)
43  : PortBase(name), m_singlebuffer(true), m_thebuffer(0), m_littleEndian(true)
44  {
45  RTC_DEBUG(("Port name: %s", name));
46 
47  // PortProfile::properties を設定 RTC_DEBUG(("setting port.port_type: DataIntPort")); addProperty("port.port_type", "DataInPort"); RTC_DEBUG(("setting dataport.data_type: %s", data_type)); addProperty("dataport.data_type", data_type); addProperty("dataport.subscription_type", "Any"); } /*! * @if jp * @brief デストラクタ * @else * @brief Destructor * @endif */ InPortBase::~InPortBase() { RTC_TRACE(("~InPortBase()")); if (m_connectors.size() != 0) { RTC_ERROR(("connector.size should be 0 in InPortBase's dtor.")); for (int i(0), len(m_connectors.size()); i < len; ++i) { m_connectors[i]->disconnect(); delete m_connectors[i]; } } if (m_thebuffer != 0) { CdrBufferFactory::instance().deleteObject(m_thebuffer); if (!m_singlebuffer) { RTC_ERROR(("Although singlebuffer flag is true, the buffer != 0")); } } } /*! * @if jp * @brief プロパティの初期化 * @else * @brief Initializing properties * @endif */ void InPortBase::init(coil::Properties& prop) { RTC_TRACE(("init()")); RTC_PARANOID(("given properties:")); RTC_DEBUG_STR((prop)); // merge properties to PortProfile.properties m_properties << prop; NVList nv; NVUtil::copyFromProperties(nv, m_properties); CORBA_SeqUtil::push_back_list(m_profile.properties, nv); RTC_PARANOID(("updated properties:")); RTC_DEBUG_STR((m_properties)); if (m_singlebuffer) { RTC_DEBUG(("single buffer mode.")); m_thebuffer = CdrBufferFactory::instance().createObject("ring_buffer"); if (m_thebuffer == 0) { RTC_ERROR(("default buffer creation failed")); } } else { RTC_DEBUG(("multi buffer mode.")); } initProviders(); initConsumers(); int num(-1); if (!coil::stringTo(num, m_properties.getProperty("connection_limit","-1").c_str())) { RTC_ERROR(("invalid connection_limit value: %s", m_properties.getProperty("connection_limit").c_str())); } setConnectionLimit(num); } /*! * @if jp * @brief プロパティを取得する * @else * @brief Get properties * @endif */ coil::Properties& InPortBase::properties() { RTC_TRACE(("properties()")); return m_properties; } /*! * @if jp * @brief Connector を取得 * @else * @brief Connector list * @endif */ const std::vector<InPortConnector*>& InPortBase::connectors() { RTC_TRACE(("connectors(): size = %d", m_connectors.size())); return m_connectors; } /*! * @if jp * @brief ConnectorProfile を取得 * @else * @brief ConnectorProfile list * @endif */ ConnectorInfoList InPortBase::getConnectorProfiles() { RTC_TRACE(("getConnectorProfiles(): size = %d", m_connectors.size())); ConnectorInfoList profs; for (int i(0), len(m_connectors.size()); i < len; ++i) { profs.push_back(m_connectors[i]->profile()); } return profs; } /*! * @if jp * @brief ConnectorId を取得 * @else * @brief ConnectorId list * @endif */ coil::vstring InPortBase::getConnectorIds() { coil::vstring ids; for (int i(0), len(m_connectors.size()); i < len; ++i) { ids.push_back(m_connectors[i]->id()); } RTC_TRACE(("getConnectorIds(): %s", coil::flatten(ids).c_str())); return ids; } /*! * @if jp * @brief Connectorの名前を取得 * @else * @brief Connector name list * @endif */ coil::vstring InPortBase::getConnectorNames() { coil::vstring names; for (int i(0), len(m_connectors.size()); i < len; ++i) { names.push_back(m_connectors[i]->name()); } RTC_TRACE(("getConnectorNames(): %s", coil::flatten(names).c_str())); return names; } /*! * @if jp * @brief ConnectorをIDで取得 * @else * @brief Getting Connector by ID * @endif */ InPortConnector* InPortBase::getConnectorById(const char* id) { RTC_TRACE(("getConnectorById(id = %s)", id)); std::string sid(id); for (int i(0), len(m_connectors.size()); i < len; ++i) { if (sid == m_connectors[i]->id()) { return m_connectors[i]; } } RTC_WARN(("ConnectorProfile with the id(%s) not found.", id)); return 0; } /*! * @if jp * @brief Connectorを名前で取得 * @else * @brief Getting ConnectorProfile by name * @endif */ InPortConnector* InPortBase::getConnectorByName(const char* name) { RTC_TRACE(("getConnectorByName(name = %s)", name)); std::string sname(name); for (int i(0), len(m_connectors.size()); i < len; ++i) { if (sname == m_connectors[i]->name()) { return m_connectors[i]; } } RTC_WARN(("ConnectorProfile with the name(%s) not found.", name)); return 0; } /*! * @if jp * @brief ConnectorProfileをIDで取得 * @else * @brief Getting ConnectorProfile by name * @endif */ bool InPortBase::getConnectorProfileById(const char* id, ConnectorInfo& prof) { RTC_TRACE(("getConnectorProfileById(id = %s)", id)); InPortConnector* conn(getConnectorById(id)); if (conn == 0) { return false; } prof = conn->profile(); return true; } /*! * @if jp * @brief ConnectorProfileを名前で取得 * @else * @brief Getting ConnectorProfile by name * @endif */ bool InPortBase::getConnectorProfileByName(const char* name, ConnectorInfo& prof) { RTC_TRACE(("getConnectorProfileByName(name = %s)", name)); InPortConnector* conn(getConnectorByName(name)); if (conn == 0) { return false; } prof = conn->profile(); return true; } /*! * @if jp * @brief InPortを activates する * @else * @brief Activate all Port interfaces * @endif */ void InPortBase::activateInterfaces() { RTC_TRACE(("activateInterfaces()")); for (int i(0), len(m_connectors.size()); i < len; ++i) { m_connectors[i]->activate(); RTC_DEBUG(("activate connector: %s %s", m_connectors[i]->name(), m_connectors[i]->id())); } } /*! * @if jp * @brief 全ての Port のインターフェースを deactivates する * @else * @brief Deactivate all Port interfaces * @endif */ void InPortBase::deactivateInterfaces() { RTC_TRACE(("deactivateInterfaces()")); for (int i(0), len(m_connectors.size()); i < len; ++i) { m_connectors[i]->deactivate(); RTC_DEBUG(("deactivate connector: %s %s", m_connectors[i]->name(), m_connectors[i]->id())); } } /*! * @if jp * @brief ConnectorDataListener リスナを追加する * * バッファ書き込みまたは読み出しイベントに関連する各種リスナを設定する。 * * @else * @brief Adding ConnectorDataListener type listener * * @endif */ void InPortBase:: addConnectorDataListener(ConnectorDataListenerType type, ConnectorDataListener* listener, bool autoclean) { if (type < CONNECTOR_DATA_LISTENER_NUM) { RTC_TRACE(("addConnectorDataListener(%s)", ConnectorDataListener::toString(type))); m_listeners.connectorData_[type].addListener(listener, autoclean); return; } RTC_ERROR(("addConnectorDataListener(): Invalid listener type.")); return; } void InPortBase:: removeConnectorDataListener(ConnectorDataListenerType type, ConnectorDataListener* listener) { if (type < CONNECTOR_DATA_LISTENER_NUM) { RTC_TRACE(("removeConnectorDataListener(%s)", ConnectorDataListener::toString(type))); m_listeners.connectorData_[type].removeListener(listener); return; } RTC_ERROR(("removeConnectorDataListener(): Invalid listener type.")); return; } /*! * @if jp * @brief ConnectorListener リスナを追加する * * @else * @brief Adding ConnectorListener type listener * * @endif */ void InPortBase::addConnectorListener(ConnectorListenerType type, ConnectorListener* listener, bool autoclean) { if (type < CONNECTOR_LISTENER_NUM) { RTC_TRACE(("addConnectorListener(%s)", ConnectorListener::toString(type))); m_listeners.connector_[type].addListener(listener, autoclean); return; } RTC_ERROR(("addConnectorListener(): Invalid listener type.")); return; } void InPortBase::removeConnectorListener(ConnectorListenerType type, ConnectorListener* listener) { if (type < CONNECTOR_LISTENER_NUM) { RTC_TRACE(("removeConnectorListener(%s)", ConnectorListener::toString(type))); m_listeners.connector_[type].removeListener(listener); return; } RTC_ERROR(("removeConnectorListener(): Invalid listener type.")); } /*! * @if jp * @brief endian 設定がlittleか否か返す * @else * @brief return it whether endian setting is little * @endif */ bool InPortBase::isLittleEndian() { return m_littleEndian; } /*! * @if jp * @brief [CORBA interface] Port の接続を行う * @else * @brief [CORBA interface] Connect the Port * @endif */ ReturnCode_t InPortBase::connect(ConnectorProfile& connector_profile) throw (CORBA::SystemException) { RTC_TRACE(("InPortBase::connect()")); // endian infomation check CORBA::Long index(NVUtil::find_index(connector_profile.properties, "dataport.serializer.cdr.endian")); if (index < 0) { RTC_TRACE(("ConnectorProfile dataport.serializer.cdr.endian set.")); // endian infomation set CORBA_SeqUtil::push_back(connector_profile.properties, NVUtil::newNV("dataport.serializer.cdr.endian", "little,big")); } return PortBase::connect(connector_profile); } //============================================================ // protected interfaces //============================================================ /*! * @if jp * @brief Interface情報を公開する * @else * @brief Publish interface information * @endif */ ReturnCode_t InPortBase::publishInterfaces(ConnectorProfile& cprof) { RTC_TRACE(("publishInterfaces()")); ReturnCode_t returnvalue = _publishInterfaces(); if(returnvalue!=RTC::RTC_OK) { return returnvalue; } // prop: [port.outport]. coil::Properties prop(m_properties); { coil::Properties conn_prop; NVUtil::copyToProperties(conn_prop, cprof.properties); prop << conn_prop.getNode("dataport"); // marge ConnectorProfile /* * marge ConnectorProfile for buffer property. * e.g. * prof[buffer.write.full_policy] * << cprof[dataport.inport.buffer.write.full_policy] */ prop << conn_prop.getNode("dataport.inport"); } RTC_DEBUG(("ConnectorProfile::properties are as follows.")); RTC_DEBUG_STR((prop)); /* * ここで, ConnectorProfile からの properties がマージされたため、 * prop["dataflow_type"]: データフロータイプ * prop["interface_type"]: インターフェースタイプ * などがアクセス可能になる。 */ std::string dflow_type(prop["dataflow_type"]); coil::normalize(dflow_type); if (dflow_type == "push") { RTC_DEBUG(("dataflow_type = push .... create PushConnector")); // create InPortProvider InPortProvider* provider(createProvider(cprof, prop)); if (provider == 0) { RTC_ERROR(("InPort provider creation failed.")); return RTC::BAD_PARAMETER; } // create InPortPushConnector InPortConnector* connector(createConnector(cprof, prop, provider)); if (connector == 0) { RTC_ERROR(("PushConnector creation failed.")); return RTC::RTC_ERROR; } // connector set provider->setConnector(connector); RTC_DEBUG(("publishInterface() successfully finished.")); return RTC::RTC_OK; } else if (dflow_type == "pull") { RTC_DEBUG(("dataflow_type = pull .... do nothing")); return RTC::RTC_OK; } RTC_ERROR(("unsupported dataflow_type: %s", dflow_type.c_str())); return RTC::BAD_PARAMETER; } /*! * @if jp * @brief Interfaceに接続する * @else * @brief Subscribe to the interface * @endif */ ReturnCode_t InPortBase::subscribeInterfaces(const ConnectorProfile& cprof) { RTC_TRACE(("subscribeInterfaces()")); // prop: [port.outport]. coil::Properties prop(m_properties); { coil::Properties conn_prop; NVUtil::copyToProperties(conn_prop, cprof.properties); prop << conn_prop.getNode("dataport"); // marge ConnectorProfile /* * marge ConnectorProfile for buffer property. * e.g. * prof[buffer.write.full_policy] * << cprof[dataport.inport.buffer.write.full_policy] */ prop << conn_prop.getNode("dataport.inport"); } RTC_DEBUG(("ConnectorProfile::properties are as follows.")); RTC_DEBUG_STR((prop)); bool littleEndian; // true: little, false: big if (!checkEndian(prop, littleEndian)) { RTC_ERROR(("unsupported endian")); return RTC::UNSUPPORTED; } RTC_TRACE(("endian: %s", littleEndian ? "little" : "big")); /* * ここで, ConnectorProfile からの properties がマージされたため、 * prop["dataflow_type"]: データフロータイプ * prop["interface_type"]: インターフェースタイプ * などがアクセス可能になる。 */ std::string dflow_type(prop["dataflow_type"]); coil::normalize(dflow_type); if (dflow_type == "push") { RTC_DEBUG(("dataflow_type is push.")); // setting endian type InPortConnector* conn(getConnectorById(cprof.connector_id)); if (conn == 0) { RTC_ERROR(("specified connector not found: %s", (const char*)cprof.connector_id)); return RTC::RTC_ERROR; } conn->setEndian(littleEndian); RTC_DEBUG(("subscribeInterfaces() successfully finished.")); return RTC::RTC_OK; } else if (dflow_type == "pull") { RTC_DEBUG(("dataflow_type is pull.")); // create OutPortConsumer OutPortConsumer* consumer(createConsumer(cprof, prop)); if (consumer == 0) { return RTC::BAD_PARAMETER; } // create InPortPullConnector InPortConnector* connector(createConnector(cprof, prop, consumer)); if (connector == 0) { return RTC::RTC_ERROR; } RTC_DEBUG(("subscribeInterfaces() successfully finished.")); return RTC::RTC_OK; } RTC_ERROR(("unsupported dataflow_type: %s", dflow_type.c_str())); return RTC::BAD_PARAMETER; } /*! * @if jp * @brief Interfaceへの接続を解除する * @else * @brief Disconnect the interface connection * @endif */ void InPortBase::unsubscribeInterfaces(const ConnectorProfile& connector_profile) { RTC_TRACE(("unsubscribeInterfaces()")); std::string id(connector_profile.connector_id); RTC_PARANOID(("connector_id: %s", id.c_str())); ConnectorList::iterator it(m_connectors.begin()); while (it != m_connectors.end()) { if (id == (*it)->id()) { // Connector's dtor must call disconnect() // RtORB's bug? This causes double delete and segmeentation fault. #ifndef ORB_IS_RTORB delete *it; #endif m_connectors.erase(it); RTC_TRACE(("delete connector: %s", id.c_str())); return; } ++it; } RTC_ERROR(("specified connector not found: %s", id.c_str())); return; } /*! * @if jp * @brief InPort provider の初期化 * @else * @brief InPort provider initialization * @endif */ void InPortBase::initProviders() { RTC_TRACE(("initProviders()")); // create InPort providers InPortProviderFactory& factory(InPortProviderFactory::instance()); coil::vstring provider_types(factory.getIdentifiers()); RTC_DEBUG(("available providers: %s", coil::flatten(provider_types).c_str())); #ifndef RTC_NO_DATAPORTIF_ACTIVATION_OPTION if (m_properties.hasKey("provider_types") && coil::normalize(m_properties["provider_types"]) != "all") { RTC_DEBUG(("allowed providers: %s", m_properties["provider_types"].c_str())); coil::vstring temp_types(provider_types); provider_types.clear(); coil::vstring active_types(coil::split(m_properties["provider_types"], ",")); std::sort(temp_types.begin(), temp_types.end()); std::sort(active_types.begin(), active_types.end()); std::set_intersection(temp_types.begin(), temp_types.end(), active_types.begin(), active_types.end(), std::back_inserter(provider_types)); } #endif // InPortProvider supports "push" dataflow type if (provider_types.size() > 0) { RTC_DEBUG(("dataflow_type push is supported")); appendProperty("dataport.dataflow_type", "push"); appendProperty("dataport.interface_type", coil::flatten(provider_types).c_str()); } m_providerTypes = provider_types; } /*! * @if jp * @brief OutPort consumer の初期化 * @else * @brief OutPort consumer initialization * @endif */ void InPortBase::initConsumers() { RTC_TRACE(("initConsumers()")); // create OuPort consumers OutPortConsumerFactory& factory(OutPortConsumerFactory::instance()); coil::vstring consumer_types(factory.getIdentifiers()); RTC_DEBUG(("available consumers: %s", coil::flatten(consumer_types).c_str())); #ifndef RTC_NO_DATAPORTIF_ACTIVATION_OPTION if (m_properties.hasKey("consumer_types") && coil::normalize(m_properties["consumer_types"]) != "all") { RTC_DEBUG(("allowed consumers: %s", m_properties["consumer_types"].c_str())); coil::vstring temp_types(consumer_types); consumer_types.clear(); coil::vstring active_types(coil::split(m_properties["consumer_types"], ",")); std::sort(temp_types.begin(), temp_types.end()); std::sort(active_types.begin(), active_types.end()); std::set_intersection(temp_types.begin(), temp_types.end(), active_types.begin(), active_types.end(), std::back_inserter(consumer_types)); } #endif // OutPortConsumer supports "pull" dataflow type if (consumer_types.size() > 0) { RTC_PARANOID(("dataflow_type pull is supported")); appendProperty("dataport.dataflow_type", "pull"); appendProperty("dataport.interface_type", coil::flatten(consumer_types).c_str()); } m_consumerTypes = consumer_types; } /*! * @if jp * @brief シリアライザのエンディアンをチェックする * @else * @brief Checking endian flag of serializer * @endif */ bool InPortBase::checkEndian(const coil::Properties& prop, bool& littleEndian) { // old version check if(prop.hasKey("serializer") == NULL) { littleEndian = true; return true; } // endian type check std::string endian_type(prop.getProperty("serializer.cdr.endian", "")); RTC_DEBUG(("endian_type: %s", endian_type.c_str())); coil::normalize(endian_type); std::vector<std::string> endian(coil::split(endian_type, ",")); if(endian.empty()) { return false; } if(endian[0] == "little") { littleEndian = true; return true; } else if(endian[0] == "big") { littleEndian = false; return true; } return false; } /*! * @if jp * @brief InPort provider の生成 * @else * @brief InPort provider creation * @endif */ InPortProvider* InPortBase::createProvider(ConnectorProfile& cprof, coil::Properties& prop) { if (!prop["interface_type"].empty() && !coil::includes((coil::vstring)m_providerTypes, prop["interface_type"])) { RTC_ERROR(("no provider found")); RTC_DEBUG(("interface_type: %s", prop["interface_type"].c_str())); RTC_DEBUG(("interface_types: %s", coil::flatten(m_providerTypes).c_str())); return 0; } RTC_DEBUG(("interface_type: %s", prop["interface_type"].c_str())); InPortProvider* provider; provider = InPortProviderFactory:: instance().createObject(prop["interface_type"].c_str()); if (provider != 0) { RTC_DEBUG(("provider created")); provider->init(prop.getNode("provider")); #ifndef ORB_IS_RTORB if (!provider->publishInterface(cprof.properties)) { RTC_ERROR(("publishing interface information error")); InPortProviderFactory::instance().deleteObject(provider); return 0; } #else // ORB_IS_RTORB // RtORB's copy ctor's bug? ::SDOPackage::NVList_ptr prop_ref(cprof.properties); if (!provider->publishInterface(*prop_ref)) { RTC_ERROR(("publishing interface information error")); InPortProviderFactory::instance().deleteObject(provider); return 0; } #endif // ORB_IS_RTORB return provider; } RTC_ERROR(("provider creation failed")); return 0; } /*! * @if jp * @brief OutPort consumer の生成 * @else * @brief InPort provider creation * @endif */ OutPortConsumer* InPortBase::createConsumer(const ConnectorProfile& cprof, coil::Properties& prop) { if (!prop["interface_type"].empty() && !coil::includes((coil::vstring)m_consumerTypes, prop["interface_type"])) { RTC_ERROR(("no consumer found")); RTC_DEBUG(("interface_type: %s", prop["interface_type"].c_str())); RTC_DEBUG(("interface_types: %s", coil::flatten(m_consumerTypes).c_str())); return 0; } RTC_DEBUG(("interface_type: %s", prop["interface_type"].c_str())); OutPortConsumer* consumer; consumer = OutPortConsumerFactory:: instance().createObject(prop["interface_type"].c_str()); if (consumer != 0) { RTC_DEBUG(("consumer created")); consumer->init(prop.getNode("consumer")); if (!consumer->subscribeInterface(cprof.properties)) { RTC_ERROR(("interface subscription failed.")); OutPortConsumerFactory::instance().deleteObject(consumer); return 0; } return consumer; } RTC_ERROR(("consumer creation failed")); return 0; } /*! * @if jp * @brief InPortPushConnector の生成 * @else * @brief InPortPushConnector creation * @endif */ InPortConnector* InPortBase::createConnector(ConnectorProfile& cprof, coil::Properties& prop, InPortProvider* provider) { #ifndef ORB_IS_RTORB ConnectorInfo profile(cprof.name, cprof.connector_id, CORBA_SeqUtil::refToVstring(cprof.ports), prop); #else // ORB_IS_RTORB ConnectorInfo profile(cprof.name, cprof.connector_id, CORBA_SeqUtil:: refToVstring(RTC::PortServiceList(cprof.ports)), prop); #endif // ORB_IS_RTORB InPortConnector* connector(0); try { if (m_singlebuffer) { connector = new InPortPushConnector(profile, provider, m_listeners, m_thebuffer); } else { connector = new InPortPushConnector(profile, provider, m_listeners); } if (connector == 0) { RTC_ERROR(("old compiler? new returned 0;")); return 0; } RTC_TRACE(("InPortPushConnector created")); m_connectors.push_back(connector); RTC_PARANOID(("connector push backed: %d", m_connectors.size())); return connector; } catch (std::bad_alloc& e) { RTC_ERROR(("InPortPushConnector creation failed")); return 0; } RTC_FATAL(("never comes here: createConnector()")); return 0; } /*! * @if jp * @brief InPortPullConnector の生成 * @else * @brief InPortPullConnector creation * @endif */ InPortConnector* InPortBase::createConnector(const ConnectorProfile& cprof, coil::Properties& prop, OutPortConsumer* consumer) { #ifndef ORB_IS_RTORB ConnectorInfo profile(cprof.name, cprof.connector_id, CORBA_SeqUtil::refToVstring(cprof.ports), prop); #else // ORB_IS_RTORB ConnectorInfo profile(cprof.name, cprof.connector_id, CORBA_SeqUtil:: refToVstring(RTC::PortServiceList(cprof.ports)), prop); #endif // ORB_IS_RTORB InPortConnector* connector(0); try { if (m_singlebuffer) { connector = new InPortPullConnector(profile, consumer, m_listeners, m_thebuffer); } else { connector = new InPortPullConnector(profile, consumer, m_listeners); } if (connector == 0) { RTC_ERROR(("old compiler? new returned 0;")); return 0; } RTC_TRACE(("InPortPushConnector created")); // endian type set connector->setEndian(m_littleEndian); m_connectors.push_back(connector); RTC_PARANOID(("connector push backed: %d", m_connectors.size())); return connector; } catch (std::bad_alloc& e) { RTC_ERROR(("InPortPullConnector creation failed")); return 0; } RTC_FATAL(("never comes here: createConnector()")); return 0; } };
48  RTC_DEBUG(("setting port.port_type: DataIntPort"));
49  addProperty("port.port_type", "DataInPort");
50 
51  RTC_DEBUG(("setting dataport.data_type: %s", data_type));
52  addProperty("dataport.data_type", data_type);
53 
54  addProperty("dataport.subscription_type", "Any");
55  }
56 
65  {
66  RTC_TRACE(("~InPortBase()"));
67 
68  if (m_connectors.size() != 0)
69  {
70  RTC_ERROR(("connector.size should be 0 in InPortBase's dtor."));
71  for (int i(0), len(m_connectors.size()); i < len; ++i)
72  {
73  m_connectors[i]->disconnect();
74  delete m_connectors[i];
75  }
76  }
77 
78  if (m_thebuffer != 0)
79  {
81  if (!m_singlebuffer)
82  {
83  RTC_ERROR(("Although singlebuffer flag is true, the buffer != 0"));
84  }
85  }
86 
87  }
88 
97  {
98  RTC_TRACE(("init()"));
99  RTC_PARANOID(("given properties:"));
100  RTC_DEBUG_STR((prop));
101 
102  // merge properties to PortProfile.properties
103  m_properties << prop;
104  NVList nv;
107  RTC_PARANOID(("updated properties:"));
109 
110  if (m_singlebuffer)
111  {
112  RTC_DEBUG(("single buffer mode."));
113  m_thebuffer = CdrBufferFactory::instance().createObject("ring_buffer");
114  if (m_thebuffer == 0)
115  {
116  RTC_ERROR(("default buffer creation failed"));
117  }
118  }
119  else
120  {
121  RTC_DEBUG(("multi buffer mode."));
122  }
123 
124  initProviders();
125  initConsumers();
126  int num(-1);
127  if (!coil::stringTo(num,
128  m_properties.getProperty("connection_limit","-1").c_str()))
129  {
130  RTC_ERROR(("invalid connection_limit value: %s",
131  m_properties.getProperty("connection_limit").c_str()));
132  }
133 
134  setConnectionLimit(num);
135  }
136 
145  {
146  RTC_TRACE(("properties()"));
147 
148  return m_properties;
149  }
150 
158  const std::vector<InPortConnector*>& InPortBase::connectors()
159  {
160  RTC_TRACE(("connectors(): size = %d", m_connectors.size()));
161  return m_connectors;
162  }
163 
172  {
173  RTC_TRACE(("getConnectorProfiles(): size = %d", m_connectors.size()));
174  ConnectorInfoList profs;
175  for (int i(0), len(m_connectors.size()); i < len; ++i)
176  {
177  profs.push_back(m_connectors[i]->profile());
178  }
179  return profs;
180  }
181 
190  {
191  coil::vstring ids;
192  for (int i(0), len(m_connectors.size()); i < len; ++i)
193  {
194  ids.push_back(m_connectors[i]->id());
195  }
196  RTC_TRACE(("getConnectorIds(): %s", coil::flatten(ids).c_str()));
197  return ids;
198  }
199 
208  {
209  coil::vstring names;
210  for (int i(0), len(m_connectors.size()); i < len; ++i)
211  {
212  names.push_back(m_connectors[i]->name());
213  }
214  RTC_TRACE(("getConnectorNames(): %s", coil::flatten(names).c_str()));
215  return names;
216  }
217 
226  {
227  RTC_TRACE(("getConnectorById(id = %s)", id));
228 
229  std::string sid(id);
230  for (int i(0), len(m_connectors.size()); i < len; ++i)
231  {
232  if (sid == m_connectors[i]->id())
233  {
234  return m_connectors[i];
235  }
236  }
237  RTC_WARN(("ConnectorProfile with the id(%s) not found.", id));
238  return 0;
239  }
240 
249  {
250  RTC_TRACE(("getConnectorByName(name = %s)", name));
251 
252  std::string sname(name);
253  for (int i(0), len(m_connectors.size()); i < len; ++i)
254  {
255  if (sname == m_connectors[i]->name())
256  {
257  return m_connectors[i];
258  }
259  }
260  RTC_WARN(("ConnectorProfile with the name(%s) not found.", name));
261  return 0;
262  }
263 
272  ConnectorInfo& prof)
273  {
274  RTC_TRACE(("getConnectorProfileById(id = %s)", id));
276  if (conn == 0)
277  {
278  return false;
279  }
280  prof = conn->profile();
281  return true;
282  }
283 
292  ConnectorInfo& prof)
293  {
294  RTC_TRACE(("getConnectorProfileByName(name = %s)", name));
295  InPortConnector* conn(getConnectorByName(name));
296  if (conn == 0)
297  {
298  return false;
299  }
300  prof = conn->profile();
301  return true;
302  }
303 
304 
313  {
314  RTC_TRACE(("activateInterfaces()"));
315 
316  for (int i(0), len(m_connectors.size()); i < len; ++i)
317  {
318  m_connectors[i]->activate();
319  RTC_DEBUG(("activate connector: %s %s",
320  m_connectors[i]->name(),
321  m_connectors[i]->id()));
322  }
323  }
324 
333  {
334  RTC_TRACE(("deactivateInterfaces()"));
335 
336  for (int i(0), len(m_connectors.size()); i < len; ++i)
337  {
338  m_connectors[i]->deactivate();
339  RTC_DEBUG(("deactivate connector: %s %s",
340  m_connectors[i]->name(),
341  m_connectors[i]->id()));
342  }
343  }
344 
356  void InPortBase::
358  ConnectorDataListener* listener,
359  bool autoclean)
360  {
361  if (type < CONNECTOR_DATA_LISTENER_NUM)
362  {
363  RTC_TRACE(("addConnectorDataListener(%s)",
365  m_listeners.connectorData_[type].addListener(listener, autoclean);
366  return;
367  }
368  RTC_ERROR(("addConnectorDataListener(): Invalid listener type."));
369  return;
370  }
371 
372  void InPortBase::
374  ConnectorDataListener* listener)
375  {
376  if (type < CONNECTOR_DATA_LISTENER_NUM)
377  {
378  RTC_TRACE(("removeConnectorDataListener(%s)",
380  m_listeners.connectorData_[type].removeListener(listener);
381  return;
382  }
383  RTC_ERROR(("removeConnectorDataListener(): Invalid listener type."));
384  return;
385  }
386 
397  ConnectorListener* listener,
398  bool autoclean)
399  {
400  if (type < CONNECTOR_LISTENER_NUM)
401  {
402  RTC_TRACE(("addConnectorListener(%s)",
404  m_listeners.connector_[type].addListener(listener, autoclean);
405  return;
406  }
407  RTC_ERROR(("addConnectorListener(): Invalid listener type."));
408  return;
409  }
410 
412  ConnectorListener* listener)
413  {
414  if (type < CONNECTOR_LISTENER_NUM)
415  {
416  RTC_TRACE(("removeConnectorListener(%s)",
418  m_listeners.connector_[type].removeListener(listener);
419  return;
420  }
421  RTC_ERROR(("removeConnectorListener(): Invalid listener type."));
422  }
423 
432  {
433  return m_littleEndian;
434  }
435 
443  ReturnCode_t InPortBase::connect(ConnectorProfile& connector_profile)
444  throw (CORBA::SystemException)
445  {
446  RTC_TRACE(("InPortBase::connect()"));
447 
448  // endian infomation check
449  CORBA::Long index(NVUtil::find_index(connector_profile.properties,
450  "dataport.serializer.cdr.endian"));
451  if (index < 0)
452  {
453  RTC_TRACE(("ConnectorProfile dataport.serializer.cdr.endian set."));
454  // endian infomation set
455  CORBA_SeqUtil::push_back(connector_profile.properties,
456  NVUtil::newNV("dataport.serializer.cdr.endian", "little,big"));
457  }
458  return PortBase::connect(connector_profile);
459  }
460 
461  //============================================================
462  // protected interfaces
463  //============================================================
464 
473  {
474  RTC_TRACE(("publishInterfaces()"));
475 
476  ReturnCode_t returnvalue = _publishInterfaces();
477  if(returnvalue!=RTC::RTC_OK)
478  {
479  return returnvalue;
480  }
481 
482  // prop: [port.outport].
484  {
485  coil::Properties conn_prop;
486  NVUtil::copyToProperties(conn_prop, cprof.properties);
487  prop << conn_prop.getNode("dataport"); // marge ConnectorProfile
488  /*
489  * marge ConnectorProfile for buffer property.
490  * e.g.
491  * prof[buffer.write.full_policy]
492  * << cprof[dataport.inport.buffer.write.full_policy]
493  */
494  prop << conn_prop.getNode("dataport.inport");
495  }
496  RTC_DEBUG(("ConnectorProfile::properties are as follows."));
497  RTC_DEBUG_STR((prop));
498 
499  /*
500  * ここで, ConnectorProfile からの properties がマージされたため、
501  * prop["dataflow_type"]: データフロータイプ * prop["interface_type"]: インターフェースタイプ * などがアクセス可能になる。 */ std::string dflow_type(prop["dataflow_type"]); coil::normalize(dflow_type); if (dflow_type == "push") { RTC_DEBUG(("dataflow_type = push .... create PushConnector")); // create InPortProvider InPortProvider* provider(createProvider(cprof, prop)); if (provider == 0) { RTC_ERROR(("InPort provider creation failed.")); return RTC::BAD_PARAMETER; } // create InPortPushConnector InPortConnector* connector(createConnector(cprof, prop, provider)); if (connector == 0) { RTC_ERROR(("PushConnector creation failed.")); return RTC::RTC_ERROR; } // connector set provider->setConnector(connector); RTC_DEBUG(("publishInterface() successfully finished.")); return RTC::RTC_OK; } else if (dflow_type == "pull") { RTC_DEBUG(("dataflow_type = pull .... do nothing")); return RTC::RTC_OK; } RTC_ERROR(("unsupported dataflow_type: %s", dflow_type.c_str())); return RTC::BAD_PARAMETER; } /*! * @if jp * @brief Interfaceに接続する * @else * @brief Subscribe to the interface * @endif */ ReturnCode_t InPortBase::subscribeInterfaces(const ConnectorProfile& cprof) { RTC_TRACE(("subscribeInterfaces()")); // prop: [port.outport]. coil::Properties prop(m_properties); { coil::Properties conn_prop; NVUtil::copyToProperties(conn_prop, cprof.properties); prop << conn_prop.getNode("dataport"); // marge ConnectorProfile /* * marge ConnectorProfile for buffer property. * e.g. * prof[buffer.write.full_policy] * << cprof[dataport.inport.buffer.write.full_policy] */ prop << conn_prop.getNode("dataport.inport"); } RTC_DEBUG(("ConnectorProfile::properties are as follows.")); RTC_DEBUG_STR((prop)); bool littleEndian; // true: little, false: big if (!checkEndian(prop, littleEndian)) { RTC_ERROR(("unsupported endian")); return RTC::UNSUPPORTED; } RTC_TRACE(("endian: %s", littleEndian ? "little" : "big")); /* * ここで, ConnectorProfile からの properties がマージされたため、 * prop["dataflow_type"]: データフロータイプ * prop["interface_type"]: インターフェースタイプ * などがアクセス可能になる。 */ std::string dflow_type(prop["dataflow_type"]); coil::normalize(dflow_type); if (dflow_type == "push") { RTC_DEBUG(("dataflow_type is push.")); // setting endian type InPortConnector* conn(getConnectorById(cprof.connector_id)); if (conn == 0) { RTC_ERROR(("specified connector not found: %s", (const char*)cprof.connector_id)); return RTC::RTC_ERROR; } conn->setEndian(littleEndian); RTC_DEBUG(("subscribeInterfaces() successfully finished.")); return RTC::RTC_OK; } else if (dflow_type == "pull") { RTC_DEBUG(("dataflow_type is pull.")); // create OutPortConsumer OutPortConsumer* consumer(createConsumer(cprof, prop)); if (consumer == 0) { return RTC::BAD_PARAMETER; } // create InPortPullConnector InPortConnector* connector(createConnector(cprof, prop, consumer)); if (connector == 0) { return RTC::RTC_ERROR; } RTC_DEBUG(("subscribeInterfaces() successfully finished.")); return RTC::RTC_OK; } RTC_ERROR(("unsupported dataflow_type: %s", dflow_type.c_str())); return RTC::BAD_PARAMETER; } /*! * @if jp * @brief Interfaceへの接続を解除する * @else * @brief Disconnect the interface connection * @endif */ void InPortBase::unsubscribeInterfaces(const ConnectorProfile& connector_profile) { RTC_TRACE(("unsubscribeInterfaces()")); std::string id(connector_profile.connector_id); RTC_PARANOID(("connector_id: %s", id.c_str())); ConnectorList::iterator it(m_connectors.begin()); while (it != m_connectors.end()) { if (id == (*it)->id()) { // Connector's dtor must call disconnect() // RtORB's bug? This causes double delete and segmeentation fault. #ifndef ORB_IS_RTORB delete *it; #endif m_connectors.erase(it); RTC_TRACE(("delete connector: %s", id.c_str())); return; } ++it; } RTC_ERROR(("specified connector not found: %s", id.c_str())); return; } /*! * @if jp * @brief InPort provider の初期化 * @else * @brief InPort provider initialization * @endif */ void InPortBase::initProviders() { RTC_TRACE(("initProviders()")); // create InPort providers InPortProviderFactory& factory(InPortProviderFactory::instance()); coil::vstring provider_types(factory.getIdentifiers()); RTC_DEBUG(("available providers: %s", coil::flatten(provider_types).c_str())); #ifndef RTC_NO_DATAPORTIF_ACTIVATION_OPTION if (m_properties.hasKey("provider_types") && coil::normalize(m_properties["provider_types"]) != "all") { RTC_DEBUG(("allowed providers: %s", m_properties["provider_types"].c_str())); coil::vstring temp_types(provider_types); provider_types.clear(); coil::vstring active_types(coil::split(m_properties["provider_types"], ",")); std::sort(temp_types.begin(), temp_types.end()); std::sort(active_types.begin(), active_types.end()); std::set_intersection(temp_types.begin(), temp_types.end(), active_types.begin(), active_types.end(), std::back_inserter(provider_types)); } #endif // InPortProvider supports "push" dataflow type if (provider_types.size() > 0) { RTC_DEBUG(("dataflow_type push is supported")); appendProperty("dataport.dataflow_type", "push"); appendProperty("dataport.interface_type", coil::flatten(provider_types).c_str()); } m_providerTypes = provider_types; } /*! * @if jp * @brief OutPort consumer の初期化 * @else * @brief OutPort consumer initialization * @endif */ void InPortBase::initConsumers() { RTC_TRACE(("initConsumers()")); // create OuPort consumers OutPortConsumerFactory& factory(OutPortConsumerFactory::instance()); coil::vstring consumer_types(factory.getIdentifiers()); RTC_DEBUG(("available consumers: %s", coil::flatten(consumer_types).c_str())); #ifndef RTC_NO_DATAPORTIF_ACTIVATION_OPTION if (m_properties.hasKey("consumer_types") && coil::normalize(m_properties["consumer_types"]) != "all") { RTC_DEBUG(("allowed consumers: %s", m_properties["consumer_types"].c_str())); coil::vstring temp_types(consumer_types); consumer_types.clear(); coil::vstring active_types(coil::split(m_properties["consumer_types"], ",")); std::sort(temp_types.begin(), temp_types.end()); std::sort(active_types.begin(), active_types.end()); std::set_intersection(temp_types.begin(), temp_types.end(), active_types.begin(), active_types.end(), std::back_inserter(consumer_types)); } #endif // OutPortConsumer supports "pull" dataflow type if (consumer_types.size() > 0) { RTC_PARANOID(("dataflow_type pull is supported")); appendProperty("dataport.dataflow_type", "pull"); appendProperty("dataport.interface_type", coil::flatten(consumer_types).c_str()); } m_consumerTypes = consumer_types; } /*! * @if jp * @brief シリアライザのエンディアンをチェックする * @else * @brief Checking endian flag of serializer * @endif */ bool InPortBase::checkEndian(const coil::Properties& prop, bool& littleEndian) { // old version check if(prop.hasKey("serializer") == NULL) { littleEndian = true; return true; } // endian type check std::string endian_type(prop.getProperty("serializer.cdr.endian", "")); RTC_DEBUG(("endian_type: %s", endian_type.c_str())); coil::normalize(endian_type); std::vector<std::string> endian(coil::split(endian_type, ",")); if(endian.empty()) { return false; } if(endian[0] == "little") { littleEndian = true; return true; } else if(endian[0] == "big") { littleEndian = false; return true; } return false; } /*! * @if jp * @brief InPort provider の生成 * @else * @brief InPort provider creation * @endif */ InPortProvider* InPortBase::createProvider(ConnectorProfile& cprof, coil::Properties& prop) { if (!prop["interface_type"].empty() && !coil::includes((coil::vstring)m_providerTypes, prop["interface_type"])) { RTC_ERROR(("no provider found")); RTC_DEBUG(("interface_type: %s", prop["interface_type"].c_str())); RTC_DEBUG(("interface_types: %s", coil::flatten(m_providerTypes).c_str())); return 0; } RTC_DEBUG(("interface_type: %s", prop["interface_type"].c_str())); InPortProvider* provider; provider = InPortProviderFactory:: instance().createObject(prop["interface_type"].c_str()); if (provider != 0) { RTC_DEBUG(("provider created")); provider->init(prop.getNode("provider")); #ifndef ORB_IS_RTORB if (!provider->publishInterface(cprof.properties)) { RTC_ERROR(("publishing interface information error")); InPortProviderFactory::instance().deleteObject(provider); return 0; } #else // ORB_IS_RTORB // RtORB's copy ctor's bug? ::SDOPackage::NVList_ptr prop_ref(cprof.properties); if (!provider->publishInterface(*prop_ref)) { RTC_ERROR(("publishing interface information error")); InPortProviderFactory::instance().deleteObject(provider); return 0; } #endif // ORB_IS_RTORB return provider; } RTC_ERROR(("provider creation failed")); return 0; } /*! * @if jp * @brief OutPort consumer の生成 * @else * @brief InPort provider creation * @endif */ OutPortConsumer* InPortBase::createConsumer(const ConnectorProfile& cprof, coil::Properties& prop) { if (!prop["interface_type"].empty() && !coil::includes((coil::vstring)m_consumerTypes, prop["interface_type"])) { RTC_ERROR(("no consumer found")); RTC_DEBUG(("interface_type: %s", prop["interface_type"].c_str())); RTC_DEBUG(("interface_types: %s", coil::flatten(m_consumerTypes).c_str())); return 0; } RTC_DEBUG(("interface_type: %s", prop["interface_type"].c_str())); OutPortConsumer* consumer; consumer = OutPortConsumerFactory:: instance().createObject(prop["interface_type"].c_str()); if (consumer != 0) { RTC_DEBUG(("consumer created")); consumer->init(prop.getNode("consumer")); if (!consumer->subscribeInterface(cprof.properties)) { RTC_ERROR(("interface subscription failed.")); OutPortConsumerFactory::instance().deleteObject(consumer); return 0; } return consumer; } RTC_ERROR(("consumer creation failed")); return 0; } /*! * @if jp * @brief InPortPushConnector の生成 * @else * @brief InPortPushConnector creation * @endif */ InPortConnector* InPortBase::createConnector(ConnectorProfile& cprof, coil::Properties& prop, InPortProvider* provider) { #ifndef ORB_IS_RTORB ConnectorInfo profile(cprof.name, cprof.connector_id, CORBA_SeqUtil::refToVstring(cprof.ports), prop); #else // ORB_IS_RTORB ConnectorInfo profile(cprof.name, cprof.connector_id, CORBA_SeqUtil:: refToVstring(RTC::PortServiceList(cprof.ports)), prop); #endif // ORB_IS_RTORB InPortConnector* connector(0); try { if (m_singlebuffer) { connector = new InPortPushConnector(profile, provider, m_listeners, m_thebuffer); } else { connector = new InPortPushConnector(profile, provider, m_listeners); } if (connector == 0) { RTC_ERROR(("old compiler? new returned 0;")); return 0; } RTC_TRACE(("InPortPushConnector created")); m_connectors.push_back(connector); RTC_PARANOID(("connector push backed: %d", m_connectors.size())); return connector; } catch (std::bad_alloc& e) { RTC_ERROR(("InPortPushConnector creation failed")); return 0; } RTC_FATAL(("never comes here: createConnector()")); return 0; } /*! * @if jp * @brief InPortPullConnector の生成 * @else * @brief InPortPullConnector creation * @endif */ InPortConnector* InPortBase::createConnector(const ConnectorProfile& cprof, coil::Properties& prop, OutPortConsumer* consumer) { #ifndef ORB_IS_RTORB ConnectorInfo profile(cprof.name, cprof.connector_id, CORBA_SeqUtil::refToVstring(cprof.ports), prop); #else // ORB_IS_RTORB ConnectorInfo profile(cprof.name, cprof.connector_id, CORBA_SeqUtil:: refToVstring(RTC::PortServiceList(cprof.ports)), prop); #endif // ORB_IS_RTORB InPortConnector* connector(0); try { if (m_singlebuffer) { connector = new InPortPullConnector(profile, consumer, m_listeners, m_thebuffer); } else { connector = new InPortPullConnector(profile, consumer, m_listeners); } if (connector == 0) { RTC_ERROR(("old compiler? new returned 0;")); return 0; } RTC_TRACE(("InPortPushConnector created")); // endian type set connector->setEndian(m_littleEndian); m_connectors.push_back(connector); RTC_PARANOID(("connector push backed: %d", m_connectors.size())); return connector; } catch (std::bad_alloc& e) { RTC_ERROR(("InPortPullConnector creation failed")); return 0; } RTC_FATAL(("never comes here: createConnector()")); return 0; } };
502  * prop["interface_type"]: インターフェースタイプ * などがアクセス可能になる。 */ std::string dflow_type(prop["dataflow_type"]); coil::normalize(dflow_type); if (dflow_type == "push") { RTC_DEBUG(("dataflow_type = push .... create PushConnector")); // create InPortProvider InPortProvider* provider(createProvider(cprof, prop)); if (provider == 0) { RTC_ERROR(("InPort provider creation failed.")); return RTC::BAD_PARAMETER; } // create InPortPushConnector InPortConnector* connector(createConnector(cprof, prop, provider)); if (connector == 0) { RTC_ERROR(("PushConnector creation failed.")); return RTC::RTC_ERROR; } // connector set provider->setConnector(connector); RTC_DEBUG(("publishInterface() successfully finished.")); return RTC::RTC_OK; } else if (dflow_type == "pull") { RTC_DEBUG(("dataflow_type = pull .... do nothing")); return RTC::RTC_OK; } RTC_ERROR(("unsupported dataflow_type: %s", dflow_type.c_str())); return RTC::BAD_PARAMETER; } /*! * @if jp * @brief Interfaceに接続する * @else * @brief Subscribe to the interface * @endif */ ReturnCode_t InPortBase::subscribeInterfaces(const ConnectorProfile& cprof) { RTC_TRACE(("subscribeInterfaces()")); // prop: [port.outport]. coil::Properties prop(m_properties); { coil::Properties conn_prop; NVUtil::copyToProperties(conn_prop, cprof.properties); prop << conn_prop.getNode("dataport"); // marge ConnectorProfile /* * marge ConnectorProfile for buffer property. * e.g. * prof[buffer.write.full_policy] * << cprof[dataport.inport.buffer.write.full_policy] */ prop << conn_prop.getNode("dataport.inport"); } RTC_DEBUG(("ConnectorProfile::properties are as follows.")); RTC_DEBUG_STR((prop)); bool littleEndian; // true: little, false: big if (!checkEndian(prop, littleEndian)) { RTC_ERROR(("unsupported endian")); return RTC::UNSUPPORTED; } RTC_TRACE(("endian: %s", littleEndian ? "little" : "big")); /* * ここで, ConnectorProfile からの properties がマージされたため、 * prop["dataflow_type"]: データフロータイプ * prop["interface_type"]: インターフェースタイプ * などがアクセス可能になる。 */ std::string dflow_type(prop["dataflow_type"]); coil::normalize(dflow_type); if (dflow_type == "push") { RTC_DEBUG(("dataflow_type is push.")); // setting endian type InPortConnector* conn(getConnectorById(cprof.connector_id)); if (conn == 0) { RTC_ERROR(("specified connector not found: %s", (const char*)cprof.connector_id)); return RTC::RTC_ERROR; } conn->setEndian(littleEndian); RTC_DEBUG(("subscribeInterfaces() successfully finished.")); return RTC::RTC_OK; } else if (dflow_type == "pull") { RTC_DEBUG(("dataflow_type is pull.")); // create OutPortConsumer OutPortConsumer* consumer(createConsumer(cprof, prop)); if (consumer == 0) { return RTC::BAD_PARAMETER; } // create InPortPullConnector InPortConnector* connector(createConnector(cprof, prop, consumer)); if (connector == 0) { return RTC::RTC_ERROR; } RTC_DEBUG(("subscribeInterfaces() successfully finished.")); return RTC::RTC_OK; } RTC_ERROR(("unsupported dataflow_type: %s", dflow_type.c_str())); return RTC::BAD_PARAMETER; } /*! * @if jp * @brief Interfaceへの接続を解除する * @else * @brief Disconnect the interface connection * @endif */ void InPortBase::unsubscribeInterfaces(const ConnectorProfile& connector_profile) { RTC_TRACE(("unsubscribeInterfaces()")); std::string id(connector_profile.connector_id); RTC_PARANOID(("connector_id: %s", id.c_str())); ConnectorList::iterator it(m_connectors.begin()); while (it != m_connectors.end()) { if (id == (*it)->id()) { // Connector's dtor must call disconnect() // RtORB's bug? This causes double delete and segmeentation fault. #ifndef ORB_IS_RTORB delete *it; #endif m_connectors.erase(it); RTC_TRACE(("delete connector: %s", id.c_str())); return; } ++it; } RTC_ERROR(("specified connector not found: %s", id.c_str())); return; } /*! * @if jp * @brief InPort provider の初期化 * @else * @brief InPort provider initialization * @endif */ void InPortBase::initProviders() { RTC_TRACE(("initProviders()")); // create InPort providers InPortProviderFactory& factory(InPortProviderFactory::instance()); coil::vstring provider_types(factory.getIdentifiers()); RTC_DEBUG(("available providers: %s", coil::flatten(provider_types).c_str())); #ifndef RTC_NO_DATAPORTIF_ACTIVATION_OPTION if (m_properties.hasKey("provider_types") && coil::normalize(m_properties["provider_types"]) != "all") { RTC_DEBUG(("allowed providers: %s", m_properties["provider_types"].c_str())); coil::vstring temp_types(provider_types); provider_types.clear(); coil::vstring active_types(coil::split(m_properties["provider_types"], ",")); std::sort(temp_types.begin(), temp_types.end()); std::sort(active_types.begin(), active_types.end()); std::set_intersection(temp_types.begin(), temp_types.end(), active_types.begin(), active_types.end(), std::back_inserter(provider_types)); } #endif // InPortProvider supports "push" dataflow type if (provider_types.size() > 0) { RTC_DEBUG(("dataflow_type push is supported")); appendProperty("dataport.dataflow_type", "push"); appendProperty("dataport.interface_type", coil::flatten(provider_types).c_str()); } m_providerTypes = provider_types; } /*! * @if jp * @brief OutPort consumer の初期化 * @else * @brief OutPort consumer initialization * @endif */ void InPortBase::initConsumers() { RTC_TRACE(("initConsumers()")); // create OuPort consumers OutPortConsumerFactory& factory(OutPortConsumerFactory::instance()); coil::vstring consumer_types(factory.getIdentifiers()); RTC_DEBUG(("available consumers: %s", coil::flatten(consumer_types).c_str())); #ifndef RTC_NO_DATAPORTIF_ACTIVATION_OPTION if (m_properties.hasKey("consumer_types") && coil::normalize(m_properties["consumer_types"]) != "all") { RTC_DEBUG(("allowed consumers: %s", m_properties["consumer_types"].c_str())); coil::vstring temp_types(consumer_types); consumer_types.clear(); coil::vstring active_types(coil::split(m_properties["consumer_types"], ",")); std::sort(temp_types.begin(), temp_types.end()); std::sort(active_types.begin(), active_types.end()); std::set_intersection(temp_types.begin(), temp_types.end(), active_types.begin(), active_types.end(), std::back_inserter(consumer_types)); } #endif // OutPortConsumer supports "pull" dataflow type if (consumer_types.size() > 0) { RTC_PARANOID(("dataflow_type pull is supported")); appendProperty("dataport.dataflow_type", "pull"); appendProperty("dataport.interface_type", coil::flatten(consumer_types).c_str()); } m_consumerTypes = consumer_types; } /*! * @if jp * @brief シリアライザのエンディアンをチェックする * @else * @brief Checking endian flag of serializer * @endif */ bool InPortBase::checkEndian(const coil::Properties& prop, bool& littleEndian) { // old version check if(prop.hasKey("serializer") == NULL) { littleEndian = true; return true; } // endian type check std::string endian_type(prop.getProperty("serializer.cdr.endian", "")); RTC_DEBUG(("endian_type: %s", endian_type.c_str())); coil::normalize(endian_type); std::vector<std::string> endian(coil::split(endian_type, ",")); if(endian.empty()) { return false; } if(endian[0] == "little") { littleEndian = true; return true; } else if(endian[0] == "big") { littleEndian = false; return true; } return false; } /*! * @if jp * @brief InPort provider の生成 * @else * @brief InPort provider creation * @endif */ InPortProvider* InPortBase::createProvider(ConnectorProfile& cprof, coil::Properties& prop) { if (!prop["interface_type"].empty() && !coil::includes((coil::vstring)m_providerTypes, prop["interface_type"])) { RTC_ERROR(("no provider found")); RTC_DEBUG(("interface_type: %s", prop["interface_type"].c_str())); RTC_DEBUG(("interface_types: %s", coil::flatten(m_providerTypes).c_str())); return 0; } RTC_DEBUG(("interface_type: %s", prop["interface_type"].c_str())); InPortProvider* provider; provider = InPortProviderFactory:: instance().createObject(prop["interface_type"].c_str()); if (provider != 0) { RTC_DEBUG(("provider created")); provider->init(prop.getNode("provider")); #ifndef ORB_IS_RTORB if (!provider->publishInterface(cprof.properties)) { RTC_ERROR(("publishing interface information error")); InPortProviderFactory::instance().deleteObject(provider); return 0; } #else // ORB_IS_RTORB // RtORB's copy ctor's bug? ::SDOPackage::NVList_ptr prop_ref(cprof.properties); if (!provider->publishInterface(*prop_ref)) { RTC_ERROR(("publishing interface information error")); InPortProviderFactory::instance().deleteObject(provider); return 0; } #endif // ORB_IS_RTORB return provider; } RTC_ERROR(("provider creation failed")); return 0; } /*! * @if jp * @brief OutPort consumer の生成 * @else * @brief InPort provider creation * @endif */ OutPortConsumer* InPortBase::createConsumer(const ConnectorProfile& cprof, coil::Properties& prop) { if (!prop["interface_type"].empty() && !coil::includes((coil::vstring)m_consumerTypes, prop["interface_type"])) { RTC_ERROR(("no consumer found")); RTC_DEBUG(("interface_type: %s", prop["interface_type"].c_str())); RTC_DEBUG(("interface_types: %s", coil::flatten(m_consumerTypes).c_str())); return 0; } RTC_DEBUG(("interface_type: %s", prop["interface_type"].c_str())); OutPortConsumer* consumer; consumer = OutPortConsumerFactory:: instance().createObject(prop["interface_type"].c_str()); if (consumer != 0) { RTC_DEBUG(("consumer created")); consumer->init(prop.getNode("consumer")); if (!consumer->subscribeInterface(cprof.properties)) { RTC_ERROR(("interface subscription failed.")); OutPortConsumerFactory::instance().deleteObject(consumer); return 0; } return consumer; } RTC_ERROR(("consumer creation failed")); return 0; } /*! * @if jp * @brief InPortPushConnector の生成 * @else * @brief InPortPushConnector creation * @endif */ InPortConnector* InPortBase::createConnector(ConnectorProfile& cprof, coil::Properties& prop, InPortProvider* provider) { #ifndef ORB_IS_RTORB ConnectorInfo profile(cprof.name, cprof.connector_id, CORBA_SeqUtil::refToVstring(cprof.ports), prop); #else // ORB_IS_RTORB ConnectorInfo profile(cprof.name, cprof.connector_id, CORBA_SeqUtil:: refToVstring(RTC::PortServiceList(cprof.ports)), prop); #endif // ORB_IS_RTORB InPortConnector* connector(0); try { if (m_singlebuffer) { connector = new InPortPushConnector(profile, provider, m_listeners, m_thebuffer); } else { connector = new InPortPushConnector(profile, provider, m_listeners); } if (connector == 0) { RTC_ERROR(("old compiler? new returned 0;")); return 0; } RTC_TRACE(("InPortPushConnector created")); m_connectors.push_back(connector); RTC_PARANOID(("connector push backed: %d", m_connectors.size())); return connector; } catch (std::bad_alloc& e) { RTC_ERROR(("InPortPushConnector creation failed")); return 0; } RTC_FATAL(("never comes here: createConnector()")); return 0; } /*! * @if jp * @brief InPortPullConnector の生成 * @else * @brief InPortPullConnector creation * @endif */ InPortConnector* InPortBase::createConnector(const ConnectorProfile& cprof, coil::Properties& prop, OutPortConsumer* consumer) { #ifndef ORB_IS_RTORB ConnectorInfo profile(cprof.name, cprof.connector_id, CORBA_SeqUtil::refToVstring(cprof.ports), prop); #else // ORB_IS_RTORB ConnectorInfo profile(cprof.name, cprof.connector_id, CORBA_SeqUtil:: refToVstring(RTC::PortServiceList(cprof.ports)), prop); #endif // ORB_IS_RTORB InPortConnector* connector(0); try { if (m_singlebuffer) { connector = new InPortPullConnector(profile, consumer, m_listeners, m_thebuffer); } else { connector = new InPortPullConnector(profile, consumer, m_listeners); } if (connector == 0) { RTC_ERROR(("old compiler? new returned 0;")); return 0; } RTC_TRACE(("InPortPushConnector created")); // endian type set connector->setEndian(m_littleEndian); m_connectors.push_back(connector); RTC_PARANOID(("connector push backed: %d", m_connectors.size())); return connector; } catch (std::bad_alloc& e) { RTC_ERROR(("InPortPullConnector creation failed")); return 0; } RTC_FATAL(("never comes here: createConnector()")); return 0; } };
503  * などがアクセス可能になる。
504  */
505  std::string dflow_type(prop["dataflow_type"]);
506  coil::normalize(dflow_type);
507 
508  if (dflow_type == "push")
509  {
510  RTC_DEBUG(("dataflow_type = push .... create PushConnector"));
511 
512  // create InPortProvider
513  InPortProvider* provider(createProvider(cprof, prop));
514  if (provider == 0)
515  {
516  RTC_ERROR(("InPort provider creation failed."));
517  return RTC::BAD_PARAMETER;
518  }
519 
520  // create InPortPushConnector
521  InPortConnector* connector(createConnector(cprof, prop, provider));
522  if (connector == 0)
523  {
524  RTC_ERROR(("PushConnector creation failed."));
525  return RTC::RTC_ERROR;
526  }
527 
528  // connector set
529  provider->setConnector(connector);
530 
531  RTC_DEBUG(("publishInterface() successfully finished."));
532  return RTC::RTC_OK;
533  }
534  else if (dflow_type == "pull")
535  {
536  RTC_DEBUG(("dataflow_type = pull .... do nothing"));
537  return RTC::RTC_OK;
538  }
539 
540  RTC_ERROR(("unsupported dataflow_type: %s", dflow_type.c_str()));
541  return RTC::BAD_PARAMETER;
542  }
543 
551  ReturnCode_t InPortBase::subscribeInterfaces(const ConnectorProfile& cprof)
552  {
553  RTC_TRACE(("subscribeInterfaces()"));
554 
555  // prop: [port.outport].
557  {
558  coil::Properties conn_prop;
559  NVUtil::copyToProperties(conn_prop, cprof.properties);
560  prop << conn_prop.getNode("dataport"); // marge ConnectorProfile
561  /*
562  * marge ConnectorProfile for buffer property.
563  * e.g.
564  * prof[buffer.write.full_policy]
565  * << cprof[dataport.inport.buffer.write.full_policy]
566  */
567  prop << conn_prop.getNode("dataport.inport");
568  }
569  RTC_DEBUG(("ConnectorProfile::properties are as follows."));
570  RTC_DEBUG_STR((prop));
571 
572  bool littleEndian; // true: little, false: big
573  if (!checkEndian(prop, littleEndian))
574  {
575  RTC_ERROR(("unsupported endian"));
576  return RTC::UNSUPPORTED;
577  }
578  RTC_TRACE(("endian: %s", littleEndian ? "little" : "big"));
579 
580  /*
581  * ここで, ConnectorProfile からの properties がマージされたため、
582  * prop["dataflow_type"]: データフロータイプ * prop["interface_type"]: インターフェースタイプ * などがアクセス可能になる。 */ std::string dflow_type(prop["dataflow_type"]); coil::normalize(dflow_type); if (dflow_type == "push") { RTC_DEBUG(("dataflow_type is push.")); // setting endian type InPortConnector* conn(getConnectorById(cprof.connector_id)); if (conn == 0) { RTC_ERROR(("specified connector not found: %s", (const char*)cprof.connector_id)); return RTC::RTC_ERROR; } conn->setEndian(littleEndian); RTC_DEBUG(("subscribeInterfaces() successfully finished.")); return RTC::RTC_OK; } else if (dflow_type == "pull") { RTC_DEBUG(("dataflow_type is pull.")); // create OutPortConsumer OutPortConsumer* consumer(createConsumer(cprof, prop)); if (consumer == 0) { return RTC::BAD_PARAMETER; } // create InPortPullConnector InPortConnector* connector(createConnector(cprof, prop, consumer)); if (connector == 0) { return RTC::RTC_ERROR; } RTC_DEBUG(("subscribeInterfaces() successfully finished.")); return RTC::RTC_OK; } RTC_ERROR(("unsupported dataflow_type: %s", dflow_type.c_str())); return RTC::BAD_PARAMETER; } /*! * @if jp * @brief Interfaceへの接続を解除する * @else * @brief Disconnect the interface connection * @endif */ void InPortBase::unsubscribeInterfaces(const ConnectorProfile& connector_profile) { RTC_TRACE(("unsubscribeInterfaces()")); std::string id(connector_profile.connector_id); RTC_PARANOID(("connector_id: %s", id.c_str())); ConnectorList::iterator it(m_connectors.begin()); while (it != m_connectors.end()) { if (id == (*it)->id()) { // Connector's dtor must call disconnect() // RtORB's bug? This causes double delete and segmeentation fault. #ifndef ORB_IS_RTORB delete *it; #endif m_connectors.erase(it); RTC_TRACE(("delete connector: %s", id.c_str())); return; } ++it; } RTC_ERROR(("specified connector not found: %s", id.c_str())); return; } /*! * @if jp * @brief InPort provider の初期化 * @else * @brief InPort provider initialization * @endif */ void InPortBase::initProviders() { RTC_TRACE(("initProviders()")); // create InPort providers InPortProviderFactory& factory(InPortProviderFactory::instance()); coil::vstring provider_types(factory.getIdentifiers()); RTC_DEBUG(("available providers: %s", coil::flatten(provider_types).c_str())); #ifndef RTC_NO_DATAPORTIF_ACTIVATION_OPTION if (m_properties.hasKey("provider_types") && coil::normalize(m_properties["provider_types"]) != "all") { RTC_DEBUG(("allowed providers: %s", m_properties["provider_types"].c_str())); coil::vstring temp_types(provider_types); provider_types.clear(); coil::vstring active_types(coil::split(m_properties["provider_types"], ",")); std::sort(temp_types.begin(), temp_types.end()); std::sort(active_types.begin(), active_types.end()); std::set_intersection(temp_types.begin(), temp_types.end(), active_types.begin(), active_types.end(), std::back_inserter(provider_types)); } #endif // InPortProvider supports "push" dataflow type if (provider_types.size() > 0) { RTC_DEBUG(("dataflow_type push is supported")); appendProperty("dataport.dataflow_type", "push"); appendProperty("dataport.interface_type", coil::flatten(provider_types).c_str()); } m_providerTypes = provider_types; } /*! * @if jp * @brief OutPort consumer の初期化 * @else * @brief OutPort consumer initialization * @endif */ void InPortBase::initConsumers() { RTC_TRACE(("initConsumers()")); // create OuPort consumers OutPortConsumerFactory& factory(OutPortConsumerFactory::instance()); coil::vstring consumer_types(factory.getIdentifiers()); RTC_DEBUG(("available consumers: %s", coil::flatten(consumer_types).c_str())); #ifndef RTC_NO_DATAPORTIF_ACTIVATION_OPTION if (m_properties.hasKey("consumer_types") && coil::normalize(m_properties["consumer_types"]) != "all") { RTC_DEBUG(("allowed consumers: %s", m_properties["consumer_types"].c_str())); coil::vstring temp_types(consumer_types); consumer_types.clear(); coil::vstring active_types(coil::split(m_properties["consumer_types"], ",")); std::sort(temp_types.begin(), temp_types.end()); std::sort(active_types.begin(), active_types.end()); std::set_intersection(temp_types.begin(), temp_types.end(), active_types.begin(), active_types.end(), std::back_inserter(consumer_types)); } #endif // OutPortConsumer supports "pull" dataflow type if (consumer_types.size() > 0) { RTC_PARANOID(("dataflow_type pull is supported")); appendProperty("dataport.dataflow_type", "pull"); appendProperty("dataport.interface_type", coil::flatten(consumer_types).c_str()); } m_consumerTypes = consumer_types; } /*! * @if jp * @brief シリアライザのエンディアンをチェックする * @else * @brief Checking endian flag of serializer * @endif */ bool InPortBase::checkEndian(const coil::Properties& prop, bool& littleEndian) { // old version check if(prop.hasKey("serializer") == NULL) { littleEndian = true; return true; } // endian type check std::string endian_type(prop.getProperty("serializer.cdr.endian", "")); RTC_DEBUG(("endian_type: %s", endian_type.c_str())); coil::normalize(endian_type); std::vector<std::string> endian(coil::split(endian_type, ",")); if(endian.empty()) { return false; } if(endian[0] == "little") { littleEndian = true; return true; } else if(endian[0] == "big") { littleEndian = false; return true; } return false; } /*! * @if jp * @brief InPort provider の生成 * @else * @brief InPort provider creation * @endif */ InPortProvider* InPortBase::createProvider(ConnectorProfile& cprof, coil::Properties& prop) { if (!prop["interface_type"].empty() && !coil::includes((coil::vstring)m_providerTypes, prop["interface_type"])) { RTC_ERROR(("no provider found")); RTC_DEBUG(("interface_type: %s", prop["interface_type"].c_str())); RTC_DEBUG(("interface_types: %s", coil::flatten(m_providerTypes).c_str())); return 0; } RTC_DEBUG(("interface_type: %s", prop["interface_type"].c_str())); InPortProvider* provider; provider = InPortProviderFactory:: instance().createObject(prop["interface_type"].c_str()); if (provider != 0) { RTC_DEBUG(("provider created")); provider->init(prop.getNode("provider")); #ifndef ORB_IS_RTORB if (!provider->publishInterface(cprof.properties)) { RTC_ERROR(("publishing interface information error")); InPortProviderFactory::instance().deleteObject(provider); return 0; } #else // ORB_IS_RTORB // RtORB's copy ctor's bug? ::SDOPackage::NVList_ptr prop_ref(cprof.properties); if (!provider->publishInterface(*prop_ref)) { RTC_ERROR(("publishing interface information error")); InPortProviderFactory::instance().deleteObject(provider); return 0; } #endif // ORB_IS_RTORB return provider; } RTC_ERROR(("provider creation failed")); return 0; } /*! * @if jp * @brief OutPort consumer の生成 * @else * @brief InPort provider creation * @endif */ OutPortConsumer* InPortBase::createConsumer(const ConnectorProfile& cprof, coil::Properties& prop) { if (!prop["interface_type"].empty() && !coil::includes((coil::vstring)m_consumerTypes, prop["interface_type"])) { RTC_ERROR(("no consumer found")); RTC_DEBUG(("interface_type: %s", prop["interface_type"].c_str())); RTC_DEBUG(("interface_types: %s", coil::flatten(m_consumerTypes).c_str())); return 0; } RTC_DEBUG(("interface_type: %s", prop["interface_type"].c_str())); OutPortConsumer* consumer; consumer = OutPortConsumerFactory:: instance().createObject(prop["interface_type"].c_str()); if (consumer != 0) { RTC_DEBUG(("consumer created")); consumer->init(prop.getNode("consumer")); if (!consumer->subscribeInterface(cprof.properties)) { RTC_ERROR(("interface subscription failed.")); OutPortConsumerFactory::instance().deleteObject(consumer); return 0; } return consumer; } RTC_ERROR(("consumer creation failed")); return 0; } /*! * @if jp * @brief InPortPushConnector の生成 * @else * @brief InPortPushConnector creation * @endif */ InPortConnector* InPortBase::createConnector(ConnectorProfile& cprof, coil::Properties& prop, InPortProvider* provider) { #ifndef ORB_IS_RTORB ConnectorInfo profile(cprof.name, cprof.connector_id, CORBA_SeqUtil::refToVstring(cprof.ports), prop); #else // ORB_IS_RTORB ConnectorInfo profile(cprof.name, cprof.connector_id, CORBA_SeqUtil:: refToVstring(RTC::PortServiceList(cprof.ports)), prop); #endif // ORB_IS_RTORB InPortConnector* connector(0); try { if (m_singlebuffer) { connector = new InPortPushConnector(profile, provider, m_listeners, m_thebuffer); } else { connector = new InPortPushConnector(profile, provider, m_listeners); } if (connector == 0) { RTC_ERROR(("old compiler? new returned 0;")); return 0; } RTC_TRACE(("InPortPushConnector created")); m_connectors.push_back(connector); RTC_PARANOID(("connector push backed: %d", m_connectors.size())); return connector; } catch (std::bad_alloc& e) { RTC_ERROR(("InPortPushConnector creation failed")); return 0; } RTC_FATAL(("never comes here: createConnector()")); return 0; } /*! * @if jp * @brief InPortPullConnector の生成 * @else * @brief InPortPullConnector creation * @endif */ InPortConnector* InPortBase::createConnector(const ConnectorProfile& cprof, coil::Properties& prop, OutPortConsumer* consumer) { #ifndef ORB_IS_RTORB ConnectorInfo profile(cprof.name, cprof.connector_id, CORBA_SeqUtil::refToVstring(cprof.ports), prop); #else // ORB_IS_RTORB ConnectorInfo profile(cprof.name, cprof.connector_id, CORBA_SeqUtil:: refToVstring(RTC::PortServiceList(cprof.ports)), prop); #endif // ORB_IS_RTORB InPortConnector* connector(0); try { if (m_singlebuffer) { connector = new InPortPullConnector(profile, consumer, m_listeners, m_thebuffer); } else { connector = new InPortPullConnector(profile, consumer, m_listeners); } if (connector == 0) { RTC_ERROR(("old compiler? new returned 0;")); return 0; } RTC_TRACE(("InPortPushConnector created")); // endian type set connector->setEndian(m_littleEndian); m_connectors.push_back(connector); RTC_PARANOID(("connector push backed: %d", m_connectors.size())); return connector; } catch (std::bad_alloc& e) { RTC_ERROR(("InPortPullConnector creation failed")); return 0; } RTC_FATAL(("never comes here: createConnector()")); return 0; } };
583  * prop["interface_type"]: インターフェースタイプ * などがアクセス可能になる。 */ std::string dflow_type(prop["dataflow_type"]); coil::normalize(dflow_type); if (dflow_type == "push") { RTC_DEBUG(("dataflow_type is push.")); // setting endian type InPortConnector* conn(getConnectorById(cprof.connector_id)); if (conn == 0) { RTC_ERROR(("specified connector not found: %s", (const char*)cprof.connector_id)); return RTC::RTC_ERROR; } conn->setEndian(littleEndian); RTC_DEBUG(("subscribeInterfaces() successfully finished.")); return RTC::RTC_OK; } else if (dflow_type == "pull") { RTC_DEBUG(("dataflow_type is pull.")); // create OutPortConsumer OutPortConsumer* consumer(createConsumer(cprof, prop)); if (consumer == 0) { return RTC::BAD_PARAMETER; } // create InPortPullConnector InPortConnector* connector(createConnector(cprof, prop, consumer)); if (connector == 0) { return RTC::RTC_ERROR; } RTC_DEBUG(("subscribeInterfaces() successfully finished.")); return RTC::RTC_OK; } RTC_ERROR(("unsupported dataflow_type: %s", dflow_type.c_str())); return RTC::BAD_PARAMETER; } /*! * @if jp * @brief Interfaceへの接続を解除する * @else * @brief Disconnect the interface connection * @endif */ void InPortBase::unsubscribeInterfaces(const ConnectorProfile& connector_profile) { RTC_TRACE(("unsubscribeInterfaces()")); std::string id(connector_profile.connector_id); RTC_PARANOID(("connector_id: %s", id.c_str())); ConnectorList::iterator it(m_connectors.begin()); while (it != m_connectors.end()) { if (id == (*it)->id()) { // Connector's dtor must call disconnect() // RtORB's bug? This causes double delete and segmeentation fault. #ifndef ORB_IS_RTORB delete *it; #endif m_connectors.erase(it); RTC_TRACE(("delete connector: %s", id.c_str())); return; } ++it; } RTC_ERROR(("specified connector not found: %s", id.c_str())); return; } /*! * @if jp * @brief InPort provider の初期化 * @else * @brief InPort provider initialization * @endif */ void InPortBase::initProviders() { RTC_TRACE(("initProviders()")); // create InPort providers InPortProviderFactory& factory(InPortProviderFactory::instance()); coil::vstring provider_types(factory.getIdentifiers()); RTC_DEBUG(("available providers: %s", coil::flatten(provider_types).c_str())); #ifndef RTC_NO_DATAPORTIF_ACTIVATION_OPTION if (m_properties.hasKey("provider_types") && coil::normalize(m_properties["provider_types"]) != "all") { RTC_DEBUG(("allowed providers: %s", m_properties["provider_types"].c_str())); coil::vstring temp_types(provider_types); provider_types.clear(); coil::vstring active_types(coil::split(m_properties["provider_types"], ",")); std::sort(temp_types.begin(), temp_types.end()); std::sort(active_types.begin(), active_types.end()); std::set_intersection(temp_types.begin(), temp_types.end(), active_types.begin(), active_types.end(), std::back_inserter(provider_types)); } #endif // InPortProvider supports "push" dataflow type if (provider_types.size() > 0) { RTC_DEBUG(("dataflow_type push is supported")); appendProperty("dataport.dataflow_type", "push"); appendProperty("dataport.interface_type", coil::flatten(provider_types).c_str()); } m_providerTypes = provider_types; } /*! * @if jp * @brief OutPort consumer の初期化 * @else * @brief OutPort consumer initialization * @endif */ void InPortBase::initConsumers() { RTC_TRACE(("initConsumers()")); // create OuPort consumers OutPortConsumerFactory& factory(OutPortConsumerFactory::instance()); coil::vstring consumer_types(factory.getIdentifiers()); RTC_DEBUG(("available consumers: %s", coil::flatten(consumer_types).c_str())); #ifndef RTC_NO_DATAPORTIF_ACTIVATION_OPTION if (m_properties.hasKey("consumer_types") && coil::normalize(m_properties["consumer_types"]) != "all") { RTC_DEBUG(("allowed consumers: %s", m_properties["consumer_types"].c_str())); coil::vstring temp_types(consumer_types); consumer_types.clear(); coil::vstring active_types(coil::split(m_properties["consumer_types"], ",")); std::sort(temp_types.begin(), temp_types.end()); std::sort(active_types.begin(), active_types.end()); std::set_intersection(temp_types.begin(), temp_types.end(), active_types.begin(), active_types.end(), std::back_inserter(consumer_types)); } #endif // OutPortConsumer supports "pull" dataflow type if (consumer_types.size() > 0) { RTC_PARANOID(("dataflow_type pull is supported")); appendProperty("dataport.dataflow_type", "pull"); appendProperty("dataport.interface_type", coil::flatten(consumer_types).c_str()); } m_consumerTypes = consumer_types; } /*! * @if jp * @brief シリアライザのエンディアンをチェックする * @else * @brief Checking endian flag of serializer * @endif */ bool InPortBase::checkEndian(const coil::Properties& prop, bool& littleEndian) { // old version check if(prop.hasKey("serializer") == NULL) { littleEndian = true; return true; } // endian type check std::string endian_type(prop.getProperty("serializer.cdr.endian", "")); RTC_DEBUG(("endian_type: %s", endian_type.c_str())); coil::normalize(endian_type); std::vector<std::string> endian(coil::split(endian_type, ",")); if(endian.empty()) { return false; } if(endian[0] == "little") { littleEndian = true; return true; } else if(endian[0] == "big") { littleEndian = false; return true; } return false; } /*! * @if jp * @brief InPort provider の生成 * @else * @brief InPort provider creation * @endif */ InPortProvider* InPortBase::createProvider(ConnectorProfile& cprof, coil::Properties& prop) { if (!prop["interface_type"].empty() && !coil::includes((coil::vstring)m_providerTypes, prop["interface_type"])) { RTC_ERROR(("no provider found")); RTC_DEBUG(("interface_type: %s", prop["interface_type"].c_str())); RTC_DEBUG(("interface_types: %s", coil::flatten(m_providerTypes).c_str())); return 0; } RTC_DEBUG(("interface_type: %s", prop["interface_type"].c_str())); InPortProvider* provider; provider = InPortProviderFactory:: instance().createObject(prop["interface_type"].c_str()); if (provider != 0) { RTC_DEBUG(("provider created")); provider->init(prop.getNode("provider")); #ifndef ORB_IS_RTORB if (!provider->publishInterface(cprof.properties)) { RTC_ERROR(("publishing interface information error")); InPortProviderFactory::instance().deleteObject(provider); return 0; } #else // ORB_IS_RTORB // RtORB's copy ctor's bug? ::SDOPackage::NVList_ptr prop_ref(cprof.properties); if (!provider->publishInterface(*prop_ref)) { RTC_ERROR(("publishing interface information error")); InPortProviderFactory::instance().deleteObject(provider); return 0; } #endif // ORB_IS_RTORB return provider; } RTC_ERROR(("provider creation failed")); return 0; } /*! * @if jp * @brief OutPort consumer の生成 * @else * @brief InPort provider creation * @endif */ OutPortConsumer* InPortBase::createConsumer(const ConnectorProfile& cprof, coil::Properties& prop) { if (!prop["interface_type"].empty() && !coil::includes((coil::vstring)m_consumerTypes, prop["interface_type"])) { RTC_ERROR(("no consumer found")); RTC_DEBUG(("interface_type: %s", prop["interface_type"].c_str())); RTC_DEBUG(("interface_types: %s", coil::flatten(m_consumerTypes).c_str())); return 0; } RTC_DEBUG(("interface_type: %s", prop["interface_type"].c_str())); OutPortConsumer* consumer; consumer = OutPortConsumerFactory:: instance().createObject(prop["interface_type"].c_str()); if (consumer != 0) { RTC_DEBUG(("consumer created")); consumer->init(prop.getNode("consumer")); if (!consumer->subscribeInterface(cprof.properties)) { RTC_ERROR(("interface subscription failed.")); OutPortConsumerFactory::instance().deleteObject(consumer); return 0; } return consumer; } RTC_ERROR(("consumer creation failed")); return 0; } /*! * @if jp * @brief InPortPushConnector の生成 * @else * @brief InPortPushConnector creation * @endif */ InPortConnector* InPortBase::createConnector(ConnectorProfile& cprof, coil::Properties& prop, InPortProvider* provider) { #ifndef ORB_IS_RTORB ConnectorInfo profile(cprof.name, cprof.connector_id, CORBA_SeqUtil::refToVstring(cprof.ports), prop); #else // ORB_IS_RTORB ConnectorInfo profile(cprof.name, cprof.connector_id, CORBA_SeqUtil:: refToVstring(RTC::PortServiceList(cprof.ports)), prop); #endif // ORB_IS_RTORB InPortConnector* connector(0); try { if (m_singlebuffer) { connector = new InPortPushConnector(profile, provider, m_listeners, m_thebuffer); } else { connector = new InPortPushConnector(profile, provider, m_listeners); } if (connector == 0) { RTC_ERROR(("old compiler? new returned 0;")); return 0; } RTC_TRACE(("InPortPushConnector created")); m_connectors.push_back(connector); RTC_PARANOID(("connector push backed: %d", m_connectors.size())); return connector; } catch (std::bad_alloc& e) { RTC_ERROR(("InPortPushConnector creation failed")); return 0; } RTC_FATAL(("never comes here: createConnector()")); return 0; } /*! * @if jp * @brief InPortPullConnector の生成 * @else * @brief InPortPullConnector creation * @endif */ InPortConnector* InPortBase::createConnector(const ConnectorProfile& cprof, coil::Properties& prop, OutPortConsumer* consumer) { #ifndef ORB_IS_RTORB ConnectorInfo profile(cprof.name, cprof.connector_id, CORBA_SeqUtil::refToVstring(cprof.ports), prop); #else // ORB_IS_RTORB ConnectorInfo profile(cprof.name, cprof.connector_id, CORBA_SeqUtil:: refToVstring(RTC::PortServiceList(cprof.ports)), prop); #endif // ORB_IS_RTORB InPortConnector* connector(0); try { if (m_singlebuffer) { connector = new InPortPullConnector(profile, consumer, m_listeners, m_thebuffer); } else { connector = new InPortPullConnector(profile, consumer, m_listeners); } if (connector == 0) { RTC_ERROR(("old compiler? new returned 0;")); return 0; } RTC_TRACE(("InPortPushConnector created")); // endian type set connector->setEndian(m_littleEndian); m_connectors.push_back(connector); RTC_PARANOID(("connector push backed: %d", m_connectors.size())); return connector; } catch (std::bad_alloc& e) { RTC_ERROR(("InPortPullConnector creation failed")); return 0; } RTC_FATAL(("never comes here: createConnector()")); return 0; } };
584  * などがアクセス可能になる。
585  */
586  std::string dflow_type(prop["dataflow_type"]);
587  coil::normalize(dflow_type);
588 
589  if (dflow_type == "push")
590  {
591  RTC_DEBUG(("dataflow_type is push."));
592 
593  // setting endian type
594  InPortConnector* conn(getConnectorById(cprof.connector_id));
595  if (conn == 0)
596  {
597  RTC_ERROR(("specified connector not found: %s",
598  (const char*)cprof.connector_id));
599  return RTC::RTC_ERROR;
600  }
601  conn->setEndian(littleEndian);
602 
603  RTC_DEBUG(("subscribeInterfaces() successfully finished."));
604  return RTC::RTC_OK;
605  }
606  else if (dflow_type == "pull")
607  {
608  RTC_DEBUG(("dataflow_type is pull."));
609 
610  // create OutPortConsumer
611  OutPortConsumer* consumer(createConsumer(cprof, prop));
612  if (consumer == 0)
613  {
614  return RTC::BAD_PARAMETER;
615  }
616 
617  // create InPortPullConnector
618  InPortConnector* connector(createConnector(cprof, prop, consumer));
619  if (connector == 0)
620  {
621  return RTC::RTC_ERROR;
622  }
623 
624  RTC_DEBUG(("subscribeInterfaces() successfully finished."));
625  return RTC::RTC_OK;
626  }
627 
628  RTC_ERROR(("unsupported dataflow_type: %s", dflow_type.c_str()));
629  return RTC::BAD_PARAMETER;
630  }
631 
639  void
640  InPortBase::unsubscribeInterfaces(const ConnectorProfile& connector_profile)
641  {
642  RTC_TRACE(("unsubscribeInterfaces()"));
643 
644  std::string id(connector_profile.connector_id);
645  RTC_PARANOID(("connector_id: %s", id.c_str()));
646 
647  ConnectorList::iterator it(m_connectors.begin());
648 
649  while (it != m_connectors.end())
650  {
651  if (id == (*it)->id())
652  {
653  // Connector's dtor must call disconnect()
654 // RtORB's bug? This causes double delete and segmeentation fault.
655 #ifndef ORB_IS_RTORB
656  delete *it;
657 #endif
658  m_connectors.erase(it);
659  RTC_TRACE(("delete connector: %s", id.c_str()));
660  return;
661  }
662  ++it;
663  }
664  RTC_ERROR(("specified connector not found: %s", id.c_str()));
665  return;
666  }
667 
676  {
677  RTC_TRACE(("initProviders()"));
678 
679  // create InPort providers
681  coil::vstring provider_types(factory.getIdentifiers());
682  RTC_DEBUG(("available providers: %s",
683  coil::flatten(provider_types).c_str()));
684 
685 #ifndef RTC_NO_DATAPORTIF_ACTIVATION_OPTION
686  if (m_properties.hasKey("provider_types") &&
687  coil::normalize(m_properties["provider_types"]) != "all")
688  {
689  RTC_DEBUG(("allowed providers: %s",
690  m_properties["provider_types"].c_str()));
691 
692  coil::vstring temp_types(provider_types);
693  provider_types.clear();
695  active_types(coil::split(m_properties["provider_types"], ","));
696 
697  std::sort(temp_types.begin(), temp_types.end());
698  std::sort(active_types.begin(), active_types.end());
699  std::set_intersection(temp_types.begin(), temp_types.end(),
700  active_types.begin(), active_types.end(),
701  std::back_inserter(provider_types));
702  }
703 #endif
704 
705  // InPortProvider supports "push" dataflow type
706  if (provider_types.size() > 0)
707  {
708  RTC_DEBUG(("dataflow_type push is supported"));
709  appendProperty("dataport.dataflow_type", "push");
710  appendProperty("dataport.interface_type",
711  coil::flatten(provider_types).c_str());
712  }
713 
714  m_providerTypes = provider_types;
715  }
716 
725  {
726  RTC_TRACE(("initConsumers()"));
727 
728  // create OuPort consumers
730  coil::vstring consumer_types(factory.getIdentifiers());
731  RTC_DEBUG(("available consumers: %s",
732  coil::flatten(consumer_types).c_str()));
733 
734 #ifndef RTC_NO_DATAPORTIF_ACTIVATION_OPTION
735  if (m_properties.hasKey("consumer_types") &&
736  coil::normalize(m_properties["consumer_types"]) != "all")
737  {
738  RTC_DEBUG(("allowed consumers: %s",
739  m_properties["consumer_types"].c_str()));
740 
741  coil::vstring temp_types(consumer_types);
742  consumer_types.clear();
744  active_types(coil::split(m_properties["consumer_types"], ","));
745 
746  std::sort(temp_types.begin(), temp_types.end());
747  std::sort(active_types.begin(), active_types.end());
748  std::set_intersection(temp_types.begin(), temp_types.end(),
749  active_types.begin(), active_types.end(),
750  std::back_inserter(consumer_types));
751  }
752 #endif
753 
754  // OutPortConsumer supports "pull" dataflow type
755  if (consumer_types.size() > 0)
756  {
757  RTC_PARANOID(("dataflow_type pull is supported"));
758  appendProperty("dataport.dataflow_type", "pull");
759  appendProperty("dataport.interface_type",
760  coil::flatten(consumer_types).c_str());
761  }
762 
763  m_consumerTypes = consumer_types;
764  }
765 
774  bool& littleEndian)
775  {
776  // old version check
777  if(prop.hasKey("serializer") == NULL)
778  {
779  littleEndian = true;
780  return true;
781  }
782 
783  // endian type check
784  std::string endian_type(prop.getProperty("serializer.cdr.endian", ""));
785  RTC_DEBUG(("endian_type: %s", endian_type.c_str()));
786  coil::normalize(endian_type);
787  std::vector<std::string> endian(coil::split(endian_type, ","));
788 
789  if(endian.empty()) { return false; }
790  if(endian[0] == "little")
791  {
792  littleEndian = true;
793  return true;
794  }
795  else if(endian[0] == "big")
796  {
797  littleEndian = false;
798  return true;
799  }
800  return false;
801  }
802 
803 
804 
814  {
815  if (!prop["interface_type"].empty() &&
816  !coil::includes((coil::vstring)m_providerTypes, prop["interface_type"]))
817  {
818  RTC_ERROR(("no provider found"));
819  RTC_DEBUG(("interface_type: %s", prop["interface_type"].c_str()));
820  RTC_DEBUG(("interface_types: %s",
821  coil::flatten(m_providerTypes).c_str()));
822  return 0;
823  }
824 
825  RTC_DEBUG(("interface_type: %s", prop["interface_type"].c_str()));
827  provider = InPortProviderFactory::
828  instance().createObject(prop["interface_type"].c_str());
829 
830  if (provider != 0)
831  {
832  RTC_DEBUG(("provider created"));
833  provider->init(prop.getNode("provider"));
834 
835 #ifndef ORB_IS_RTORB
836  if (!provider->publishInterface(cprof.properties))
837  {
838  RTC_ERROR(("publishing interface information error"));
839  InPortProviderFactory::instance().deleteObject(provider);
840  return 0;
841  }
842 #else // ORB_IS_RTORB
843  // RtORB's copy ctor's bug?
844  ::SDOPackage::NVList_ptr prop_ref(cprof.properties);
845  if (!provider->publishInterface(*prop_ref))
846  {
847  RTC_ERROR(("publishing interface information error"));
848  InPortProviderFactory::instance().deleteObject(provider);
849  return 0;
850  }
851 #endif // ORB_IS_RTORB
852  return provider;
853  }
854 
855  RTC_ERROR(("provider creation failed"));
856  return 0;
857  }
858 
867  InPortBase::createConsumer(const ConnectorProfile& cprof,
869  {
870  if (!prop["interface_type"].empty() &&
871  !coil::includes((coil::vstring)m_consumerTypes, prop["interface_type"]))
872  {
873  RTC_ERROR(("no consumer found"));
874  RTC_DEBUG(("interface_type: %s", prop["interface_type"].c_str()));
875  RTC_DEBUG(("interface_types: %s",
876  coil::flatten(m_consumerTypes).c_str()));
877  return 0;
878  }
879 
880  RTC_DEBUG(("interface_type: %s", prop["interface_type"].c_str()));
881  OutPortConsumer* consumer;
882  consumer = OutPortConsumerFactory::
883  instance().createObject(prop["interface_type"].c_str());
884 
885  if (consumer != 0)
886  {
887  RTC_DEBUG(("consumer created"));
888  consumer->init(prop.getNode("consumer"));
889 
890  if (!consumer->subscribeInterface(cprof.properties))
891  {
892  RTC_ERROR(("interface subscription failed."));
893  OutPortConsumerFactory::instance().deleteObject(consumer);
894  return 0;
895  }
896 
897  return consumer;
898  }
899 
900  RTC_ERROR(("consumer creation failed"));
901  return 0;
902  }
903 
914  {
915 #ifndef ORB_IS_RTORB
916  ConnectorInfo profile(cprof.name,
917  cprof.connector_id,
918  CORBA_SeqUtil::refToVstring(cprof.ports),
919  prop);
920 #else // ORB_IS_RTORB
921  ConnectorInfo profile(cprof.name,
922  cprof.connector_id,
923  CORBA_SeqUtil::
924  refToVstring(RTC::PortServiceList(cprof.ports)),
925  prop);
926 #endif // ORB_IS_RTORB
927 
928  InPortConnector* connector(0);
929  try
930  {
931  if (m_singlebuffer)
932  {
933  connector = new InPortPushConnector(profile, provider,
934  m_listeners,
935  m_thebuffer);
936  }
937  else
938  {
939  connector = new InPortPushConnector(profile,
940  provider,
941  m_listeners);
942  }
943 
944  if (connector == 0)
945  {
946  RTC_ERROR(("old compiler? new returned 0;"));
947  return 0;
948  }
949  RTC_TRACE(("InPortPushConnector created"));
950 
951  m_connectors.push_back(connector);
952  RTC_PARANOID(("connector push backed: %d", m_connectors.size()));
953  return connector;
954  }
955  catch (std::bad_alloc& e)
956  {
957  RTC_ERROR(("InPortPushConnector creation failed"));
958  return 0;
959  }
960  RTC_FATAL(("never comes here: createConnector()"));
961  return 0;
962  }
963 
972  InPortBase::createConnector(const ConnectorProfile& cprof,
974  OutPortConsumer* consumer)
975  {
976 #ifndef ORB_IS_RTORB
977  ConnectorInfo profile(cprof.name,
978  cprof.connector_id,
979  CORBA_SeqUtil::refToVstring(cprof.ports),
980  prop);
981 #else // ORB_IS_RTORB
982  ConnectorInfo profile(cprof.name,
983  cprof.connector_id,
984  CORBA_SeqUtil::
985  refToVstring(RTC::PortServiceList(cprof.ports)),
986  prop);
987 #endif // ORB_IS_RTORB
988 
989  InPortConnector* connector(0);
990  try
991  {
992  if (m_singlebuffer)
993  {
994  connector = new InPortPullConnector(profile, consumer,
995  m_listeners,
996  m_thebuffer);
997  }
998  else
999  {
1000  connector = new InPortPullConnector(profile, consumer, m_listeners);
1001  }
1002 
1003  if (connector == 0)
1004  {
1005  RTC_ERROR(("old compiler? new returned 0;"));
1006  return 0;
1007  }
1008  RTC_TRACE(("InPortPushConnector created"));
1009 
1010  // endian type set
1011  connector->setEndian(m_littleEndian);
1012  m_connectors.push_back(connector);
1013  RTC_PARANOID(("connector push backed: %d", m_connectors.size()));
1014  return connector;
1015  }
1016  catch (std::bad_alloc& e)
1017  {
1018  RTC_ERROR(("InPortPullConnector creation failed"));
1019  return 0;
1020  }
1021  RTC_FATAL(("never comes here: createConnector()"));
1022  return 0;
1023  }
1024 
1025 };
SDOPackage::NameValue newNV(const char *name, Value value)
Create NameValue.
Definition: NVUtil.h:79
void removeListener(ConnectorListener *listener)
Remove the listener.
#define RTC_ERROR(fmt)
Error log output macro.
Definition: SystemLogger.h:422
bool checkEndian(const coil::Properties &prop, bool &littleEndian)
Checking endian flag of serializer.
Definition: InPortBase.cpp:773
std::string normalize(std::string &str)
Erase the head/tail blank and replace upper case to lower case.
Definition: stringutil.cpp:308
virtual ReturnCode_t subscribeInterfaces(const ConnectorProfile &connector_profile)
Subscribe to the interface.
Definition: InPortBase.cpp:551
coil::Properties & properties()
Get properties.
Definition: InPortBase.cpp:144
virtual void unsubscribeInterfaces(const ConnectorProfile &connector_profile)
Disconnect the interface connection.
Definition: InPortBase.cpp:640
InPortProvider class.
CdrBufferBase * m_thebuffer
Buffer.
Definition: InPortBase.h:821
RT-Component.
virtual ReturnCode_t connect(ConnectorProfile &connector_profile)
[CORBA interface] Connect the Port
Definition: InPortBase.cpp:443
bool stringTo(To &val, const char *str)
Convert the given std::string to object.
Definition: stringutil.h:597
ConnectorDataListener class.
ReturnCode_t
Definition: doil.h:53
void addListener(ConnectorDataListener *listener, bool autoclean)
Add the listener.
std::vector< std::pair< std::string, std::string > > NVList
Definition: IRTC.h:67
ConnectorListenerHolder connector_[CONNECTOR_LISTENER_NUM]
ConnectorListenerType listener array The ConnectorListenerType listener is stored.
void removeListener(ConnectorDataListener *listener)
Remove the listener.
ConnectorListeners m_listeners
ConnectorDataListener listener.
Definition: InPortBase.h:870
virtual ReturnCode_t connect(ConnectorProfile &connector_profile)
[CORBA interface] Connect the Port
Definition: PortBase.cpp:181
vstring split(const std::string &input, const std::string &delimiter, bool ignore_empty)
Split string by delimiter.
Definition: stringutil.cpp:346
std::vector< ConnectorInfo > ConnectorInfoList
OutPortConsumer class.
bool isLittleEndian()
return it whether endian setting.
Definition: InPortBase.cpp:431
void addListener(ConnectorListener *listener, bool autoclean)
Add the listener.
static GlobalFactory< AbstractClass, Identifier, Compare, Creator, Destructor > & instance()
Create instance.
Definition: Singleton.h:131
GlobalFactory template class.
virtual void deactivateInterfaces()
Deactivate all Port interfaces.
Definition: InPortBase.cpp:332
virtual const ConnectorInfo & profile()
Getting ConnectorInfo.
coil::vstring m_providerTypes
Available providers.
Definition: InPortBase.h:837
coil::vstring m_consumerTypes
Available consumers.
Definition: InPortBase.h:845
virtual void activateInterfaces()
Activate all Port interfaces.
Definition: InPortBase.cpp:312
virtual ~InPortBase(void)
Destructor.
Definition: InPortBase.cpp:64
#define RTC_WARN(fmt)
Warning log output macro.
Definition: SystemLogger.h:444
Properties * hasKey(const char *key) const
Check whether key exists in the children.
Definition: Properties.cpp:522
#define RTC_FATAL(fmt)
Error log output macro.
Definition: SystemLogger.h:400
#define RTC_DEBUG_STR(str)
Definition: SystemLogger.h:489
#define RTC_PARANOID(fmt)
Paranoid level log output macro.
Definition: SystemLogger.h:555
std::vector< Identifier > getIdentifiers()
Get factory ID list.
std::vector< std::string > vstring
Definition: stringutil.h:37
ConnectorDataListenerType
The types of ConnectorDataListener.
InPortConnector * createConnector(ConnectorProfile &cprof, coil::Properties &prop, InPortProvider *provider)
InPortPushConnector creation.
Definition: InPortBase.cpp:912
const CORBA::Long find_index(const SDOPackage::NVList &nv, const char *name)
Return the index of element specified by name from NVList.
Definition: NVUtil.cpp:227
static const char * toString(ConnectorListenerType type)
Convert ConnectorListenerType into the string.
bool m_littleEndian
Connected Endian.
Definition: InPortBase.h:861
InPortConnector * getConnectorByName(const char *name)
Getting Connector by name.
Definition: InPortBase.cpp:248
ConnectorDataListenerHolder connectorData_[CONNECTOR_DATA_LISTENER_NUM]
ConnectorDataListenerType listener array The ConnectorDataListenerType listener is stored...
virtual bool subscribeInterface(const SDOPackage::NVList &properties)=0
Subscribe the data receive notification.
void appendProperty(const char *key, const char *value)
Append NameValue data to PortProfile&#39;s properties.
Definition: PortBase.h:1907
#define RTC_DEBUG(fmt)
Debug level log output macro.
Definition: SystemLogger.h:488
const std::string & getProperty(const std::string &key) const
Search for the property with the specified key in this property.
Definition: Properties.cpp:160
std::string flatten(vstring sv)
Create CSV file from the given string list.
Definition: stringutil.cpp:554
void copyToProperties(coil::Properties &prop, const SDOPackage::NVList &nv)
Copy NVList to the Proeprties.
Definition: NVUtil.cpp:137
#define RTC_TRACE(fmt)
void removeConnectorDataListener(ConnectorDataListenerType listener_type, ConnectorDataListener *listener)
Removing BufferDataListener type listener.
Definition: InPortBase.cpp:373
list index
Definition: rtimages.py:10
InPortBase(const char *name, const char *data_type)
Constructor.
Definition: InPortBase.cpp:42
NameValue and NVList utility functions.
virtual void setConnector(InPortConnector *connector)=0
set Connector
bool getConnectorProfileById(const char *id, ConnectorInfo &prof)
Getting ConnectorProfile by name.
Definition: InPortBase.cpp:271
ConnectorInfoList getConnectorProfiles()
ConnectorProfile list.
Definition: InPortBase.cpp:171
void initProviders()
InPort provider initialization.
Definition: InPortBase.cpp:675
CORBA sequence utility template functions.
virtual void setEndian(const bool endian_type)
Setting an endian type.
Push type connector class.
coil::vstring getConnectorIds()
ConnectorId list.
Definition: InPortBase.cpp:189
bool getConnectorProfileByName(const char *name, ConnectorInfo &prof)
Getting ConnectorProfile by name.
Definition: InPortBase.cpp:291
virtual void init(coil::Properties &prop)=0
Initializing configuration.
void addConnectorListener(ConnectorListenerType callback_type, ConnectorListener *listener, bool autoclean=true)
Adding ConnectorListener type listener.
Definition: InPortBase.cpp:396
const std::vector< InPortConnector * > & connectors()
Connector list.
Definition: InPortBase.cpp:158
prop
Organization::get_organization_property ();.
RTC::Port implementation for InPort.
void initConsumers()
OutPort consumer initialization.
Definition: InPortBase.cpp:724
PortProfile m_profile
PortProfile of the Port.
Definition: PortBase.h:2070
ConnectorListenerType
The types of ConnectorListener.
Class represents a set of properties.
Definition: Properties.h:101
void removeConnectorListener(ConnectorListenerType callback_type, ConnectorListener *listener)
Removing BufferDataListener type listener.
Definition: InPortBase.cpp:411
static const char * toString(ConnectorDataListenerType type)
Convert ConnectorDataListenerType into the string.
coil::Properties m_properties
Properties.
Definition: InPortBase.h:829
std::vector< IPortService * > PortServiceList
Definition: IPortService.h:39
virtual bool publishInterface(SDOPackage::NVList &properties)
Publish interface information.
virtual void init(coil::Properties &prop)=0
Initializing configuration.
InPortPull type connector class.
void push_back_list(CorbaSequence &seq1, const CorbaSequence &seq2)
Merge the elements of the CORBA sequence.
void push_back(CorbaSequence &seq, SequenceElement elem)
Push the new element back to the CORBA sequence.
OutPortConsumer abstract class.
void copyFromProperties(SDOPackage::NVList &nv, const coil::Properties &prop)
Copy the properties to NVList.
Definition: NVUtil.cpp:108
coil::vstring getConnectorNames()
Connector name list.
Definition: InPortBase.cpp:207
Properties & getNode(const std::string &key)
Get node of properties.
Definition: Properties.cpp:460
InPortConnector * getConnectorById(const char *id)
Getting ConnectorProfile by ID.
Definition: InPortBase.cpp:225
void init(coil::Properties &prop)
Initializing properties.
Definition: InPortBase.cpp:96
bool m_singlebuffer
Buffer mode.
Definition: InPortBase.h:813
bool includes(const vstring &list, std::string value, bool ignore_case)
Include if a string is included in string list.
Definition: stringutil.cpp:437
OutPortConsumer * createConsumer(const ConnectorProfile &cprof, coil::Properties &prop)
InPort provider creation.
Definition: InPortBase.cpp:867
coil::vstring refToVstring(const CorbaRefSequence &objlist)
void addProperty(const char *key, ValueType value)
Add NameValue data to PortProfile&#39;s properties.
Definition: PortBase.h:1876
CORBA IOR helper functions.
void addConnectorDataListener(ConnectorDataListenerType listener_type, ConnectorDataListener *listener, bool autoclean=true)
Adding BufferDataListener type listener.
Definition: InPortBase.cpp:357
ConnectorList m_connectors
Connection list.
Definition: InPortBase.h:853
virtual ReturnCode_t _publishInterfaces(void)
Publish interface information.
Definition: PortBase.cpp:315
virtual void setConnectionLimit(int limit_value)
Set the maximum number of connections.
Definition: PortBase.cpp:700
InPortProvider * createProvider(ConnectorProfile &cprof, coil::Properties &prop)
InPort provider creation.
Definition: InPortBase.cpp:813
virtual ReturnCode_t publishInterfaces(ConnectorProfile &connector_profile)
Publish interface information.
Definition: InPortBase.cpp:472


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Mon Feb 28 2022 23:00:43