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()")); m_properties << prop; 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  m_properties << prop;
100  if (m_singlebuffer)
101  {
102  RTC_DEBUG(("single buffer mode."));
103  m_thebuffer = CdrBufferFactory::instance().createObject("ring_buffer");
104  if (m_thebuffer == 0)
105  {
106  RTC_ERROR(("default buffer creation failed"));
107  }
108  }
109  else
110  {
111  RTC_DEBUG(("multi buffer mode."));
112  }
113 
114  initProviders();
115  initConsumers();
116  int num(-1);
117  if (!coil::stringTo(num,
118  m_properties.getProperty("connection_limit","-1").c_str()))
119  {
120  RTC_ERROR(("invalid connection_limit value: %s",
121  m_properties.getProperty("connection_limit").c_str()));
122  }
123 
124  setConnectionLimit(num);
125  }
126 
135  {
136  RTC_TRACE(("properties()"));
137 
138  return m_properties;
139  }
140 
148  const std::vector<InPortConnector*>& InPortBase::connectors()
149  {
150  RTC_TRACE(("connectors(): size = %d", m_connectors.size()));
151  return m_connectors;
152  }
153 
162  {
163  RTC_TRACE(("getConnectorProfiles(): size = %d", m_connectors.size()));
164  ConnectorInfoList profs;
165  for (int i(0), len(m_connectors.size()); i < len; ++i)
166  {
167  profs.push_back(m_connectors[i]->profile());
168  }
169  return profs;
170  }
171 
180  {
181  coil::vstring ids;
182  for (int i(0), len(m_connectors.size()); i < len; ++i)
183  {
184  ids.push_back(m_connectors[i]->id());
185  }
186  RTC_TRACE(("getConnectorIds(): %s", coil::flatten(ids).c_str()));
187  return ids;
188  }
189 
198  {
199  coil::vstring names;
200  for (int i(0), len(m_connectors.size()); i < len; ++i)
201  {
202  names.push_back(m_connectors[i]->name());
203  }
204  RTC_TRACE(("getConnectorNames(): %s", coil::flatten(names).c_str()));
205  return names;
206  }
207 
216  {
217  RTC_TRACE(("getConnectorById(id = %s)", id));
218 
219  std::string sid(id);
220  for (int i(0), len(m_connectors.size()); i < len; ++i)
221  {
222  if (sid == m_connectors[i]->id())
223  {
224  return m_connectors[i];
225  }
226  }
227  RTC_WARN(("ConnectorProfile with the id(%s) not found.", id));
228  return 0;
229  }
230 
239  {
240  RTC_TRACE(("getConnectorByName(name = %s)", name));
241 
242  std::string sname(name);
243  for (int i(0), len(m_connectors.size()); i < len; ++i)
244  {
245  if (sname == m_connectors[i]->name())
246  {
247  return m_connectors[i];
248  }
249  }
250  RTC_WARN(("ConnectorProfile with the name(%s) not found.", name));
251  return 0;
252  }
253 
262  ConnectorInfo& prof)
263  {
264  RTC_TRACE(("getConnectorProfileById(id = %s)", id));
266  if (conn == 0)
267  {
268  return false;
269  }
270  prof = conn->profile();
271  return true;
272  }
273 
282  ConnectorInfo& prof)
283  {
284  RTC_TRACE(("getConnectorProfileByName(name = %s)", name));
285  InPortConnector* conn(getConnectorByName(name));
286  if (conn == 0)
287  {
288  return false;
289  }
290  prof = conn->profile();
291  return true;
292  }
293 
294 
303  {
304  RTC_TRACE(("activateInterfaces()"));
305 
306  for (int i(0), len(m_connectors.size()); i < len; ++i)
307  {
308  m_connectors[i]->activate();
309  RTC_DEBUG(("activate connector: %s %s",
310  m_connectors[i]->name(),
311  m_connectors[i]->id()));
312  }
313  }
314 
323  {
324  RTC_TRACE(("deactivateInterfaces()"));
325 
326  for (int i(0), len(m_connectors.size()); i < len; ++i)
327  {
328  m_connectors[i]->deactivate();
329  RTC_DEBUG(("deactivate connector: %s %s",
330  m_connectors[i]->name(),
331  m_connectors[i]->id()));
332  }
333  }
334 
346  void InPortBase::
348  ConnectorDataListener* listener,
349  bool autoclean)
350  {
351  if (type < CONNECTOR_DATA_LISTENER_NUM)
352  {
353  RTC_TRACE(("addConnectorDataListener(%s)",
355  m_listeners.connectorData_[type].addListener(listener, autoclean);
356  return;
357  }
358  RTC_ERROR(("addConnectorDataListener(): Invalid listener type."));
359  return;
360  }
361 
362  void InPortBase::
364  ConnectorDataListener* listener)
365  {
366  if (type < CONNECTOR_DATA_LISTENER_NUM)
367  {
368  RTC_TRACE(("removeConnectorDataListener(%s)",
370  m_listeners.connectorData_[type].removeListener(listener);
371  return;
372  }
373  RTC_ERROR(("removeConnectorDataListener(): Invalid listener type."));
374  return;
375  }
376 
387  ConnectorListener* listener,
388  bool autoclean)
389  {
390  if (type < CONNECTOR_LISTENER_NUM)
391  {
392  RTC_TRACE(("addConnectorListener(%s)",
394  m_listeners.connector_[type].addListener(listener, autoclean);
395  return;
396  }
397  RTC_ERROR(("addConnectorListener(): Invalid listener type."));
398  return;
399  }
400 
402  ConnectorListener* listener)
403  {
404  if (type < CONNECTOR_LISTENER_NUM)
405  {
406  RTC_TRACE(("removeConnectorListener(%s)",
408  m_listeners.connector_[type].removeListener(listener);
409  return;
410  }
411  RTC_ERROR(("removeConnectorListener(): Invalid listener type."));
412  }
413 
422  {
423  return m_littleEndian;
424  }
425 
433  ReturnCode_t InPortBase::connect(ConnectorProfile& connector_profile)
434  throw (CORBA::SystemException)
435  {
436  RTC_TRACE(("InPortBase::connect()"));
437 
438  // endian infomation check
439  CORBA::Long index(NVUtil::find_index(connector_profile.properties,
440  "dataport.serializer.cdr.endian"));
441  if (index < 0)
442  {
443  RTC_TRACE(("ConnectorProfile dataport.serializer.cdr.endian set."));
444  // endian infomation set
445  CORBA_SeqUtil::push_back(connector_profile.properties,
446  NVUtil::newNV("dataport.serializer.cdr.endian", "little,big"));
447  }
448  return PortBase::connect(connector_profile);
449  }
450 
451  //============================================================
452  // protected interfaces
453  //============================================================
454 
463  {
464  RTC_TRACE(("publishInterfaces()"));
465 
466  ReturnCode_t returnvalue = _publishInterfaces();
467  if(returnvalue!=RTC::RTC_OK)
468  {
469  return returnvalue;
470  }
471 
472  // prop: [port.outport].
474  {
475  coil::Properties conn_prop;
476  NVUtil::copyToProperties(conn_prop, cprof.properties);
477  prop << conn_prop.getNode("dataport"); // marge ConnectorProfile
478  /*
479  * marge ConnectorProfile for buffer property.
480  * e.g.
481  * prof[buffer.write.full_policy]
482  * << cprof[dataport.inport.buffer.write.full_policy]
483  */
484  prop << conn_prop.getNode("dataport.inport");
485  }
486  RTC_DEBUG(("ConnectorProfile::properties are as follows."));
487  RTC_DEBUG_STR((prop));
488 
489  /*
490  * ここで, ConnectorProfile からの properties がマージされたため、
491  * 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; } };
492  * 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; } };
493  * などがアクセス可能になる。
494  */
495  std::string dflow_type(prop["dataflow_type"]);
496  coil::normalize(dflow_type);
497 
498  if (dflow_type == "push")
499  {
500  RTC_DEBUG(("dataflow_type = push .... create PushConnector"));
501 
502  // create InPortProvider
503  InPortProvider* provider(createProvider(cprof, prop));
504  if (provider == 0)
505  {
506  RTC_ERROR(("InPort provider creation failed."));
507  return RTC::BAD_PARAMETER;
508  }
509 
510  // create InPortPushConnector
511  InPortConnector* connector(createConnector(cprof, prop, provider));
512  if (connector == 0)
513  {
514  RTC_ERROR(("PushConnector creation failed."));
515  return RTC::RTC_ERROR;
516  }
517 
518  // connector set
519  provider->setConnector(connector);
520 
521  RTC_DEBUG(("publishInterface() successfully finished."));
522  return RTC::RTC_OK;
523  }
524  else if (dflow_type == "pull")
525  {
526  RTC_DEBUG(("dataflow_type = pull .... do nothing"));
527  return RTC::RTC_OK;
528  }
529 
530  RTC_ERROR(("unsupported dataflow_type: %s", dflow_type.c_str()));
531  return RTC::BAD_PARAMETER;
532  }
533 
541  ReturnCode_t InPortBase::subscribeInterfaces(const ConnectorProfile& cprof)
542  {
543  RTC_TRACE(("subscribeInterfaces()"));
544 
545  // prop: [port.outport].
547  {
548  coil::Properties conn_prop;
549  NVUtil::copyToProperties(conn_prop, cprof.properties);
550  prop << conn_prop.getNode("dataport"); // marge ConnectorProfile
551  /*
552  * marge ConnectorProfile for buffer property.
553  * e.g.
554  * prof[buffer.write.full_policy]
555  * << cprof[dataport.inport.buffer.write.full_policy]
556  */
557  prop << conn_prop.getNode("dataport.inport");
558  }
559  RTC_DEBUG(("ConnectorProfile::properties are as follows."));
560  RTC_DEBUG_STR((prop));
561 
562  bool littleEndian; // true: little, false: big
563  if (!checkEndian(prop, littleEndian))
564  {
565  RTC_ERROR(("unsupported endian"));
566  return RTC::UNSUPPORTED;
567  }
568  RTC_TRACE(("endian: %s", littleEndian ? "little" : "big"));
569 
570  /*
571  * ここで, ConnectorProfile からの properties がマージされたため、
572  * 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; } };
573  * 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; } };
574  * などがアクセス可能になる。
575  */
576  std::string dflow_type(prop["dataflow_type"]);
577  coil::normalize(dflow_type);
578 
579  if (dflow_type == "push")
580  {
581  RTC_DEBUG(("dataflow_type is push."));
582 
583  // setting endian type
584  InPortConnector* conn(getConnectorById(cprof.connector_id));
585  if (conn == 0)
586  {
587  RTC_ERROR(("specified connector not found: %s",
588  (const char*)cprof.connector_id));
589  return RTC::RTC_ERROR;
590  }
591  conn->setEndian(littleEndian);
592 
593  RTC_DEBUG(("subscribeInterfaces() successfully finished."));
594  return RTC::RTC_OK;
595  }
596  else if (dflow_type == "pull")
597  {
598  RTC_DEBUG(("dataflow_type is pull."));
599 
600  // create OutPortConsumer
601  OutPortConsumer* consumer(createConsumer(cprof, prop));
602  if (consumer == 0)
603  {
604  return RTC::BAD_PARAMETER;
605  }
606 
607  // create InPortPullConnector
608  InPortConnector* connector(createConnector(cprof, prop, consumer));
609  if (connector == 0)
610  {
611  return RTC::RTC_ERROR;
612  }
613 
614  RTC_DEBUG(("subscribeInterfaces() successfully finished."));
615  return RTC::RTC_OK;
616  }
617 
618  RTC_ERROR(("unsupported dataflow_type: %s", dflow_type.c_str()));
619  return RTC::BAD_PARAMETER;
620  }
621 
629  void
630  InPortBase::unsubscribeInterfaces(const ConnectorProfile& connector_profile)
631  {
632  RTC_TRACE(("unsubscribeInterfaces()"));
633 
634  std::string id(connector_profile.connector_id);
635  RTC_PARANOID(("connector_id: %s", id.c_str()));
636 
637  ConnectorList::iterator it(m_connectors.begin());
638 
639  while (it != m_connectors.end())
640  {
641  if (id == (*it)->id())
642  {
643  // Connector's dtor must call disconnect()
644 // RtORB's bug? This causes double delete and segmeentation fault.
645 #ifndef ORB_IS_RTORB
646  delete *it;
647 #endif
648  m_connectors.erase(it);
649  RTC_TRACE(("delete connector: %s", id.c_str()));
650  return;
651  }
652  ++it;
653  }
654  RTC_ERROR(("specified connector not found: %s", id.c_str()));
655  return;
656  }
657 
666  {
667  RTC_TRACE(("initProviders()"));
668 
669  // create InPort providers
671  coil::vstring provider_types(factory.getIdentifiers());
672  RTC_DEBUG(("available providers: %s",
673  coil::flatten(provider_types).c_str()));
674 
675 #ifndef RTC_NO_DATAPORTIF_ACTIVATION_OPTION
676  if (m_properties.hasKey("provider_types") &&
677  coil::normalize(m_properties["provider_types"]) != "all")
678  {
679  RTC_DEBUG(("allowed providers: %s",
680  m_properties["provider_types"].c_str()));
681 
682  coil::vstring temp_types(provider_types);
683  provider_types.clear();
685  active_types(coil::split(m_properties["provider_types"], ","));
686 
687  std::sort(temp_types.begin(), temp_types.end());
688  std::sort(active_types.begin(), active_types.end());
689  std::set_intersection(temp_types.begin(), temp_types.end(),
690  active_types.begin(), active_types.end(),
691  std::back_inserter(provider_types));
692  }
693 #endif
694 
695  // InPortProvider supports "push" dataflow type
696  if (provider_types.size() > 0)
697  {
698  RTC_DEBUG(("dataflow_type push is supported"));
699  appendProperty("dataport.dataflow_type", "push");
700  appendProperty("dataport.interface_type",
701  coil::flatten(provider_types).c_str());
702  }
703 
704  m_providerTypes = provider_types;
705  }
706 
715  {
716  RTC_TRACE(("initConsumers()"));
717 
718  // create OuPort consumers
720  coil::vstring consumer_types(factory.getIdentifiers());
721  RTC_DEBUG(("available consumers: %s",
722  coil::flatten(consumer_types).c_str()));
723 
724 #ifndef RTC_NO_DATAPORTIF_ACTIVATION_OPTION
725  if (m_properties.hasKey("consumer_types") &&
726  coil::normalize(m_properties["consumer_types"]) != "all")
727  {
728  RTC_DEBUG(("allowed consumers: %s",
729  m_properties["consumer_types"].c_str()));
730 
731  coil::vstring temp_types(consumer_types);
732  consumer_types.clear();
734  active_types(coil::split(m_properties["consumer_types"], ","));
735 
736  std::sort(temp_types.begin(), temp_types.end());
737  std::sort(active_types.begin(), active_types.end());
738  std::set_intersection(temp_types.begin(), temp_types.end(),
739  active_types.begin(), active_types.end(),
740  std::back_inserter(consumer_types));
741  }
742 #endif
743 
744  // OutPortConsumer supports "pull" dataflow type
745  if (consumer_types.size() > 0)
746  {
747  RTC_PARANOID(("dataflow_type pull is supported"));
748  appendProperty("dataport.dataflow_type", "pull");
749  appendProperty("dataport.interface_type",
750  coil::flatten(consumer_types).c_str());
751  }
752 
753  m_consumerTypes = consumer_types;
754  }
755 
764  bool& littleEndian)
765  {
766  // old version check
767  if(prop.hasKey("serializer") == NULL)
768  {
769  littleEndian = true;
770  return true;
771  }
772 
773  // endian type check
774  std::string endian_type(prop.getProperty("serializer.cdr.endian", ""));
775  RTC_DEBUG(("endian_type: %s", endian_type.c_str()));
776  coil::normalize(endian_type);
777  std::vector<std::string> endian(coil::split(endian_type, ","));
778 
779  if(endian.empty()) { return false; }
780  if(endian[0] == "little")
781  {
782  littleEndian = true;
783  return true;
784  }
785  else if(endian[0] == "big")
786  {
787  littleEndian = false;
788  return true;
789  }
790  return false;
791  }
792 
793 
794 
804  {
805  if (!prop["interface_type"].empty() &&
806  !coil::includes((coil::vstring)m_providerTypes, prop["interface_type"]))
807  {
808  RTC_ERROR(("no provider found"));
809  RTC_DEBUG(("interface_type: %s", prop["interface_type"].c_str()));
810  RTC_DEBUG(("interface_types: %s",
811  coil::flatten(m_providerTypes).c_str()));
812  return 0;
813  }
814 
815  RTC_DEBUG(("interface_type: %s", prop["interface_type"].c_str()));
817  provider = InPortProviderFactory::
818  instance().createObject(prop["interface_type"].c_str());
819 
820  if (provider != 0)
821  {
822  RTC_DEBUG(("provider created"));
823  provider->init(prop.getNode("provider"));
824 
825 #ifndef ORB_IS_RTORB
826  if (!provider->publishInterface(cprof.properties))
827  {
828  RTC_ERROR(("publishing interface information error"));
829  InPortProviderFactory::instance().deleteObject(provider);
830  return 0;
831  }
832 #else // ORB_IS_RTORB
833  // RtORB's copy ctor's bug?
834  ::SDOPackage::NVList_ptr prop_ref(cprof.properties);
835  if (!provider->publishInterface(*prop_ref))
836  {
837  RTC_ERROR(("publishing interface information error"));
838  InPortProviderFactory::instance().deleteObject(provider);
839  return 0;
840  }
841 #endif // ORB_IS_RTORB
842  return provider;
843  }
844 
845  RTC_ERROR(("provider creation failed"));
846  return 0;
847  }
848 
857  InPortBase::createConsumer(const ConnectorProfile& cprof,
859  {
860  if (!prop["interface_type"].empty() &&
861  !coil::includes((coil::vstring)m_consumerTypes, prop["interface_type"]))
862  {
863  RTC_ERROR(("no consumer found"));
864  RTC_DEBUG(("interface_type: %s", prop["interface_type"].c_str()));
865  RTC_DEBUG(("interface_types: %s",
866  coil::flatten(m_consumerTypes).c_str()));
867  return 0;
868  }
869 
870  RTC_DEBUG(("interface_type: %s", prop["interface_type"].c_str()));
871  OutPortConsumer* consumer;
872  consumer = OutPortConsumerFactory::
873  instance().createObject(prop["interface_type"].c_str());
874 
875  if (consumer != 0)
876  {
877  RTC_DEBUG(("consumer created"));
878  consumer->init(prop.getNode("consumer"));
879 
880  if (!consumer->subscribeInterface(cprof.properties))
881  {
882  RTC_ERROR(("interface subscription failed."));
883  OutPortConsumerFactory::instance().deleteObject(consumer);
884  return 0;
885  }
886 
887  return consumer;
888  }
889 
890  RTC_ERROR(("consumer creation failed"));
891  return 0;
892  }
893 
904  {
905 #ifndef ORB_IS_RTORB
906  ConnectorInfo profile(cprof.name,
907  cprof.connector_id,
908  CORBA_SeqUtil::refToVstring(cprof.ports),
909  prop);
910 #else // ORB_IS_RTORB
911  ConnectorInfo profile(cprof.name,
912  cprof.connector_id,
913  CORBA_SeqUtil::
914  refToVstring(RTC::PortServiceList(cprof.ports)),
915  prop);
916 #endif // ORB_IS_RTORB
917 
918  InPortConnector* connector(0);
919  try
920  {
921  if (m_singlebuffer)
922  {
923  connector = new InPortPushConnector(profile, provider,
924  m_listeners,
925  m_thebuffer);
926  }
927  else
928  {
929  connector = new InPortPushConnector(profile,
930  provider,
931  m_listeners);
932  }
933 
934  if (connector == 0)
935  {
936  RTC_ERROR(("old compiler? new returned 0;"));
937  return 0;
938  }
939  RTC_TRACE(("InPortPushConnector created"));
940 
941  m_connectors.push_back(connector);
942  RTC_PARANOID(("connector push backed: %d", m_connectors.size()));
943  return connector;
944  }
945  catch (std::bad_alloc& e)
946  {
947  RTC_ERROR(("InPortPushConnector creation failed"));
948  return 0;
949  }
950  RTC_FATAL(("never comes here: createConnector()"));
951  return 0;
952  }
953 
962  InPortBase::createConnector(const ConnectorProfile& cprof,
964  OutPortConsumer* consumer)
965  {
966 #ifndef ORB_IS_RTORB
967  ConnectorInfo profile(cprof.name,
968  cprof.connector_id,
969  CORBA_SeqUtil::refToVstring(cprof.ports),
970  prop);
971 #else // ORB_IS_RTORB
972  ConnectorInfo profile(cprof.name,
973  cprof.connector_id,
974  CORBA_SeqUtil::
975  refToVstring(RTC::PortServiceList(cprof.ports)),
976  prop);
977 #endif // ORB_IS_RTORB
978 
979  InPortConnector* connector(0);
980  try
981  {
982  if (m_singlebuffer)
983  {
984  connector = new InPortPullConnector(profile, consumer,
985  m_listeners,
986  m_thebuffer);
987  }
988  else
989  {
990  connector = new InPortPullConnector(profile, consumer, m_listeners);
991  }
992 
993  if (connector == 0)
994  {
995  RTC_ERROR(("old compiler? new returned 0;"));
996  return 0;
997  }
998  RTC_TRACE(("InPortPushConnector created"));
999 
1000  // endian type set
1001  connector->setEndian(m_littleEndian);
1002  m_connectors.push_back(connector);
1003  RTC_PARANOID(("connector push backed: %d", m_connectors.size()));
1004  return connector;
1005  }
1006  catch (std::bad_alloc& e)
1007  {
1008  RTC_ERROR(("InPortPullConnector creation failed"));
1009  return 0;
1010  }
1011  RTC_FATAL(("never comes here: createConnector()"));
1012  return 0;
1013  }
1014 
1015 };
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:763
std::string normalize(std::string &str)
Erase the head/tail blank and replace upper case to lower case.
Definition: stringutil.cpp:303
virtual ReturnCode_t subscribeInterfaces(const ConnectorProfile &connector_profile)
Subscribe to the interface.
Definition: InPortBase.cpp:541
coil::Properties & properties()
Get properties.
Definition: InPortBase.cpp:134
virtual void unsubscribeInterfaces(const ConnectorProfile &connector_profile)
Disconnect the interface connection.
Definition: InPortBase.cpp:630
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:433
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.
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:341
std::vector< ConnectorInfo > ConnectorInfoList
OutPortConsumer class.
Properties * hasKey(const char *key) const
Check whether key exists in the children.
Definition: Properties.cpp:517
bool isLittleEndian()
return it whether endian setting.
Definition: InPortBase.cpp:421
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:322
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:302
virtual ~InPortBase(void)
Destructor.
Definition: InPortBase.cpp:64
#define RTC_WARN(fmt)
Warning log output macro.
Definition: SystemLogger.h:444
#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:902
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:238
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
std::string flatten(vstring sv)
Create CSV file from the given string list.
Definition: stringutil.cpp:549
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:363
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:261
ConnectorInfoList getConnectorProfiles()
ConnectorProfile list.
Definition: InPortBase.cpp:161
void initProviders()
InPort provider initialization.
Definition: InPortBase.cpp:665
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:179
bool getConnectorProfileByName(const char *name, ConnectorInfo &prof)
Getting ConnectorProfile by name.
Definition: InPortBase.cpp:281
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:386
const std::vector< InPortConnector * > & connectors()
Connector list.
Definition: InPortBase.cpp:148
prop
Organization::get_organization_property ();.
RTC::Port implementation for InPort.
void initConsumers()
OutPort consumer initialization.
Definition: InPortBase.cpp:714
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:401
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(CorbaSequence &seq, SequenceElement elem)
Push the new element back to the CORBA sequence.
OutPortConsumer abstract class.
coil::vstring getConnectorNames()
Connector name list.
Definition: InPortBase.cpp:197
Properties & getNode(const std::string &key)
Get node of properties.
Definition: Properties.cpp:455
InPortConnector * getConnectorById(const char *id)
Getting ConnectorProfile by ID.
Definition: InPortBase.cpp:215
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:432
OutPortConsumer * createConsumer(const ConnectorProfile &cprof, coil::Properties &prop)
InPort provider creation.
Definition: InPortBase.cpp:857
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:347
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
const std::string & getProperty(const std::string &key) const
Search for the property with the specified key in this property.
Definition: Properties.cpp:156
InPortProvider * createProvider(ConnectorProfile &cprof, coil::Properties &prop)
InPort provider creation.
Definition: InPortBase.cpp:803
virtual ReturnCode_t publishInterfaces(ConnectorProfile &connector_profile)
Publish interface information.
Definition: InPortBase.cpp:462


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Mon Jun 10 2019 14:07:52