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

RtcCompositeBase.h

説明を見る。
00001 // -*- C++ -*-
00013 #ifndef __RtcComposite_h__
00014 #define __RtcComposite_h__
00015 
00016 #include "rtm/RtcBase.h"
00017 
00018 namespace RTM {
00019 
00020   class RtcCompositeBase
00021         : public RtcBase
00022   {
00023   public:
00027         RtcCompositeBase();
00028         RtcCompositeBase(RtcManager* manager);
00029         RtcCompositeBase(CORBA::ORB_ptr &orb, PortableServer::POA_ptr &poa);
00030         
00032         //      virtual ~RtcCompositeBase();
00033         
00034         //============================================================
00035         //
00036         // <<< CORBA interfaces >>>
00037         //
00038         //============================================================
00039         
00040         //------------------------------------------------------------
00041         // Transition operation of component activity state
00042         //------------------------------------------------------------
00044         //  virtual RtmRes rtc_start();
00045         
00047         //      virtual RtmRes rtc_stop();
00048         
00050         //      virtual RtmRes rtc_reset();
00051         
00053         //      virtual RtmRes rtc_exit();
00054         
00056         //      virtual RtmRes rtc_kill();
00057         
00058         //------------------------------------------------------------
00059         // Main activity
00060         //------------------------------------------------------------
00062         //      virtual RtmRes rtc_worker();
00063         
00064         //------------------------------------------------------------
00065         // Status handling
00066         //------------------------------------------------------------
00068         //  virtual ComponentState get_state();
00069         //      virtual OutPort_ptr rtc_state();
00070         
00071         //------------------------------------------------------------
00072         // Get inports and outport object reference
00073         //------------------------------------------------------------
00075         //      virtual InPortList* inports();
00076         //      virtual InPort_ptr get_inport(const char* name);
00077         
00079         //      virtual OutPortList* outports();
00080         //      virtual OutPort_ptr get_outport(const char* name);
00081         
00082         virtual RTCProfile* profile();
00083         virtual RTCConfiguration* configuration();
00084         
00085         //------------------------------------------------------------
00086         // [CORBA interface] composit component interfaces
00087         //
00088         // These interfaces are methods for RTCompositeComponet
00089         // Almost all methods do nothing. Only rtc_components and 
00090         // rtc_get_componet methods return this component itself.
00091         //------------------------------------------------------------
00092 
00096         //      virtual RtmRes rtc_set_parent(RTCBase_ptr comp);
00097 
00101         virtual RtmRes rtc_add_component(RTCBase_ptr comp);
00102 
00106         virtual RtmRes rtc_delete_component(RTCBase_ptr comp);
00107 
00111         virtual RtmRes rtc_replace_component(RTCBase_ptr comp1, RTCBase_ptr comp2);
00112 
00116         virtual RtmRes rtc_replace_component_by_name(const char* name1, const char* name2);
00117 
00121         virtual RTCBaseList* rtc_components();
00122 
00126         virtual RTCBase_ptr rtc_get_component(const char* name);
00127 
00132         virtual RtmRes rtc_attach_inport(InPort_ptr in_port);
00133 
00139         virtual RtmRes rtc_attach_inport_by_name(RTCBase_ptr comp, const char* name);
00140 
00145         virtual RtmRes rtc_detatch_inport(InPort_ptr in_port);
00146 
00150         virtual RtmRes rtc_detatch_inport_by_name(const char* name);
00151 
00156         virtual RtmRes rtc_attach_outport(OutPort_ptr out_port);
00157 
00163         virtual RtmRes rtc_attach_outport_by_name(RTCBase_ptr comp, const char* name);
00164 
00169         virtual RtmRes rtc_detatch_outport(OutPort_ptr out_port);
00170 
00174         virtual RtmRes rtc_detatch_outport_by_name(const char* name);
00175         
00176         // end of CORBA interface definition
00177         //============================================================
00178         
00179         
00180         
00181         //============================================================
00182         //
00183         // <<< Local interfaces >>>
00184         //
00185         //============================================================
00186         
00191         //      virtual void init_orb(CORBA::ORB_var orb, PortableServer::POA_var poa);
00192         
00197         virtual int open(void *args){return 0;};
00198         
00203         virtual int svc(void){return 0;};
00204         
00205         
00206         //============================================================
00207         // Component Property handling methods
00208         //============================================================
00210         //  const char* GetComponentName(){ return m_ComponentName.c_str(); };
00211         
00213         //  const char* GetInstanceName(){ return m_InstanceName.c_str(); };
00214         
00216         //  const char* GetComponentCategory(){ return m_CategoryName.c_str(); };
00217         
00218   protected:
00220         //  void  SetComponentName(const char* className){ m_ComponentName = className; };
00221         
00223         //  void  SetInstanceName(const char* componentName){ m_InstanceName = componentName; };
00224         
00226         //  void  SetComponentCategory(const char* categoryName) {m_CategoryName = categoryName; };
00227         
00228         
00229   protected:
00230         
00231         
00232         
00233         //============================================================
00234         // State implementation functions 
00235         //============================================================
00236         // The State Chart of RTComponent
00237         //                                  __                      __
00238         //                        _________V_ \          __________V_   \
00239         //                       |           |/  (any)->|            |/
00240         //                       |  Active   |          | FatalError |
00241         //                       |___________|--,       |____________|
00242         //                           A    |  ___|______      |
00243         //                     ______|___ | |          |     |
00244         //                    |          || | Aborting |     |
00245         //                    | Starting || |__________|     |
00246         //                    |__________||     |   __       |
00247         //            ____________   |    |   __V__V_ \   ___V_____
00248         //  _____    |            |<-+----+--|       |/  |         |    ___
00249         // (Start)-->|Initializing|  |    |  | Error |-->| Exiting |-->(End)
00250         //  ~~~~~    |____________|--+----+->|_______|   |_________|    ~~~
00251         //               A  |        | ___|______  A         A
00252         //               |  |        ||          | |         |
00253         //               |  |        || Stopping | |         |
00254         //               |  |        ||__________| |         |
00255         //               |  |        |    |        |         |
00256         //               |  |     ___|____V__      |         |
00257         //               |  `--->|           |-----'         |
00258         //               `-------|   Ready   |               |
00259         //                      /|___________|---------------'
00260         //                      \__A
00261         //
00262         //------------------------------------------------------------
00263         // typedef CORBA::Short ComponentState;
00264         //
00265         static const ComponentState RTC_UNKNOWN      = RTM::RTComponent::RTC_UNKNOWN;
00266         static const ComponentState RTC_BORN         = RTM::RTComponent::RTC_BORN;
00267         static const ComponentState RTC_INITIALIZING = RTM::RTComponent::RTC_INITIALIZING;
00268         static const ComponentState RTC_READY        = RTM::RTComponent::RTC_READY;
00269         static const ComponentState RTC_STARTING     = RTM::RTComponent::RTC_STARTING;
00270         static const ComponentState RTC_ACTIVE       = RTM::RTComponent::RTC_ACTIVE;
00271         static const ComponentState RTC_STOPPING     = RTM::RTComponent::RTC_STOPPING;
00272         static const ComponentState RTC_ABORTING     = RTM::RTComponent::RTC_ABORTING;
00273         static const ComponentState RTC_ERROR        = RTM::RTComponent::RTC_ERROR;
00274         static const ComponentState RTC_FATAL_ERROR  = RTM::RTComponent::RTC_FATAL_ERROR;
00275         static const ComponentState RTC_EXITING      = RTM::RTComponent::RTC_EXITING;
00276         //------------------------------------------------------------
00277         
00278         // ** Steady state **
00279         //------------------------------------------------------------
00280         // Ready state methods
00285         virtual RtmRes rtc_ready_entry(){};
00290         virtual RtmRes rtc_ready_do(){};
00295         virtual RtmRes rtc_ready_exit(){};
00296         //------------------------------------------------------------
00297         
00298         //------------------------------------------------------------
00299         // Active state methods
00304         virtual RtmRes rtc_active_entry(){};
00309         virtual RtmRes rtc_active_do(){};
00314         virtual RtmRes rtc_active_exit(){};
00315         //------------------------------------------------------------
00316         
00317         //------------------------------------------------------------
00318         // Error state methods
00323         virtual RtmRes rtc_error_entry(){};
00328         virtual RtmRes rtc_error_do(){};
00333         virtual RtmRes rtc_error_exit(){};
00334         //------------------------------------------------------------
00335         
00336         //------------------------------------------------------------
00337         // FatalError state methods
00342         virtual RtmRes rtc_fatal_entry(){};
00347         virtual RtmRes rtc_fatal_do(){};
00352         virtual RtmRes rtc_fatal_exit(){};
00353         //------------------------------------------------------------
00354         
00355         // ** Transient state **
00357 
00361         virtual RtmRes rtc_init_entry(){};
00362         
00367         virtual RtmRes rtc_starting_entry(){};
00368         
00373         virtual RtmRes rtc_stopping_entry(){};
00374         
00379         virtual RtmRes rtc_aborting_entry(){};
00380         
00385         virtual RtmRes rtc_exiting_entry(){};
00386         
00387         
00388         //============================================================
00389         // Input channel handling
00390         //============================================================
00400         bool registerPort(InPortBase& in_ch);
00401         
00410         bool deletePort(InPortBase& in_ch);
00411         
00420         bool deleteInPortByName(char* ch_name);
00421         
00422         //============================================================
00423         // Output channel handling
00424         //============================================================
00434         bool registerPort(OutPortBase& out_ch);
00435         
00444         bool deletePort(OutPortBase& out_ch);
00445         
00454         bool deleteOutPortByName(char* ch_name);
00455         
00456         
00457   private:
00461         class eq_comp_name
00462         {
00463         public:
00464           const string m_name;
00465           eq_comp_name(const char* name) : m_name(name){};
00466           bool operator()(RTCBase_var comp)
00467           {
00468                 if (comp->_is_nil())
00469                   {
00470                         return false;
00471                   }
00472 
00473                 RTCProfile_var profile = comp->profile();
00474                 if (ACE_OS::strcmp(m_name.c_str(),
00475                                                    CORBA::string_dup(profile->name))
00476                         == 0) 
00477                   {
00478                         return true;
00479                   }
00480                 return false;
00481           }
00482         };
00483         
00487         class eq_comp
00488         {
00489         public:
00490           const RTCBase_var m_comp;
00491           eq_comp(const RTCBase_ptr comp) : m_comp(comp){};
00492           bool operator()(RTCBase_ptr comp)
00493           {
00494                 if (m_comp->_is_nil())
00495                   {
00496                         return false;
00497                   }
00498                 return m_comp->_is_equivalent(comp);
00499           };
00500         };
00501         
00502 
00503         class eq_port_name
00504         {
00505         public:
00506           const string m_name;
00507           eq_port_name(const char* name) : m_name(name) {};
00508           bool operator()(InPort_ptr in_port)
00509           {
00510                 if (in_port->_is_nil())
00511                   {
00512                         return false;
00513                   }
00514 
00515                 PortProfile_var profile = in_port->profile();
00516                 if (ACE_OS::strcmp(m_name.c_str(),
00517                                                    CORBA::string_dup(profile->name))
00518                         == 0) 
00519                   {
00520                         return true;
00521                   }
00522                 return false;
00523           }
00524           bool operator()(OutPort_ptr out_port)
00525           {
00526                 if (out_port->_is_nil())
00527                   {
00528                         return false;
00529                   }
00530 
00531                 PortProfile_var profile = out_port->profile();
00532                 if (ACE_OS::strcmp(m_name.c_str(),
00533                                                    CORBA::string_dup(profile->name))
00534                         == 0) 
00535                   {
00536                         return true;
00537                   }
00538                 return false;
00539           }
00540 
00541         };
00542         
00546         class eq_port
00547         {
00548         public:
00549           const InPort_var m_inport;
00550           const OutPort_var m_outport;
00551           eq_port(const InPort_ptr port) : m_inport(port){};
00552           eq_port(const OutPort_ptr port) : m_outport(port){};
00553           bool operator()(InPort_ptr port)
00554           {
00555                 if (m_inport->_is_nil())
00556                   {
00557                         return false;
00558                   }
00559                 return m_inport->_is_equivalent(port);
00560           };
00561           bool operator()(OutPort_ptr port)
00562           {
00563                 if (m_outport->_is_nil())
00564                   {
00565                         return false;
00566                   }
00567                 return m_outport->_is_equivalent(port);
00568           };
00569         };
00570         
00571 
00572         
00573 
00574   protected:
00575         RTCProfile m_Profile;
00576         RTCConfiguration m_Configuration;
00577 
00578         typedef list<RTCBase_ptr>::iterator Components_it;
00579 
00581         struct Components
00582         {
00583           list<RTCBase_ptr> m_List;
00584           ACE_Thread_Mutex m_Mutex;
00585         };
00586         Components m_Components;
00587         
00589         typedef list<InPort_ptr>::iterator InPorts_it;
00590         
00592         typedef list<OutPort_ptr>::iterator OutPorts_it;
00593         
00595         struct InPorts
00596         {
00597           list<InPort_ptr> m_List;
00598           ACE_Thread_Mutex m_Mutex;
00599         };
00600         InPorts m_InPorts;
00601         
00603         struct OutPorts
00604         {
00605           list<OutPort_ptr> m_List;
00606           ACE_Thread_Mutex m_Mutex;
00607         };
00608         OutPorts m_OutPorts;
00609         
00610   }; // end of class RtcComposite
00611   
00612 };
00613 
00614 #endif // end of __RtcComposite_h_

OpenRTMに対してThu Dec 16 15:29:05 2004に生成されました。 doxygen 1.3.6