RTObject.h
Go to the documentation of this file.
00001 // -*- C++ -*-
00018 #ifndef RTC_RTOBJECT_H
00019 #define RTC_RTOBJECT_H
00020 
00021 // CORBA header include
00022 #include <coil/Properties.h>
00023 
00024 #include <rtm/RTC.h>
00025 #include <rtm/idl/RTCSkel.h>
00026 #include <rtm/idl/OpenRTMSkel.h>
00027 #include <rtm/PortBase.h>
00028 #include <rtm/PortAdmin.h>
00029 #include <rtm/InPortBase.h>
00030 #include <rtm/OutPortBase.h>
00031 #include <rtm/CorbaPort.h>
00032 #include <rtm/ConfigAdmin.h>
00033 #include <rtm/SystemLogger.h>
00034 #include <rtm/ComponentActionListener.h>
00035 #include <rtm/SdoServiceAdmin.h>
00036 #include <rtm/PortConnectListener.h>
00037 
00038 #define ECOTHER_OFFSET 1000
00039 
00040 namespace SDOPackage
00041 {
00042   class Configuration_impl;
00043 };
00044 
00045 #ifdef WIN32
00046 #pragma warning( disable : 4290 )
00047 #endif
00048 
00049 namespace RTC
00050 {
00051   class Manager;
00052   class ExecutionContextBase;
00053   typedef ExecutionContextHandle_t UniqueId;
00054 
00089   class RTObject_impl
00090     : public virtual POA_OpenRTM::DataFlowComponent, 
00091       public virtual PortableServer::RefCountServantBase
00092   {
00093   public:
00112     RTObject_impl(Manager* manager);
00113     
00134     RTObject_impl(CORBA::ORB_ptr orb, PortableServer::POA_ptr poa);
00135     
00147     virtual ~RTObject_impl(void);
00148     
00149   protected:
00150     //============================================================
00151     // Overridden functions
00152     //============================================================
00180     // The initialize action (on CREATED->ALIVE transition)
00181     // formaer rtc_init_entry() 
00182     virtual ReturnCode_t onInitialize();
00183     
00211     // The finalize action (on ALIVE->END transition)
00212     // formaer rtc_exiting_entry()
00213     virtual ReturnCode_t onFinalize();
00214     
00246     // The startup action when ExecutionContext startup
00247     // former rtc_starting_entry()
00248     virtual ReturnCode_t onStartup(RTC::UniqueId exec_handle);
00249     
00281     // The shutdown action when ExecutionContext stop
00282     // former rtc_stopping_entry()
00283     virtual ReturnCode_t onShutdown(RTC::UniqueId exec_handle);
00284     
00316     // The activated action (Active state entry action)
00317     // former rtc_active_entry()
00318     virtual ReturnCode_t onActivated(RTC::UniqueId exec_handle);
00319     
00351     // The deactivated action (Active state exit action)
00352     // former rtc_active_exit()
00353     virtual ReturnCode_t onDeactivated(RTC::UniqueId exec_handle);
00354     
00391     // The execution action that is invoked periodically
00392     // former rtc_active_do()
00393     virtual ReturnCode_t onExecute(RTC::UniqueId exec_handle);
00394     
00426     // The aborting action when main logic error occurred.
00427     // former rtc_aborting_entry()
00428     virtual ReturnCode_t onAborting(RTC::UniqueId exec_handle);
00429     
00460     // The error action in ERROR state
00461     // former rtc_error_do()
00462     virtual ReturnCode_t onError(RTC::UniqueId exec_handle);
00463     
00494     // The reset action that is invoked resetting
00495     // This is same but different the former rtc_init_entry()
00496     virtual ReturnCode_t onReset(RTC::UniqueId exec_handle);
00497     
00534     // The state update action that is invoked after onExecute() action
00535     // no corresponding operation exists in OpenRTm-aist-0.2.0
00536     virtual ReturnCode_t onStateUpdate(RTC::UniqueId exec_handle);
00537     
00573     // The action that is invoked when execution context's rate is changed
00574     // no corresponding operation exists in OpenRTm-aist-0.2.0
00575     virtual ReturnCode_t onRateChanged(RTC::UniqueId exec_handle);
00576     
00577   public:
00578     //============================================================
00579     // RTC::LightweightRTObject
00580     //============================================================
00616     virtual ReturnCode_t initialize()
00617       throw (CORBA::SystemException);
00618     
00664     virtual ReturnCode_t finalize()
00665       throw (CORBA::SystemException);
00666     
00710     virtual ReturnCode_t exit()
00711       throw (CORBA::SystemException); 
00712     
00746     virtual CORBA::Boolean is_alive(ExecutionContext_ptr exec_context)
00747       throw (CORBA::SystemException);
00748     
00776     virtual ExecutionContext_ptr get_context(UniqueId exec_handle)
00777       throw (CORBA::SystemException);
00778 
00797     virtual ExecutionContextList* get_owned_contexts()
00798       throw (CORBA::SystemException);
00799 
00818     virtual ExecutionContextList* get_participating_contexts()
00819       throw (CORBA::SystemException);
00820 
00835     virtual ExecutionContextHandle_t
00836     get_context_handle(ExecutionContext_ptr cxt)
00837       throw (CORBA::SystemException);
00838 
00869     UniqueId attach_context(ExecutionContext_ptr exec_context)
00870       throw (CORBA::SystemException);
00871 
00872     UniqueId bindContext(ExecutionContext_ptr exec_context);
00873     
00915     ReturnCode_t detach_context(UniqueId exec_handle)
00916       throw (CORBA::SystemException);
00917     
00918     //============================================================
00919     // RTC::RTObject
00920     //============================================================
00940     virtual ComponentProfile* get_component_profile()
00941       throw (CORBA::SystemException);
00942     
00962     virtual PortServiceList* get_ports()
00963       throw (CORBA::SystemException);
00964     
00986     //    virtual ExecutionContextServiceList* get_execution_context_services()
00987     //      throw (CORBA::SystemException);
00988     
00989     //============================================================
00990     // RTC::ComponentAction
00991     //============================================================
01017     virtual ReturnCode_t on_initialize()
01018       throw (CORBA::SystemException);
01019     
01044     virtual ReturnCode_t on_finalize()
01045       throw (CORBA::SystemException);
01046     
01075     virtual ReturnCode_t on_startup(UniqueId exec_handle)
01076       throw (CORBA::SystemException);
01077     
01106     virtual ReturnCode_t on_shutdown(UniqueId exec_handle)
01107       throw (CORBA::SystemException);
01108     
01135     virtual ReturnCode_t on_activated(UniqueId exec_handle)
01136       throw (CORBA::SystemException);
01137     
01165     virtual ReturnCode_t on_deactivated(UniqueId exec_handle)
01166       throw (CORBA::SystemException);
01167     
01200     virtual ReturnCode_t on_aborting(UniqueId exec_handle)
01201       throw (CORBA::SystemException);
01202     
01246     virtual ReturnCode_t on_error(UniqueId exec_handle)
01247       throw (CORBA::SystemException);
01248     
01283     virtual ReturnCode_t on_reset(UniqueId exec_handle)
01284       throw (CORBA::SystemException);
01285     
01286     //============================================================
01287     // RTC::DataFlowComponentAction
01288     //============================================================
01331     virtual ReturnCode_t on_execute(UniqueId exec_handle)
01332       throw (CORBA::SystemException);
01333     
01377     virtual ReturnCode_t on_state_update(UniqueId exec_handle)
01378       throw (CORBA::SystemException);
01379     
01416     virtual ReturnCode_t on_rate_changed(UniqueId exec_handle)
01417       throw (CORBA::SystemException);
01418     
01419     //============================================================
01420     // SDOPackage::SdoSystemElement
01421     //============================================================
01459     virtual SDOPackage::OrganizationList* get_owned_organizations()
01460       throw (CORBA::SystemException,
01461              SDOPackage::NotAvailable, SDOPackage::InternalError);
01462     
01463     //============================================================
01464     // SDOPackage::SDO
01465     //============================================================
01499     virtual char* get_sdo_id()
01500       throw (CORBA::SystemException,
01501              SDOPackage::NotAvailable, SDOPackage::InternalError);
01502     
01536     virtual char* get_sdo_type()
01537       throw (CORBA::SystemException, 
01538              SDOPackage::NotAvailable, SDOPackage::InternalError);
01539     
01576     virtual SDOPackage::DeviceProfile* get_device_profile()
01577       throw (CORBA::SystemException, 
01578              SDOPackage::NotAvailable, SDOPackage::InternalError);
01579     
01616     virtual SDOPackage::ServiceProfileList* get_service_profiles()
01617       throw (CORBA::SystemException, 
01618              SDOPackage::NotAvailable, SDOPackage::InternalError);
01619     
01661     virtual SDOPackage::ServiceProfile* get_service_profile(const char* id)
01662       throw (CORBA::SystemException, 
01663              SDOPackage::InvalidParameter, SDOPackage::NotAvailable,
01664              SDOPackage::InternalError);
01665     
01713     virtual SDOPackage::SDOService_ptr get_sdo_service(const char* id)
01714       throw (CORBA::SystemException, 
01715              SDOPackage::InvalidParameter, SDOPackage::NotAvailable,
01716              SDOPackage::InternalError);
01717     
01762     virtual SDOPackage::Configuration_ptr get_configuration()
01763       throw (CORBA::SystemException, 
01764              SDOPackage::InterfaceNotImplemented, SDOPackage::NotAvailable,
01765              SDOPackage::InternalError);
01766     
01810     virtual SDOPackage::Monitoring_ptr get_monitoring()
01811       throw (CORBA::SystemException, 
01812              SDOPackage::InterfaceNotImplemented, SDOPackage::NotAvailable,
01813              SDOPackage::InternalError);
01814     
01850     virtual SDOPackage::OrganizationList* get_organizations()
01851       throw (CORBA::SystemException, 
01852              SDOPackage::NotAvailable, SDOPackage::InternalError);
01853     
01885     virtual SDOPackage::NVList* get_status_list()
01886       throw (CORBA::SystemException, 
01887              SDOPackage::NotAvailable, SDOPackage::InternalError);
01888     
01925     virtual CORBA::Any* get_status(const char* name)
01926       throw (CORBA::SystemException, 
01927              SDOPackage::InvalidParameter, SDOPackage::NotAvailable,
01928              SDOPackage::InternalError);
01929     
01930     //============================================================
01931     // Local interfaces
01932     //============================================================
01952     const char* getInstanceName()
01953     {
01954       RTC_TRACE(("getInstanceName()"));
01955       return m_profile.instance_name;
01956     }
01957     
01977     void setInstanceName(const char* instance_name);
01978     
01998     const char* getTypeName()
01999     {
02000       RTC_TRACE(("getTypeName()"));
02001       return m_profile.type_name;
02002     }
02003     
02023     const char* getDescription()
02024     {
02025       RTC_TRACE(("getDescription()"));
02026       return m_profile.description;
02027     }
02028     
02049     const char* getVersion()
02050     {
02051       RTC_TRACE(("getVersion()"));
02052       return m_profile.version;
02053     }
02054     
02074     const char* getVendor()
02075     {
02076       RTC_TRACE(("getVendor()"));
02077       return m_profile.vendor;
02078     }
02079     
02099     const char* getCategory()
02100     {
02101       RTC_TRACE(("getCategory()"));
02102       return m_profile.category;
02103     }
02104     
02124     std::vector<std::string> getNamingNames();
02125     
02145     void setObjRef(const RTObject_ptr rtobj);
02146     
02166     RTObject_ptr getObjRef() const;
02167     
02193     void setProperties(const coil::Properties& prop);
02194     
02216     coil::Properties& getProperties();
02217     
02250     template <typename VarType>
02251     bool bindParameter(const char* param_name, VarType& var,
02252                        const char* def_val,
02253                        bool (*trans)(VarType&, const char*) = coil::stringTo)
02254     {
02255       RTC_TRACE(("bindParameter(%s (default: %s))", param_name, def_val));
02256       m_configsets.bindParameter(param_name, var, def_val, trans);
02257       return true;
02258     }
02259     
02281     void updateParameters(const char* config_set);
02282     
02316     bool addPort(PortBase& port);
02350     bool addPort(PortService_ptr port);
02384     bool addPort(CorbaPort& port);
02416     void registerPort(PortBase& port);
02448     void registerPort(PortService_ptr port);
02480     void registerPort(CorbaPort& port);
02481 
02510     bool addInPort(const char* name, InPortBase& inport);
02537     void registerInPort(const char* name, InPortBase& inport);
02538     
02567     bool addOutPort(const char* name, OutPortBase& outport);
02594     void registerOutPort(const char* name, OutPortBase& outport);
02595     
02617     bool removeInPort(InPortBase& port);
02618 
02640     bool removeOutPort(OutPortBase& port);
02641 
02663     bool removePort(PortBase& port);
02685     bool removePort(PortService_ptr port);
02707     bool removePort(CorbaPort& port);
02727     void deletePort(PortBase& port);
02747     void deletePort(PortService_ptr port);
02767     void deletePort(CorbaPort& port);
02768     
02788     void deletePortByName(const char* port_name);
02789     
02840     ExecutionContext_ptr getExecutionContext(RTC::UniqueId ec_id);
02841 
02894     double getExecutionRate(RTC::UniqueId ec_id);
02895 
02949     ReturnCode_t setExecutionRate(RTC::UniqueId ec_id, double rate);
02950 
03003     bool isOwnExecutionContext(RTC::UniqueId ec_id);
03004 
03043     ReturnCode_t deactivate(RTC::UniqueId ec_id);
03044 
03081     ReturnCode_t activate(RTC::UniqueId ec_id);
03082 
03117     ReturnCode_t reset(RTC::UniqueId ec_id);
03118 
03126     bool addSdoServiceProvider(const SDOPackage::ServiceProfile& prof,
03127                                SdoServiceProviderBase* provider);
03128 
03136     bool removeSdoServiceProvider(const char* id);
03137 
03145     bool addSdoServiceConsumer(const SDOPackage::ServiceProfile& prof);
03146 
03154     bool removeSdoServiceConsumer(const char* id);
03155 
03176     bool readAll();
03177 
03198     bool writeAll();
03199 
03234     void setReadAll(bool read=true, bool completion=false);
03235 
03270     void setWriteAll(bool write=true, bool completion=false);
03271 
03272 
03289     void finalizePorts();
03290 
03291 
03303     void finalizeContexts();
03304 
03305 
03378     typedef PreComponentActionListener PreCompActionListener;
03379     typedef PreComponentActionListenerType PreCompActionListenerType;
03380     void 
03381     addPreComponentActionListener(PreComponentActionListenerType listener_type,
03382                                   PreComponentActionListener* listener,
03383                                   bool autoclean = true);
03384 
03385 
03386     template <class Listener>
03387     PreComponentActionListener*
03388     addPreComponentActionListener(PreCompActionListenerType listener_type,
03389                                    Listener& obj,
03390                                    void (Listener::*memfunc)(UniqueId ec_id))
03391     {
03392       class Noname
03393         : public PreComponentActionListener
03394       {
03395       public:
03396         Noname(Listener& obj, void (Listener::*memfunc)(UniqueId))
03397           : m_obj(obj), m_memfunc(memfunc)
03398         {
03399         }
03400         void operator()(UniqueId ec_id)
03401         {
03402           (m_obj.*m_memfunc)(ec_id);
03403         }
03404       private:
03405         Listener& m_obj;
03406         typedef void (Listener::*Memfunc)(UniqueId ec_id);
03407         Memfunc m_memfunc;
03408       };
03409       Noname* listener(new Noname(obj, memfunc));
03410       addPreComponentActionListener(listener_type, listener, true);
03411       return listener;
03412     }
03413 
03433     void 
03434     removePreComponentActionListener(
03435                                  PreComponentActionListenerType listener_type,
03436                                  PreComponentActionListener* listener);
03437 
03438 
03511     typedef PostComponentActionListener PostCompActionListener;
03512     typedef PostComponentActionListenerType PostCompActionListenerType;
03513     void 
03514     addPostComponentActionListener(
03515                                PostComponentActionListenerType listener_type,
03516                                PostComponentActionListener* listener,
03517                                bool autoclean = true);
03518 
03519     template <class Listener>
03520     PostComponentActionListener*
03521     addPostComponentActionListener(PostCompActionListenerType listener_type,
03522                                    Listener& obj,
03523                                    void (Listener::*memfunc)(UniqueId ec_id,
03524                                                              ReturnCode_t ret))
03525     {
03526       class Noname
03527         : public PostComponentActionListener
03528       {
03529       public:
03530         Noname(Listener& obj, void (Listener::*memfunc)(UniqueId, ReturnCode_t))
03531           : m_obj(obj), m_memfunc(memfunc)
03532         {
03533         }
03534         void operator()(UniqueId ec_id, ReturnCode_t ret)
03535         {
03536           (m_obj.*m_memfunc)(ec_id, ret);
03537         }
03538       private:
03539         Listener& m_obj;
03540         typedef void (Listener::*Memfunc)(UniqueId ec_id, ReturnCode_t ret);
03541         Memfunc m_memfunc;
03542       };
03543       Noname* listener(new Noname(obj, memfunc));
03544       addPostComponentActionListener(listener_type, listener, true);
03545       return listener;
03546     }
03547 
03567     void 
03568     removePostComponentActionListener(
03569                                   PostComponentActionListenerType listener_type,
03570                                   PostComponentActionListener* listener);
03571 
03572 
03573 
03627     void 
03628     addPortActionListener(PortActionListenerType listener_type,
03629                           PortActionListener* listener,
03630                           bool autoclean = true);
03631     
03632     template <class Listener>
03633     PortActionListener*
03634     addPortActionListener(PortActionListenerType listener_type,
03635                           Listener& obj,
03636                           void (Listener::*memfunc)(const RTC::PortProfile&))
03637     {
03638       class Noname
03639         : public PortActionListener
03640       {
03641       public:
03642         Noname(Listener& obj,
03643                void (Listener::*memfunc)(const RTC::PortProfile&))
03644           : m_obj(obj), m_memfunc(memfunc)
03645         {
03646         }
03647         void operator()(const RTC::PortProfile& pprofile)
03648         {
03649           (m_obj.*m_memfunc)(pprofile);
03650         }
03651       private:
03652         Listener& m_obj;
03653         typedef void (Listener::*Memfunc)(const RTC::PortProfile&);
03654         Memfunc m_memfunc;
03655       };
03656       Noname* listener(new Noname(obj, memfunc));
03657       addPortActionListener(listener_type, listener, true);
03658       return listener;
03659     }
03660 
03680     void 
03681     removePortActionListener(PortActionListenerType listener_type,
03682                              PortActionListener* listener);
03683 
03684 
03685 
03739     typedef ExecutionContextActionListenerType ECActionListenerType;
03740     typedef ExecutionContextActionListener ECActionListener;
03741     void addExecutionContextActionListener(ECActionListenerType listener_type,
03742                                            ECActionListener* listener,
03743                                            bool autoclean = true);
03744 
03745     template <class Listener>
03746     ECActionListener*
03747     addExecutionContextActionListener(ECActionListenerType listener_type,
03748                                       Listener& obj,
03749                                       void (Listener::*memfunc)(UniqueId))
03750     {
03751       class Noname
03752         : public ECActionListener
03753       {
03754       public:
03755         Noname(Listener& obj, void (Listener::*memfunc)(UniqueId))
03756           : m_obj(obj), m_memfunc(memfunc)
03757         {
03758         }
03759         void operator()(UniqueId ec_id)
03760         {
03761           (m_obj.*m_memfunc)(ec_id);
03762         }
03763       private:
03764         Listener& m_obj;
03765         typedef void (Listener::*Memfunc)(UniqueId);
03766         Memfunc m_memfunc;
03767       };
03768       Noname* listener(new Noname(obj, memfunc));
03769       addExecutionContextActionListener(listener_type, listener, true);
03770       return listener;
03771     }
03772     
03773 
03793     void 
03794     removeExecutionContextActionListener(ECActionListenerType listener_type,
03795                                          ECActionListener* listener);
03796 
03797 
03852     void addPortConnectListener(PortConnectListenerType listener_type,
03853                                            PortConnectListener* listener,
03854                                            bool autoclean = true);
03855 
03856     template <class Listener>
03857     PortConnectListener*
03858     addPortConnectListener(PortConnectListenerType listener_type,
03859                            Listener& obj,
03860                            void (Listener::*memfunc)(const char*,
03861                                                      ConnectorProfile&))
03862     {
03863       class Noname
03864         : public PortConnectListener
03865       {
03866       public:
03867         Noname(Listener& obj,
03868                void (Listener::*memfunc)(const char*, ConnectorProfile&))
03869           : m_obj(obj), m_memfunc(memfunc)
03870         {
03871         }
03872         void operator()(const char* portname, ConnectorProfile& cprofile)
03873         {
03874           (m_obj.*m_memfunc)(portname, cprofile);
03875         }
03876       private:
03877         Listener& m_obj;
03878         typedef void (Listener::*Memfunc)(const char*, ConnectorProfile&);
03879         Memfunc m_memfunc;
03880       };
03881       Noname* listener(new Noname(obj, memfunc));
03882       addPortConnectListener(listener_type, listener, true);
03883       return listener;
03884     }
03885     
03886 
03906     void 
03907     removePortConnectListener(PortConnectListenerType listener_type,
03908                               PortConnectListener* listener);
03909 
03968     void addPortConnectRetListener(PortConnectRetListenerType listener_type,
03969                                            PortConnectRetListener* listener,
03970                                            bool autoclean = true);
03971 
03972     template <class Listener>
03973     PortConnectRetListener*
03974     addPortConnectRetListener(PortConnectRetListenerType listener_type,
03975                               Listener& obj,
03976                               void (Listener::*memfunc)(const char*,
03977                                                         ConnectorProfile&,
03978                                                         ReturnCode_t))
03979     {
03980       class Noname
03981         : public PortConnectRetListener
03982       {
03983       public:
03984         Noname(Listener& obj,
03985                void (Listener::*memfunc)(const char*,
03986                                          ConnectorProfile&,
03987                                          ReturnCode_t))
03988           : m_obj(obj), m_memfunc(memfunc)
03989         {
03990         }
03991         void operator()(const char* portname,
03992                         ConnectorProfile& cprofile,
03993                         ReturnCode_t ret)
03994         {
03995           (m_obj.*m_memfunc)(portname, cprofile, ret);
03996         }
03997       private:
03998         Listener& m_obj;
03999         typedef void (Listener::*Memfunc)(const char* portname,
04000                                           ConnectorProfile& cprofile,
04001                                           ReturnCode_t ret);
04002         Memfunc m_memfunc;
04003       };
04004       Noname* listener(new Noname(obj, memfunc));
04005       addPortConnectRetListener(listener_type, listener, true);
04006       return listener;
04007     }
04008     
04009 
04029     void 
04030     removePortConnectRetListener(PortConnectRetListenerType listener_type,
04031                                  PortConnectRetListener* listener);
04032 
04033 
04066     void addConfigurationParamListener(ConfigurationParamListenerType type,
04067                                        ConfigurationParamListener* listener,
04068                                        bool autoclean = true);
04069 
04070     template <class Listener>
04071     ConfigurationParamListener*
04072     addConfigurationParamListener(ConfigurationParamListenerType listener_type,
04073                                   Listener& obj,
04074                                   void (Listener::*memfunc)(const char*,
04075                                                             const char*))
04076     {
04077       class Noname
04078         : public ConfigurationParamListener
04079       {
04080       public:
04081         Noname(Listener& obj,
04082                void (Listener::*memfunc)(const char*, const char*))
04083           : m_obj(obj), m_memfunc(memfunc)
04084         {
04085         }
04086         void operator()(const char* config_set_name,
04087                         const char* config_param_name)
04088         {
04089           (m_obj.*m_memfunc)(config_set_name, config_param_name);
04090         }
04091       private:
04092         Listener& m_obj;
04093         typedef void (Listener::*Memfunc)(const char*, const char*);
04094         Memfunc m_memfunc;
04095       };
04096       Noname* listener(new Noname(obj, memfunc));
04097       addConfigurationParamListener(listener_type, listener, true);
04098       return listener;
04099     }
04100 
04125     void removeConfigurationParamListener(ConfigurationParamListenerType type,
04126                                           ConfigurationParamListener* listener);
04127     
04159     void addConfigurationSetListener(ConfigurationSetListenerType type,
04160                                      ConfigurationSetListener* listener,
04161                                      bool autoclean = true);
04162 
04163     template <class Listener>
04164     ConfigurationSetListener*
04165     addConfigurationSetListener(ConfigurationSetListenerType listener_type,
04166                                 Listener& obj,
04167                                 void (Listener::*memfunc)
04168                                 (const coil::Properties& config_set))
04169     {
04170       class Noname
04171         : public ConfigurationSetListener
04172       {
04173       public:
04174         Noname(Listener& obj,
04175                void (Listener::*memfunc)(const coil::Properties& config_set))
04176           : m_obj(obj), m_memfunc(memfunc)
04177         {
04178         }
04179         virtual void operator()(const coil::Properties& config_set)
04180         {
04181           (m_obj.*m_memfunc)(config_set);
04182         }
04183       private:
04184         Listener& m_obj;
04185         typedef void (Listener::*Memfunc)(const coil::Properties& config_set);
04186         Memfunc m_memfunc;
04187       };
04188       Noname* listener(new Noname(obj, memfunc));
04189       addConfigurationSetListener(listener_type, listener, true);
04190       return listener;
04191     }
04192 
04215     void removeConfigurationSetListener(ConfigurationSetListenerType type,
04216                                         ConfigurationSetListener* listener);
04217     
04252     void 
04253     addConfigurationSetNameListener(ConfigurationSetNameListenerType type,
04254                                     ConfigurationSetNameListener* listener,
04255                                     bool autoclean = true);
04256 
04257     template <class Listener>
04258     ConfigurationSetNameListener*
04259     addConfigurationSetNameListener(ConfigurationSetNameListenerType type,
04260                                     Listener& obj,
04261                                     void (Listener::*memfunc)(const char*))
04262     {
04263       class Noname
04264         : public ConfigurationSetNameListener
04265       {
04266       public:
04267         Noname(Listener& obj, void (Listener::*memfunc)(const char*))
04268           : m_obj(obj), m_memfunc(memfunc)
04269         {
04270         }
04271         virtual void operator()(const char* config_set_name)
04272         {
04273           (m_obj.*m_memfunc)(config_set_name);
04274         }
04275       private:
04276         Listener& m_obj;
04277         typedef void (Listener::*Memfunc)(const char*);
04278         Memfunc m_memfunc;
04279       };
04280       Noname* listener(new Noname(obj, memfunc));
04281       addConfigurationSetNameListener(type, listener, true);
04282       return listener;
04283     }
04284 
04311     void
04312     removeConfigurationSetNameListener(ConfigurationSetNameListenerType type,
04313                                        ConfigurationSetNameListener* listener);
04314     
04315   protected:
04335     void shutdown();
04336 
04337     inline void preOnInitialize(UniqueId ec_id)
04338     {
04339       m_actionListeners.preaction_[PRE_ON_INITIALIZE].notify(ec_id);
04340     }
04341 
04342     inline void preOnFinalize(UniqueId ec_id)
04343     {
04344       m_actionListeners.preaction_[PRE_ON_FINALIZE].notify(ec_id);
04345     }
04346 
04347     inline void preOnStartup(UniqueId ec_id)
04348     {
04349       m_actionListeners.preaction_[PRE_ON_STARTUP].notify(ec_id);
04350     }
04351 
04352     inline void preOnShutdown(UniqueId ec_id)
04353     {
04354       m_actionListeners.preaction_[PRE_ON_SHUTDOWN].notify(ec_id);
04355     }
04356 
04357     inline void preOnActivated(UniqueId ec_id)
04358     {
04359       m_actionListeners.preaction_[PRE_ON_ACTIVATED].notify(ec_id);
04360     }
04361 
04362     inline void preOnDeactivated(UniqueId ec_id)
04363     {
04364       m_actionListeners.preaction_[PRE_ON_DEACTIVATED].notify(ec_id);
04365     }
04366 
04367     inline void preOnAborting(UniqueId ec_id)
04368     {
04369       m_actionListeners.preaction_[PRE_ON_ABORTING].notify(ec_id);
04370     }
04371 
04372     inline void preOnError(UniqueId ec_id)
04373     {
04374       m_actionListeners.preaction_[PRE_ON_ERROR].notify(ec_id);
04375     }
04376 
04377     inline void preOnReset(UniqueId ec_id)
04378     {
04379       m_actionListeners.preaction_[PRE_ON_RESET].notify(ec_id);
04380     }
04381 
04382     inline void preOnExecute(UniqueId ec_id)
04383     {
04384       m_actionListeners.preaction_[PRE_ON_EXECUTE].notify(ec_id);
04385     }
04386 
04387     inline void preOnStateUpdate(UniqueId ec_id)
04388     {
04389       m_actionListeners.preaction_[PRE_ON_STATE_UPDATE].notify(ec_id);
04390     }
04391 
04392     inline void preOnRateChanged(UniqueId ec_id)
04393     {
04394       m_actionListeners.preaction_[PRE_ON_RATE_CHANGED].notify(ec_id);
04395     }
04396 
04397     inline void postOnInitialize(UniqueId ec_id, ReturnCode_t ret)
04398     {
04399       m_actionListeners.postaction_[POST_ON_INITIALIZE].notify(ec_id, ret);
04400     }
04401 
04402     inline void postOnFinalize(UniqueId ec_id, ReturnCode_t ret)
04403     {
04404       m_actionListeners.postaction_[POST_ON_FINALIZE].notify(ec_id, ret);
04405     }
04406 
04407     inline void postOnStartup(UniqueId ec_id, ReturnCode_t ret)
04408     {
04409       m_actionListeners.postaction_[POST_ON_STARTUP].notify(ec_id, ret);
04410     }
04411 
04412     inline void postOnShutdown(UniqueId ec_id, ReturnCode_t ret)
04413     {
04414       m_actionListeners.postaction_[POST_ON_SHUTDOWN].notify(ec_id, ret);
04415     }
04416 
04417     inline void postOnActivated(UniqueId ec_id, ReturnCode_t ret)
04418     {
04419       m_actionListeners.postaction_[POST_ON_ACTIVATED].notify(ec_id, ret);
04420     }
04421 
04422     inline void postOnDeactivated(UniqueId ec_id, ReturnCode_t ret)
04423     {
04424       m_actionListeners.postaction_[POST_ON_DEACTIVATED].notify(ec_id, ret);
04425     }
04426 
04427     inline void postOnAborting(UniqueId ec_id, ReturnCode_t ret)
04428     {
04429       m_actionListeners.postaction_[POST_ON_ABORTING].notify(ec_id, ret);
04430     }
04431 
04432     inline void postOnError(UniqueId ec_id, ReturnCode_t ret)
04433     {
04434       m_actionListeners.postaction_[POST_ON_ERROR].notify(ec_id, ret);
04435     }
04436 
04437     inline void postOnReset(UniqueId ec_id, ReturnCode_t ret)
04438     {
04439       m_actionListeners.postaction_[POST_ON_RESET].notify(ec_id, ret);
04440     }
04441 
04442     inline void postOnExecute(UniqueId ec_id, ReturnCode_t ret)
04443     {
04444       m_actionListeners.postaction_[POST_ON_EXECUTE].notify(ec_id, ret);
04445     }
04446 
04447     inline void postOnStateUpdate(UniqueId ec_id, ReturnCode_t ret)
04448     {
04449       m_actionListeners.postaction_[POST_ON_STATE_UPDATE].notify(ec_id, ret);
04450     }
04451 
04452     inline void postOnRateChanged(UniqueId ec_id, ReturnCode_t ret)
04453     {
04454       m_actionListeners.postaction_[POST_ON_RATE_CHANGED].notify(ec_id, ret);
04455     }
04456 
04457     inline void onAddPort(const PortProfile& pprof)
04458     {
04459       m_actionListeners.portaction_[ADD_PORT].notify(pprof);
04460     }
04461     
04462     inline void onRemovePort(const PortProfile& pprof)
04463     {
04464       m_actionListeners.portaction_[REMOVE_PORT].notify(pprof);
04465     }
04466     
04467     inline void onAttachExecutionContext(UniqueId ec_id)
04468     {
04469       m_actionListeners.ecaction_[EC_ATTACHED].notify(ec_id);
04470     }
04471     
04472     inline void onDetachExecutionContext(UniqueId ec_id)
04473     {
04474       m_actionListeners.ecaction_[EC_DETACHED].notify(ec_id);
04475     }
04476     
04477   protected:
04485     mutable Logger rtclog;
04493     Manager* m_pManager;
04494     
04502     CORBA::ORB_var m_pORB;
04503     
04511     PortableServer::POA_var m_pPOA;
04512     
04513     //============================================================
04514     // SDO 関係の変数
04515     //============================================================
04523     SDOPackage::OrganizationList m_sdoOwnedOrganizations;
04524     
04532     struct svc_name
04533     {
04534       svc_name (const char* id) : m_id(id) {};
04535       bool operator()(const SDOPackage::ServiceProfile& prof)
04536       {
04537         return m_id == std::string(prof.id);
04538       }
04539       std::string m_id;
04540     };  // struct svc_name
04541     
04549     SDOPackage::Configuration_impl* m_pSdoConfigImpl;
04550     
04558     SDOPackage::Configuration_var  m_pSdoConfig;
04559     
04567     SDOPackage::OrganizationList m_sdoOrganizations;
04568     
04576     SDOPackage::NVList m_sdoStatus;
04577     
04578     //============================================================
04579     // RTC 関係の変数
04580     //============================================================
04588     ComponentProfile m_profile;
04589     
04597     RTObject_var m_objref;
04598     
04606     PortAdmin m_portAdmin;
04607 
04615     std::vector<InPortBase*> m_inports;
04616 
04624     std::vector<OutPortBase*> m_outports;
04625     
04633     ExecutionContextServiceList m_ecMine;
04634     
04642     std::vector<ExecutionContextBase*> m_eclist;
04643     
04651     ExecutionContextServiceList m_ecOther;
04652     
04660     bool m_created;
04661     
04669     bool m_exiting;
04670     
04678     //    bool m_alive;
04679     
04687     coil::Properties m_properties;
04688     
04696     ConfigAdmin m_configsets;
04697     
04705     SdoServiceAdmin m_sdoservice;
04706 
04714     bool m_readAll;
04715 
04723     bool m_writeAll;
04724 
04741     bool m_readAllCompletion;
04742 
04759     bool m_writeAllCompletion;
04760 
04774     ComponentActionListeners m_actionListeners;
04775 
04789     PortConnectListeners m_portconnListeners;
04790 
04791     //------------------------------------------------------------
04792     // Functor
04793     //------------------------------------------------------------
04801     struct nv_name
04802     {
04803       nv_name(const char* name) : m_name(name) {};
04804       bool operator()(const SDOPackage::NameValue& nv)
04805       {
04806         return m_name == std::string(nv.name);
04807       }
04808       std::string m_name;
04809     };  // struct nv_name
04810     
04818     struct ec_copy
04819     {
04820       ec_copy(ExecutionContextList& eclist)
04821         : m_eclist(eclist)
04822       {
04823       }
04824       void operator()(ExecutionContextService_ptr ecs)
04825       {
04826         if (!::CORBA::is_nil(ecs))
04827           {
04828             CORBA_SeqUtil::push_back(m_eclist,
04829                                      ExecutionContext::_duplicate(ecs));
04830           }
04831       }
04832       ExecutionContextList& m_eclist;
04833     };  // struct ec_copy
04841     struct ec_find
04842     {
04843       ec_find(ExecutionContext_ptr& ec)
04844         : m_ec(ExecutionContext::_duplicate(ec))
04845       {
04846       }
04847       bool operator()(ExecutionContextService_ptr ecs)
04848       {
04849         try
04850           {
04851             if (!::CORBA::is_nil(ecs))
04852               {
04853                 ExecutionContext_var ec;
04854                 ec = ExecutionContext::_narrow(ecs);
04855                 return m_ec->_is_equivalent(ec);
04856               }
04857           }
04858         catch (...)
04859           {
04860             return false;
04861           }
04862         return false;
04863       }
04864       ExecutionContext_var m_ec;
04865 
04866     };  // struct ec_find
04867     //    ExecutionContextAdminList m_execContextList;
04868     
04876     struct deactivate_comps
04877     {
04878       deactivate_comps(LightweightRTObject_ptr comp)
04879         : m_comp(RTC::LightweightRTObject::_duplicate(comp))
04880       {
04881       }
04882       void operator()(ExecutionContextService_ptr ec)
04883       {
04884         if (!::CORBA::is_nil(ec) && !ec->_non_existent())
04885           {
04886             
04887             ec->deactivate_component(RTC::LightweightRTObject::_duplicate(m_comp));
04888             ec->stop();
04889           }
04890       }
04891       LightweightRTObject_var m_comp;
04892     };  // struct deactivate_comps
04893   };  // class RTObject_impl
04894 };  // namespace RTC
04895 
04896 #ifdef WIN32
04897 #pragma warning( default : 4290 )
04898 #endif
04899 
04900 #endif // RTC_RTOBJECT


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Sun Mar 26 2017 03:37:17