メインページ | ネームスペース一覧 | クラス階層 | 構成 | Directories | ファイル一覧 | ネームスペースメンバ | 構成メンバ | ファイルメンバ

CorbaPort.h

説明を見る。
00001 // -*- C++ -*-
00020 /*
00021  * $Log: CorbaPort.h,v $
00022  * Revision 1.1  2007/01/04 00:45:21  n-ando
00023  * CORBA serivce provider/consumer Port implementation.
00024  *
00025  *
00026  */
00027 
00028 
00029 #ifndef CorbaPort_h
00030 #define CorbaPort_h
00031 
00032 #include <rtm/PortBase.h>
00033 #include <rtm/CorbaConsumer.h>
00034 #include <rtm/NVUtil.h>
00035 
00036 namespace RTC
00037 {
00126   class CorbaPort
00127     : public PortBase
00128   {
00129   public:
00144     CorbaPort(const char* name);
00145 
00146 
00158     virtual ~CorbaPort();
00159 
00160 
00192     bool registerProvider(const char* instance_name, const char* type_name,
00193                           PortableServer::RefCountServantBase& provider);
00194 
00195 
00231     bool registerConsumer(const char* instance_name, const char* type_name,
00232                           CorbaConsumerBase& consumer);
00233 
00234 
00235   protected:
00280      virtual ReturnCode_t
00281      publishInterfaces(ConnectorProfile& connector_profile);
00282 
00283 
00326      virtual ReturnCode_t
00327      subscribeInterfaces(const ConnectorProfile& connector_profile);
00328 
00329 
00344      virtual void
00345      unsubscribeInterfaces(const ConnectorProfile& connector_profile);
00346 
00347 
00348   private:
00356     NVList m_providers;
00357 
00358 
00366     struct Consumer
00367     {
00368       Consumer(const char* _instance_name, const char* _type_name,
00369                CorbaConsumerBase& _cons)
00370         : name(std::string("port.")
00371                + _type_name
00372                + std::string(".")
00373                + _instance_name),
00374           consumer(_cons)
00375       {}
00376       Consumer(const Consumer& cons)
00377         : name(cons.name), consumer(cons.consumer)
00378       { 
00379       }
00380       Consumer operator=(const Consumer& _cons)
00381       {
00382         Consumer cons(_cons);
00383         return cons;
00384       }
00385       std::string name;
00386       CorbaConsumerBase& consumer;
00387     };
00388     std::vector<Consumer> m_consumers;
00389 
00390     // functors
00399     struct subscribe
00400     {
00401       subscribe(std::vector<Consumer>& cons)
00402         : m_cons(cons), m_len(cons.size())
00403         {
00404         }
00405         
00406         void operator()(const SDOPackage::NameValue& nv)
00407         {
00408           for (CORBA::ULong i = 0; i < m_len; ++i)
00409             {
00410               std::string name(nv.name);
00411               if (m_cons[i].name == name)
00412                 {
00413                   CORBA::Object_ptr obj;
00414                   if (nv.value >>= CORBA::Any::to_object(obj))
00415                     {
00416                       m_cons[i].consumer.setObject(obj);
00417                     }
00418                 }
00419         }
00420         }
00421         std::vector<Consumer> m_cons;
00422         CORBA::ULong m_len;
00423     };
00424 
00425 
00433     struct unsubscribe
00434     {
00435       unsubscribe(std::vector<Consumer>& cons)
00436         : m_cons(cons), m_len(cons.size())
00437       {
00438       }
00439       
00440       void operator()(const SDOPackage::NameValue& nv)
00441       {
00442         for (CORBA::ULong i = 0; i < m_len; ++i)
00443           {
00444             std::string name(nv.name);
00445             if (m_cons[i].name == name)
00446               {
00447                 m_cons[i].consumer.releaseObject();
00448               }
00449           }
00450       }
00451       std::vector<Consumer> m_cons;
00452       CORBA::ULong m_len;
00453     };
00454     
00455   };
00456 };
00457 #endif // CorbaPort_h

OpenRTMに対してFri Oct 5 05:14:57 2007に生成されました。  doxygen 1.4.1