InPortBase.cpp
Go to the documentation of this file.
00001 // -*- C++ -*-
00020 #include <algorithm>
00021 #include <iterator>
00022 
00023 #include <rtm/CORBA_SeqUtil.h>
00024 #include <rtm/NVUtil.h>
00025 #include <rtm/InPortBase.h>
00026 #include <rtm/CdrBufferBase.h>
00027 #include <rtm/InPortProvider.h>
00028 #include <rtm/OutPortConsumer.h>
00029 #include <rtm/InPortPushConnector.h>
00030 #include <rtm/InPortPullConnector.h>
00031 
00032 namespace RTC
00033 {
00034 
00042   InPortBase::InPortBase(const char* name, const char* data_type)
00043     : PortBase(name), m_singlebuffer(true), m_thebuffer(0), m_littleEndian(true)
00044   {
00045     RTC_DEBUG(("Port name: %s", name));
00046 
00047     // PortProfile::properties を設定
00048     RTC_DEBUG(("setting port.port_type: DataIntPort"));
00049     addProperty("port.port_type", "DataInPort");
00050 
00051     RTC_DEBUG(("setting dataport.data_type: %s", data_type));
00052     addProperty("dataport.data_type", data_type);
00053 
00054     addProperty("dataport.subscription_type", "Any");
00055   }
00056   
00064   InPortBase::~InPortBase()
00065   {
00066     RTC_TRACE(("~InPortBase()"));
00067     
00068     if (m_connectors.size() != 0)
00069       {
00070         RTC_ERROR(("connector.size should be 0 in InPortBase's dtor."));
00071         for (int i(0), len(m_connectors.size()); i < len; ++i)
00072           {
00073             m_connectors[i]->disconnect();
00074             delete m_connectors[i];
00075           }
00076       }
00077     
00078     if (m_thebuffer != 0)
00079       {
00080         CdrBufferFactory::instance().deleteObject(m_thebuffer);
00081         if (!m_singlebuffer)
00082           {
00083             RTC_ERROR(("Although singlebuffer flag is true, the buffer != 0"));
00084           }
00085       }
00086     
00087   }
00088 
00096   void InPortBase::init(coil::Properties& prop)
00097   {
00098     RTC_TRACE(("init()"));
00099     m_properties << prop;
00100     if (m_singlebuffer)
00101       {
00102         RTC_DEBUG(("single buffer mode."));
00103         m_thebuffer = CdrBufferFactory::instance().createObject("ring_buffer");
00104         if (m_thebuffer == 0)
00105           {
00106             RTC_ERROR(("default buffer creation failed"));
00107           }
00108       }
00109     else
00110       {
00111         RTC_DEBUG(("multi buffer mode."));
00112       }
00113 
00114     initProviders();
00115     initConsumers();
00116     int num(-1);
00117     if (!coil::stringTo(num, 
00118                      m_properties.getProperty("connection_limit","-1").c_str()))
00119       {
00120         RTC_ERROR(("invalid connection_limit value: %s", 
00121                    m_properties.getProperty("connection_limit").c_str()));
00122       }
00123 
00124     setConnectionLimit(num);
00125   }
00126   
00134   coil::Properties& InPortBase::properties()
00135   {
00136     RTC_TRACE(("properties()"));
00137     
00138     return m_properties;
00139   }
00140 
00148   const std::vector<InPortConnector*>& InPortBase::connectors()
00149   {
00150     RTC_TRACE(("connectors(): size = %d", m_connectors.size()));
00151     return m_connectors;
00152   }
00153 
00161   ConnectorInfoList InPortBase::getConnectorProfiles()
00162   {
00163     RTC_TRACE(("getConnectorProfiles(): size = %d", m_connectors.size()));
00164     ConnectorInfoList profs;
00165     for (int i(0), len(m_connectors.size()); i < len; ++i)
00166       {
00167         profs.push_back(m_connectors[i]->profile());
00168       }
00169     return profs;
00170   }
00171 
00179   coil::vstring InPortBase::getConnectorIds()
00180   {
00181     coil::vstring ids;
00182     for (int i(0), len(m_connectors.size()); i < len; ++i)
00183       {
00184         ids.push_back(m_connectors[i]->id());
00185       }
00186     RTC_TRACE(("getConnectorIds(): %s", coil::flatten(ids).c_str()));
00187     return ids;
00188   }
00189 
00197   coil::vstring InPortBase::getConnectorNames()
00198   {
00199     coil::vstring names;
00200     for (int i(0), len(m_connectors.size()); i < len; ++i)
00201       {
00202         names.push_back(m_connectors[i]->name());
00203       }
00204     RTC_TRACE(("getConnectorNames(): %s", coil::flatten(names).c_str()));
00205     return names;
00206   }
00207 
00215   InPortConnector* InPortBase::getConnectorById(const char* id)
00216   {
00217     RTC_TRACE(("getConnectorById(id = %s)", id));
00218 
00219     std::string sid(id);
00220     for (int i(0), len(m_connectors.size()); i < len; ++i)
00221       {
00222         if (sid  == m_connectors[i]->id())
00223           {
00224             return m_connectors[i];
00225           }
00226       }
00227     RTC_WARN(("ConnectorProfile with the id(%s) not found.", id));
00228     return 0;
00229   }
00230 
00238   InPortConnector* InPortBase::getConnectorByName(const char* name)
00239   {
00240     RTC_TRACE(("getConnectorByName(name = %s)", name));
00241 
00242     std::string sname(name);
00243     for (int i(0), len(m_connectors.size()); i < len; ++i)
00244       {
00245         if (sname  == m_connectors[i]->name())
00246           {
00247             return m_connectors[i];
00248           }
00249       }
00250     RTC_WARN(("ConnectorProfile with the name(%s) not found.", name));
00251     return 0;
00252   }
00253 
00261   bool InPortBase::getConnectorProfileById(const char* id,
00262                                             ConnectorInfo& prof)
00263   {
00264     RTC_TRACE(("getConnectorProfileById(id = %s)", id));
00265     InPortConnector* conn(getConnectorById(id));
00266     if (conn == 0)
00267       {
00268         return false;
00269       }
00270     prof = conn->profile();
00271     return true;
00272   }
00273 
00281   bool InPortBase::getConnectorProfileByName(const char* name,
00282                                               ConnectorInfo& prof)
00283   {
00284     RTC_TRACE(("getConnectorProfileByName(name = %s)", name));
00285     InPortConnector* conn(getConnectorByName(name));
00286     if (conn == 0)
00287       {
00288         return false;
00289       }
00290     prof = conn->profile();
00291     return true;
00292   }
00293 
00294 
00302   void InPortBase::activateInterfaces()
00303   {
00304     RTC_TRACE(("activateInterfaces()"));
00305     
00306     for (int i(0), len(m_connectors.size()); i < len; ++i)
00307       {
00308         m_connectors[i]->activate();
00309         RTC_DEBUG(("activate connector: %s %s",
00310                    m_connectors[i]->name(),
00311                    m_connectors[i]->id()));
00312       }
00313   }
00314 
00322   void InPortBase::deactivateInterfaces()
00323   {
00324     RTC_TRACE(("deactivateInterfaces()"));
00325 
00326     for (int i(0), len(m_connectors.size()); i < len; ++i)
00327       {
00328         m_connectors[i]->deactivate();
00329         RTC_DEBUG(("deactivate connector: %s %s",
00330                    m_connectors[i]->name(),
00331                    m_connectors[i]->id()));
00332       }
00333   }
00334 
00346   void InPortBase::
00347   addConnectorDataListener(ConnectorDataListenerType type,
00348                            ConnectorDataListener* listener,
00349                            bool autoclean)
00350   {
00351     if (type < CONNECTOR_DATA_LISTENER_NUM)
00352       {
00353         RTC_TRACE(("addConnectorDataListener(%s)",
00354                    ConnectorDataListener::toString(type)));
00355         m_listeners.connectorData_[type].addListener(listener, autoclean);
00356         return;
00357       }
00358     RTC_ERROR(("addConnectorDataListener(): Invalid listener type."));
00359     return;
00360   }
00361 
00362   void InPortBase::
00363   removeConnectorDataListener(ConnectorDataListenerType type,
00364                               ConnectorDataListener* listener)
00365   {
00366     if (type < CONNECTOR_DATA_LISTENER_NUM)
00367       {
00368         RTC_TRACE(("removeConnectorDataListener(%s)",
00369                    ConnectorDataListener::toString(type)));
00370         m_listeners.connectorData_[type].removeListener(listener);
00371         return;
00372       }
00373     RTC_ERROR(("removeConnectorDataListener(): Invalid listener type."));
00374     return;
00375   }
00376   
00386   void InPortBase::addConnectorListener(ConnectorListenerType type,
00387                                          ConnectorListener* listener,
00388                                          bool autoclean)
00389   {
00390     if (type < CONNECTOR_LISTENER_NUM)
00391       {
00392         RTC_TRACE(("addConnectorListener(%s)",
00393                    ConnectorListener::toString(type)));
00394         m_listeners.connector_[type].addListener(listener, autoclean);
00395         return;
00396       }
00397     RTC_ERROR(("addConnectorListener(): Invalid listener type."));
00398     return;
00399   }
00400   
00401   void InPortBase::removeConnectorListener(ConnectorListenerType type,
00402                                             ConnectorListener* listener)
00403   {
00404     if (type < CONNECTOR_LISTENER_NUM)
00405       {
00406         RTC_TRACE(("removeConnectorListener(%s)",
00407                    ConnectorListener::toString(type)));
00408         m_listeners.connector_[type].removeListener(listener);
00409         return;
00410       }
00411     RTC_ERROR(("removeConnectorListener(): Invalid listener type."));
00412   }
00413 
00421   bool InPortBase::isLittleEndian()
00422   {
00423     return m_littleEndian;
00424   }
00425 
00433   ReturnCode_t InPortBase::connect(ConnectorProfile& connector_profile)
00434     throw (CORBA::SystemException)
00435   {
00436     RTC_TRACE(("InPortBase::connect()"));
00437 
00438     // endian infomation check
00439     CORBA::Long index(NVUtil::find_index(connector_profile.properties,
00440                                        "dataport.serializer.cdr.endian"));
00441     if (index < 0)
00442       {
00443         RTC_TRACE(("ConnectorProfile dataport.serializer.cdr.endian set."));
00444         // endian infomation set
00445         CORBA_SeqUtil::push_back(connector_profile.properties,
00446             NVUtil::newNV("dataport.serializer.cdr.endian", "little,big"));
00447       }
00448     return PortBase::connect(connector_profile);
00449   }
00450   
00451   //============================================================
00452   // protected interfaces
00453   //============================================================
00454   
00462   ReturnCode_t InPortBase::publishInterfaces(ConnectorProfile& cprof)
00463   {    
00464     RTC_TRACE(("publishInterfaces()"));
00465 
00466     ReturnCode_t returnvalue = _publishInterfaces();
00467     if(returnvalue!=RTC::RTC_OK)
00468       {
00469         return returnvalue;
00470       }
00471 
00472     // prop: [port.outport].
00473     coil::Properties prop(m_properties);
00474     {
00475       coil::Properties conn_prop;
00476       NVUtil::copyToProperties(conn_prop, cprof.properties);
00477       prop << conn_prop.getNode("dataport"); // marge ConnectorProfile
00478       /*
00479        * marge ConnectorProfile for buffer property.
00480        * e.g.
00481        *  prof[buffer.write.full_policy]
00482        *       << cprof[dataport.inport.buffer.write.full_policy]
00483        */
00484       prop << conn_prop.getNode("dataport.inport");
00485     }
00486     RTC_DEBUG(("ConnectorProfile::properties are as follows."));
00487     RTC_DEBUG_STR((prop));
00488 
00489     /*
00490      * ここで, ConnectorProfile からの properties がマージされたため、
00491      * prop["dataflow_type"]: データフロータイプ
00492      * prop["interface_type"]: インターフェースタイプ
00493      * などがアクセス可能になる。
00494      */
00495     std::string dflow_type(prop["dataflow_type"]);
00496     coil::normalize(dflow_type);
00497 
00498     if (dflow_type == "push")
00499       {
00500         RTC_DEBUG(("dataflow_type = push .... create PushConnector"));
00501 
00502         // create InPortProvider
00503         InPortProvider* provider(createProvider(cprof, prop));
00504         if (provider == 0)
00505           {
00506             RTC_ERROR(("InPort provider creation failed."));
00507             return RTC::BAD_PARAMETER;
00508           }
00509 
00510         // create InPortPushConnector
00511         InPortConnector* connector(createConnector(cprof, prop, provider));
00512         if (connector == 0)
00513           {
00514             RTC_ERROR(("PushConnector creation failed."));
00515             return RTC::RTC_ERROR;
00516           }
00517 
00518         // connector set
00519         provider->setConnector(connector);
00520 
00521         RTC_DEBUG(("publishInterface() successfully finished."));
00522         return RTC::RTC_OK;
00523       }
00524     else if (dflow_type == "pull")
00525       {
00526         RTC_DEBUG(("dataflow_type = pull .... do nothing"));
00527         return RTC::RTC_OK;
00528       }
00529 
00530     RTC_ERROR(("unsupported dataflow_type: %s", dflow_type.c_str()));
00531     return RTC::BAD_PARAMETER;
00532   }
00533   
00541   ReturnCode_t InPortBase::subscribeInterfaces(const ConnectorProfile& cprof)
00542   {
00543     RTC_TRACE(("subscribeInterfaces()"));
00544 
00545     // prop: [port.outport].
00546     coil::Properties prop(m_properties);
00547     {
00548       coil::Properties conn_prop;
00549       NVUtil::copyToProperties(conn_prop, cprof.properties);
00550       prop << conn_prop.getNode("dataport"); // marge ConnectorProfile
00551       /*
00552        * marge ConnectorProfile for buffer property.
00553        * e.g.
00554        *  prof[buffer.write.full_policy]
00555        *       << cprof[dataport.inport.buffer.write.full_policy]
00556        */
00557       prop << conn_prop.getNode("dataport.inport");
00558     }
00559     RTC_DEBUG(("ConnectorProfile::properties are as follows."));
00560     RTC_DEBUG_STR((prop));
00561 
00562     bool littleEndian; // true: little, false: big
00563     if (!checkEndian(prop, littleEndian))
00564       {
00565         RTC_ERROR(("unsupported endian"));
00566         return RTC::UNSUPPORTED;
00567       }
00568     RTC_TRACE(("endian: %s", littleEndian ? "little" : "big"));
00569 
00570     /*
00571      * ここで, ConnectorProfile からの properties がマージされたため、
00572      * prop["dataflow_type"]: データフロータイプ
00573      * prop["interface_type"]: インターフェースタイプ
00574      * などがアクセス可能になる。
00575      */
00576     std::string dflow_type(prop["dataflow_type"]);
00577     coil::normalize(dflow_type);
00578 
00579     if (dflow_type == "push")
00580       {
00581         RTC_DEBUG(("dataflow_type is push."));
00582 
00583         // setting endian type
00584         InPortConnector* conn(getConnectorById(cprof.connector_id));
00585         if (conn == 0)
00586           {
00587             RTC_ERROR(("specified connector not found: %s",
00588                        (const char*)cprof.connector_id));
00589             return RTC::RTC_ERROR;
00590           }
00591         conn->setEndian(littleEndian);
00592 
00593         RTC_DEBUG(("subscribeInterfaces() successfully finished."));
00594         return RTC::RTC_OK;
00595       }
00596     else if (dflow_type == "pull")
00597       {
00598         RTC_DEBUG(("dataflow_type is pull."));
00599 
00600         // create OutPortConsumer
00601         OutPortConsumer* consumer(createConsumer(cprof, prop));
00602         if (consumer == 0)
00603           {
00604             return RTC::BAD_PARAMETER;
00605           }
00606 
00607         // create InPortPullConnector
00608         InPortConnector* connector(createConnector(cprof, prop, consumer));
00609         if (connector == 0)
00610           {
00611             return RTC::RTC_ERROR;
00612           }
00613 
00614         RTC_DEBUG(("subscribeInterfaces() successfully finished."));
00615         return RTC::RTC_OK;
00616       }
00617 
00618     RTC_ERROR(("unsupported dataflow_type: %s", dflow_type.c_str()));
00619     return RTC::BAD_PARAMETER;
00620   }
00621   
00629   void
00630   InPortBase::unsubscribeInterfaces(const ConnectorProfile& connector_profile)
00631   {
00632     RTC_TRACE(("unsubscribeInterfaces()"));
00633 
00634     std::string id(connector_profile.connector_id);
00635     RTC_PARANOID(("connector_id: %s", id.c_str()));
00636 
00637     ConnectorList::iterator it(m_connectors.begin());
00638 
00639     while (it != m_connectors.end())
00640       {
00641         if (id == (*it)->id())
00642           {
00643             // Connector's dtor must call disconnect()
00644 // RtORB's bug? This causes double delete and segmeentation fault.
00645 #ifndef ORB_IS_RTORB
00646             delete *it;
00647 #endif
00648             m_connectors.erase(it);
00649             RTC_TRACE(("delete connector: %s", id.c_str()));
00650             return;
00651           }
00652         ++it;
00653       }
00654     RTC_ERROR(("specified connector not found: %s", id.c_str()));
00655     return;
00656   }
00657 
00665   void InPortBase::initProviders()
00666   {
00667     RTC_TRACE(("initProviders()"));
00668 
00669     // create InPort providers
00670     InPortProviderFactory& factory(InPortProviderFactory::instance());
00671     coil::vstring provider_types(factory.getIdentifiers());
00672     RTC_DEBUG(("available providers: %s",
00673                coil::flatten(provider_types).c_str()));
00674 
00675 #ifndef RTC_NO_DATAPORTIF_ACTIVATION_OPTION
00676     if (m_properties.hasKey("provider_types") &&
00677         coil::normalize(m_properties["provider_types"]) != "all")
00678       {
00679         RTC_DEBUG(("allowed providers: %s",
00680                    m_properties["provider_types"].c_str()));
00681 
00682         coil::vstring temp_types(provider_types);
00683         provider_types.clear();
00684         coil::vstring
00685           active_types(coil::split(m_properties["provider_types"], ","));
00686 
00687         std::sort(temp_types.begin(), temp_types.end());
00688         std::sort(active_types.begin(), active_types.end());
00689         std::set_intersection(temp_types.begin(), temp_types.end(),
00690                               active_types.begin(), active_types.end(),
00691                               std::back_inserter(provider_types));
00692       }
00693 #endif
00694     
00695     // InPortProvider supports "push" dataflow type
00696     if (provider_types.size() > 0)
00697       {
00698         RTC_DEBUG(("dataflow_type push is supported"));
00699         appendProperty("dataport.dataflow_type", "push");
00700         appendProperty("dataport.interface_type",
00701                        coil::flatten(provider_types).c_str());
00702       }
00703 
00704     m_providerTypes = provider_types;
00705   }
00706 
00714   void InPortBase::initConsumers()
00715   {
00716     RTC_TRACE(("initConsumers()"));
00717 
00718     // create OuPort consumers
00719     OutPortConsumerFactory& factory(OutPortConsumerFactory::instance());
00720     coil::vstring consumer_types(factory.getIdentifiers());
00721     RTC_DEBUG(("available consumers: %s",
00722                coil::flatten(consumer_types).c_str()));
00723 
00724 #ifndef RTC_NO_DATAPORTIF_ACTIVATION_OPTION
00725     if (m_properties.hasKey("consumer_types") &&
00726         coil::normalize(m_properties["consumer_types"]) != "all")
00727       {
00728         RTC_DEBUG(("allowed consumers: %s",
00729                    m_properties["consumer_types"].c_str()));
00730 
00731         coil::vstring temp_types(consumer_types);
00732         consumer_types.clear();
00733         coil::vstring
00734           active_types(coil::split(m_properties["consumer_types"], ","));
00735 
00736         std::sort(temp_types.begin(), temp_types.end());
00737         std::sort(active_types.begin(), active_types.end());
00738         std::set_intersection(temp_types.begin(), temp_types.end(),
00739                               active_types.begin(), active_types.end(),
00740                               std::back_inserter(consumer_types));
00741       }
00742 #endif
00743 
00744     // OutPortConsumer supports "pull" dataflow type
00745     if (consumer_types.size() > 0)
00746       {
00747         RTC_PARANOID(("dataflow_type pull is supported"));
00748         appendProperty("dataport.dataflow_type", "pull");
00749         appendProperty("dataport.interface_type",
00750                        coil::flatten(consumer_types).c_str());
00751       }
00752 
00753     m_consumerTypes = consumer_types;
00754   }
00755 
00763   bool InPortBase::checkEndian(const coil::Properties& prop,
00764                                bool& littleEndian)
00765   {
00766         // old version check
00767     if(prop.hasKey("serializer") == NULL)
00768       {
00769         littleEndian = true;
00770         return true;
00771       }
00772 
00773     // endian type check
00774     std::string endian_type(prop.getProperty("serializer.cdr.endian", ""));
00775     RTC_DEBUG(("endian_type: %s", endian_type.c_str()));
00776     coil::normalize(endian_type);
00777     std::vector<std::string> endian(coil::split(endian_type, ","));
00778 
00779     if(endian.empty()) { return false; }
00780     if(endian[0] == "little")
00781       {
00782         littleEndian = true;
00783         return true;
00784       }
00785     else if(endian[0] == "big")
00786       {
00787         littleEndian = false;
00788         return true;
00789       }
00790     return false;
00791   }
00792 
00793 
00794 
00802   InPortProvider*
00803   InPortBase::createProvider(ConnectorProfile& cprof, coil::Properties& prop)
00804   {
00805     if (!prop["interface_type"].empty() &&
00806         !coil::includes((coil::vstring)m_providerTypes, prop["interface_type"]))
00807       {
00808         RTC_ERROR(("no provider found"));
00809         RTC_DEBUG(("interface_type:  %s", prop["interface_type"].c_str()));
00810         RTC_DEBUG(("interface_types: %s",
00811                    coil::flatten(m_providerTypes).c_str()));
00812         return 0;
00813       }
00814     
00815     RTC_DEBUG(("interface_type: %s", prop["interface_type"].c_str()));
00816     InPortProvider* provider;
00817     provider = InPortProviderFactory::
00818       instance().createObject(prop["interface_type"].c_str());
00819     
00820     if (provider != 0)
00821       {
00822         RTC_DEBUG(("provider created"));
00823         provider->init(prop.getNode("provider"));
00824 
00825 #ifndef ORB_IS_RTORB
00826         if (!provider->publishInterface(cprof.properties))
00827           {
00828             RTC_ERROR(("publishing interface information error"));
00829             InPortProviderFactory::instance().deleteObject(provider);
00830             return 0;
00831           }
00832 #else // ORB_IS_RTORB
00833         // RtORB's copy ctor's bug?
00834         ::SDOPackage::NVList_ptr prop_ref(cprof.properties);
00835         if (!provider->publishInterface(*prop_ref))
00836           {
00837             RTC_ERROR(("publishing interface information error"));
00838             InPortProviderFactory::instance().deleteObject(provider);
00839             return 0;
00840           }
00841 #endif // ORB_IS_RTORB
00842         return provider;
00843       }
00844 
00845     RTC_ERROR(("provider creation failed"));
00846     return 0;
00847   }
00848 
00856   OutPortConsumer*
00857   InPortBase::createConsumer(const ConnectorProfile& cprof,
00858                              coil::Properties& prop)
00859   {
00860     if (!prop["interface_type"].empty() &&
00861         !coil::includes((coil::vstring)m_consumerTypes, prop["interface_type"]))
00862       {
00863         RTC_ERROR(("no consumer found"));
00864         RTC_DEBUG(("interface_type:  %s", prop["interface_type"].c_str()));
00865         RTC_DEBUG(("interface_types: %s",
00866                    coil::flatten(m_consumerTypes).c_str()));
00867         return 0;
00868       }
00869     
00870     RTC_DEBUG(("interface_type: %s", prop["interface_type"].c_str()));
00871     OutPortConsumer* consumer;
00872     consumer = OutPortConsumerFactory::
00873       instance().createObject(prop["interface_type"].c_str());
00874     
00875     if (consumer != 0)
00876       {
00877         RTC_DEBUG(("consumer created"));
00878         consumer->init(prop.getNode("consumer"));
00879 
00880         if (!consumer->subscribeInterface(cprof.properties))
00881           {
00882             RTC_ERROR(("interface subscription failed."));
00883             OutPortConsumerFactory::instance().deleteObject(consumer);
00884             return 0;
00885           }
00886 
00887         return consumer;
00888       }
00889 
00890     RTC_ERROR(("consumer creation failed"));
00891     return 0; 
00892   }
00893   
00901   InPortConnector*
00902   InPortBase::createConnector(ConnectorProfile& cprof, coil::Properties& prop,
00903                               InPortProvider* provider)
00904   {
00905 #ifndef ORB_IS_RTORB
00906     ConnectorInfo profile(cprof.name,
00907                           cprof.connector_id,
00908                           CORBA_SeqUtil::refToVstring(cprof.ports),
00909                           prop); 
00910 #else // ORB_IS_RTORB
00911     ConnectorInfo profile(cprof.name,
00912                           cprof.connector_id,
00913                           CORBA_SeqUtil::
00914                           refToVstring(RTC::PortServiceList(cprof.ports)),
00915                           prop); 
00916 #endif // ORB_IS_RTORB
00917 
00918     InPortConnector* connector(0);
00919     try
00920       {
00921         if (m_singlebuffer)
00922           {
00923             connector = new InPortPushConnector(profile, provider,
00924                                                 m_listeners,
00925                                                 m_thebuffer);
00926           }
00927         else
00928           {
00929             connector = new InPortPushConnector(profile, 
00930                                                 provider,
00931                                                 m_listeners);
00932           }
00933 
00934         if (connector == 0)
00935           {
00936             RTC_ERROR(("old compiler? new returned 0;"));
00937             return 0;
00938           }
00939         RTC_TRACE(("InPortPushConnector created"));
00940 
00941         m_connectors.push_back(connector);
00942         RTC_PARANOID(("connector push backed: %d", m_connectors.size()));
00943         return connector;
00944       }
00945     catch (std::bad_alloc& e)
00946       {
00947         RTC_ERROR(("InPortPushConnector creation failed"));
00948         return 0;
00949       }
00950     RTC_FATAL(("never comes here: createConnector()"));
00951     return 0;
00952   }
00953 
00961   InPortConnector*
00962   InPortBase::createConnector(const ConnectorProfile& cprof,
00963                               coil::Properties& prop,
00964                               OutPortConsumer* consumer)
00965   {
00966 #ifndef ORB_IS_RTORB
00967     ConnectorInfo profile(cprof.name,
00968                           cprof.connector_id,
00969                           CORBA_SeqUtil::refToVstring(cprof.ports),
00970                           prop); 
00971 #else // ORB_IS_RTORB
00972     ConnectorInfo profile(cprof.name,
00973                           cprof.connector_id,
00974                           CORBA_SeqUtil::
00975                           refToVstring(RTC::PortServiceList(cprof.ports)),
00976                           prop); 
00977 #endif // ORB_IS_RTORB
00978 
00979     InPortConnector* connector(0);
00980     try
00981       {
00982         if (m_singlebuffer)
00983           {
00984             connector = new InPortPullConnector(profile, consumer,
00985                                                 m_listeners,
00986                                                 m_thebuffer);
00987           }
00988         else
00989           {
00990             connector = new InPortPullConnector(profile, consumer, m_listeners);
00991           }
00992 
00993         if (connector == 0)
00994           {
00995             RTC_ERROR(("old compiler? new returned 0;"));
00996             return 0;
00997           }
00998         RTC_TRACE(("InPortPushConnector created"));
00999 
01000         // endian type set
01001         connector->setEndian(m_littleEndian);
01002         m_connectors.push_back(connector);
01003         RTC_PARANOID(("connector push backed: %d", m_connectors.size()));
01004         return connector;
01005       }
01006     catch (std::bad_alloc& e)
01007       {
01008         RTC_ERROR(("InPortPullConnector creation failed"));
01009         return 0;
01010       }
01011     RTC_FATAL(("never comes here: createConnector()"));
01012     return 0;
01013   }
01014 
01015 };


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Thu Aug 27 2015 14:16:37