00001 
00018 #ifndef RTC_RTOBJECT_H
00019 #define RTC_RTOBJECT_H
00020 
00021 
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     
00152     
00180     
00181     
00182     virtual ReturnCode_t onInitialize();
00183     
00211     
00212     
00213     virtual ReturnCode_t onFinalize();
00214     
00246     
00247     
00248     virtual ReturnCode_t onStartup(RTC::UniqueId exec_handle);
00249     
00281     
00282     
00283     virtual ReturnCode_t onShutdown(RTC::UniqueId exec_handle);
00284     
00316     
00317     
00318     virtual ReturnCode_t onActivated(RTC::UniqueId exec_handle);
00319     
00351     
00352     
00353     virtual ReturnCode_t onDeactivated(RTC::UniqueId exec_handle);
00354     
00391     
00392     
00393     virtual ReturnCode_t onExecute(RTC::UniqueId exec_handle);
00394     
00426     
00427     
00428     virtual ReturnCode_t onAborting(RTC::UniqueId exec_handle);
00429     
00460     
00461     
00462     virtual ReturnCode_t onError(RTC::UniqueId exec_handle);
00463     
00494     
00495     
00496     virtual ReturnCode_t onReset(RTC::UniqueId exec_handle);
00497     
00534     
00535     
00536     virtual ReturnCode_t onStateUpdate(RTC::UniqueId exec_handle);
00537     
00573     
00574     
00575     virtual ReturnCode_t onRateChanged(RTC::UniqueId exec_handle);
00576     
00577   public:
00578     
00579     
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     
00920     
00940     virtual ComponentProfile* get_component_profile()
00941       throw (CORBA::SystemException);
00942     
00962     virtual PortServiceList* get_ports()
00963       throw (CORBA::SystemException);
00964     
00986     
00987     
00988     
00989     
00990     
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     
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     
01421     
01459     virtual SDOPackage::OrganizationList* get_owned_organizations()
01460       throw (CORBA::SystemException,
01461              SDOPackage::NotAvailable, SDOPackage::InternalError);
01462     
01463     
01464     
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     
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     
02805     ReturnCode_t addSdoService(const SDOPackage::ServiceProfile& profile);
02806 
02822     SDOPackage::SDOService_var removeSdoService(const char* service_name);
02823 
02844     bool readAll();
02845 
02866     bool writeAll();
02867 
02902     void setReadAll(bool read=true, bool completion=false);
02903 
02938     void setWriteAll(bool write=true, bool completion=false);
02939 
02940 
02957     void finalizePorts();
02958 
02959 
02971     void finalizeContexts();
02972 
02973 
03046     typedef PreComponentActionListener PreCompActionListener;
03047     typedef PreComponentActionListenerType PreCompActionListenerType;
03048     void 
03049     addPreComponentActionListener(PreComponentActionListenerType listener_type,
03050                                   PreComponentActionListener* listener,
03051                                   bool autoclean = true);
03052 
03053 
03054     template <class Listener>
03055     PreComponentActionListener*
03056     addPortComponentActionListener(PreCompActionListenerType listener_type,
03057                                    Listener& obj,
03058                                    void (Listener::*memfunc)(UniqueId ec_id))
03059     {
03060       class Noname
03061         : public PreComponentActionListener
03062       {
03063       public:
03064         Noname(Listener& obj, void (Listener::*memfunc)(UniqueId))
03065           : m_obj(obj), m_memfunc(memfunc)
03066         {
03067         }
03068         void operator()(UniqueId ec_id)
03069         {
03070           (m_obj.*m_memfunc)(ec_id);
03071         }
03072       private:
03073         Listener& m_obj;
03074         typedef void (Listener::*Memfunc)(UniqueId ec_id);
03075         Memfunc m_memfunc;
03076       };
03077       Noname* listener(new Noname(obj, memfunc));
03078       addPreComponentActionListener(listener_type, listener, true);
03079       return listener;
03080     }
03081 
03101     void 
03102     removePreComponentActionListener(
03103                                  PreComponentActionListenerType listener_type,
03104                                  PreComponentActionListener* listener);
03105 
03106 
03179     typedef PostComponentActionListener PostCompActionListener;
03180     typedef PostComponentActionListenerType PostCompActionListenerType;
03181     void 
03182     addPostComponentActionListener(
03183                                PostComponentActionListenerType listener_type,
03184                                PostComponentActionListener* listener,
03185                                bool autoclean = true);
03186 
03187     template <class Listener>
03188     PostComponentActionListener*
03189     addPostComponentActionListener(PostCompActionListenerType listener_type,
03190                                    Listener& obj,
03191                                    void (Listener::*memfunc)(UniqueId ec_id,
03192                                                              ReturnCode_t ret))
03193     {
03194       class Noname
03195         : public PostComponentActionListener
03196       {
03197       public:
03198         Noname(Listener& obj, void (Listener::*memfunc)(UniqueId, ReturnCode_t))
03199           : m_obj(obj), m_memfunc(memfunc)
03200         {
03201         }
03202         void operator()(UniqueId ec_id, ReturnCode_t ret)
03203         {
03204           (m_obj.*m_memfunc)(ec_id, ret);
03205         }
03206       private:
03207         Listener& m_obj;
03208         typedef void (Listener::*Memfunc)(UniqueId ec_id, ReturnCode_t ret);
03209         Memfunc m_memfunc;
03210       };
03211       Noname* listener(new Noname(obj, memfunc));
03212       addPostComponentActionListener(listener_type, listener, true);
03213       return listener;
03214     }
03215 
03235     void 
03236     removePostComponentActionListener(
03237                                   PostComponentActionListenerType listener_type,
03238                                   PostComponentActionListener* listener);
03239 
03240 
03241 
03295     void 
03296     addPortActionListener(PortActionListenerType listener_type,
03297                           PortActionListener* listener,
03298                           bool autoclean = true);
03299     
03300     template <class Listener>
03301     PortActionListener*
03302     addPortActionListener(PortActionListenerType listener_type,
03303                           Listener& obj,
03304                           void (Listener::*memfunc)(const RTC::PortProfile&))
03305     {
03306       class Noname
03307         : public PortActionListener
03308       {
03309       public:
03310         Noname(Listener& obj,
03311                void (Listener::*memfunc)(const RTC::PortProfile&))
03312           : m_obj(obj), m_memfunc(memfunc)
03313         {
03314         }
03315         void operator()(const RTC::PortProfile& pprofile)
03316         {
03317           (m_obj.*m_memfunc)(pprofile);
03318         }
03319       private:
03320         Listener& m_obj;
03321         typedef void (Listener::*Memfunc)(const RTC::PortProfile&);
03322         Memfunc m_memfunc;
03323       };
03324       Noname* listener(new Noname(obj, memfunc));
03325       addPortActionListener(listener_type, listener, true);
03326       return listener;
03327     }
03328 
03348     void 
03349     removePortActionListener(PortActionListenerType listener_type,
03350                              PortActionListener* listener);
03351 
03352 
03353 
03407     typedef ExecutionContextActionListenerType ECActionListenerType;
03408     typedef ExecutionContextActionListener ECActionListener;
03409     void addExecutionContextActionListener(ECActionListenerType listener_type,
03410                                            ECActionListener* listener,
03411                                            bool autoclean = true);
03412 
03413     template <class Listener>
03414     ECActionListener*
03415     addExecutionContextActionListener(ECActionListenerType listener_type,
03416                                       Listener& obj,
03417                                       void (Listener::*memfunc)(UniqueId))
03418     {
03419       class Noname
03420         : public ECActionListener
03421       {
03422       public:
03423         Noname(Listener& obj, void (Listener::*memfunc)(UniqueId))
03424           : m_obj(obj), m_memfunc(memfunc)
03425         {
03426         }
03427         void operator()(UniqueId ec_id)
03428         {
03429           (m_obj.*m_memfunc)(ec_id);
03430         }
03431       private:
03432         Listener& m_obj;
03433         typedef void (Listener::*Memfunc)(UniqueId);
03434         Memfunc m_memfunc;
03435       };
03436       Noname* listener(new Noname(obj, memfunc));
03437       addExecutionContextActionListener(listener_type, listener, true);
03438       return listener;
03439     }
03440     
03441 
03461     void 
03462     removeExecutionContextActionListener(ECActionListenerType listener_type,
03463                                          ECActionListener* listener);
03464 
03465 
03520     void addPortConnectListener(PortConnectListenerType listener_type,
03521                                            PortConnectListener* listener,
03522                                            bool autoclean = true);
03523 
03524     template <class Listener>
03525     PortConnectListener*
03526     addPortConnectListener(PortConnectListenerType listener_type,
03527                            Listener& obj,
03528                            void (Listener::*memfunc)(const char*,
03529                                                      ConnectorProfile&))
03530     {
03531       class Noname
03532         : public PortConnectListener
03533       {
03534       public:
03535         Noname(Listener& obj,
03536                void (Listener::*memfunc)(const char*, ConnectorProfile&))
03537           : m_obj(obj), m_memfunc(memfunc)
03538         {
03539         }
03540         void operator()(const char* portname, ConnectorProfile& cprofile)
03541         {
03542           (m_obj.*m_memfunc)(portname, cprofile);
03543         }
03544       private:
03545         Listener& m_obj;
03546         typedef void (Listener::*Memfunc)(const char*, ConnectorProfile&);
03547         Memfunc m_memfunc;
03548       };
03549       Noname* listener(new Noname(obj, memfunc));
03550       addPortConnectListener(listener_type, listener, true);
03551       return listener;
03552     }
03553     
03554 
03574     void 
03575     removePortConnectListener(PortConnectListenerType listener_type,
03576                               PortConnectListener* listener);
03577 
03636     void addPortConnectRetListener(PortConnectRetListenerType listener_type,
03637                                            PortConnectRetListener* listener,
03638                                            bool autoclean = true);
03639 
03640     template <class Listener>
03641     PortConnectRetListener*
03642     addPortConnectRetListener(PortConnectRetListenerType listener_type,
03643                               Listener& obj,
03644                               void (Listener::*memfunc)(const char*,
03645                                                         ConnectorProfile&,
03646                                                         ReturnCode_t))
03647     {
03648       class Noname
03649         : public PortConnectRetListener
03650       {
03651       public:
03652         Noname(Listener& obj,
03653                void (Listener::*memfunc)(const char*,
03654                                          ConnectorProfile&,
03655                                          ReturnCode_t))
03656           : m_obj(obj), m_memfunc(memfunc)
03657         {
03658         }
03659         void operator()(const char* portname,
03660                         ConnectorProfile& cprofile,
03661                         ReturnCode_t ret)
03662         {
03663           (m_obj.*m_memfunc)(portname, cprofile, ret);
03664         }
03665       private:
03666         Listener& m_obj;
03667         typedef void (Listener::*Memfunc)(const char* portname,
03668                                           ConnectorProfile& cprofile,
03669                                           ReturnCode_t ret);
03670         Memfunc m_memfunc;
03671       };
03672       Noname* listener(new Noname(obj, memfunc));
03673       addPortConnectRetListener(listener_type, listener, true);
03674       return listener;
03675     }
03676     
03677 
03697     void 
03698     removePortConnectRetListener(PortConnectRetListenerType listener_type,
03699                                  PortConnectRetListener* listener);
03700 
03701 
03734     void addConfigurationParamListener(ConfigurationParamListenerType type,
03735                                        ConfigurationParamListener* listener,
03736                                        bool autoclean = true);
03737 
03738     template <class Listener>
03739     ConfigurationParamListener*
03740     addConfigurationParamListener(ConfigurationParamListenerType listener_type,
03741                                   Listener& obj,
03742                                   void (Listener::*memfunc)(const char*,
03743                                                             const char*))
03744     {
03745       class Noname
03746         : public ConfigurationParamListener
03747       {
03748       public:
03749         Noname(Listener& obj,
03750                void (Listener::*memfunc)(const char*, const char*))
03751           : m_obj(obj), m_memfunc(memfunc)
03752         {
03753         }
03754         void operator()(const char* config_set_name,
03755                         const char* config_param_name)
03756         {
03757           (m_obj.*m_memfunc)(config_set_name, config_param_name);
03758         }
03759       private:
03760         Listener& m_obj;
03761         typedef void (Listener::*Memfunc)(const char*, const char*);
03762         Memfunc m_memfunc;
03763       };
03764       Noname* listener(new Noname(obj, memfunc));
03765       addConfigurationParamListener(listener_type, listener, true);
03766       return listener;
03767     }
03768 
03793     void removeConfigurationParamListener(ConfigurationParamListenerType type,
03794                                           ConfigurationParamListener* listener);
03795     
03827     void addConfigurationSetListener(ConfigurationSetListenerType type,
03828                                      ConfigurationSetListener* listener,
03829                                      bool autoclean = true);
03830 
03831     template <class Listener>
03832     ConfigurationSetListener*
03833     addConfigurationSetListener(ConfigurationSetListenerType listener_type,
03834                                 Listener& obj,
03835                                 void (Listener::*memfunc)
03836                                 (const coil::Properties& config_set))
03837     {
03838       class Noname
03839         : public ConfigurationSetListener
03840       {
03841       public:
03842         Noname(Listener& obj,
03843                void (Listener::*memfunc)(const coil::Properties& config_set))
03844           : m_obj(obj), m_memfunc(memfunc)
03845         {
03846         }
03847         virtual void operator()(const coil::Properties& config_set)
03848         {
03849           (m_obj.*m_memfunc)(config_set);
03850         }
03851       private:
03852         Listener& m_obj;
03853         typedef void (Listener::*Memfunc)(const coil::Properties& config_set);
03854         Memfunc m_memfunc;
03855       };
03856       Noname* listener(new Noname(obj, memfunc));
03857       addConfigurationSetListener(listener_type, listener, true);
03858       return listener;
03859     }
03860 
03883     void removeConfigurationSetListener(ConfigurationSetListenerType type,
03884                                         ConfigurationSetListener* listener);
03885     
03920     void 
03921     addConfigurationSetNameListener(ConfigurationSetNameListenerType type,
03922                                     ConfigurationSetNameListener* listener,
03923                                     bool autoclean = true);
03924 
03925     template <class Listener>
03926     ConfigurationSetNameListener*
03927     addConfigurationSetNameListener(ConfigurationSetNameListenerType type,
03928                                     Listener& obj,
03929                                     void (Listener::*memfunc)(const char*))
03930     {
03931       class Noname
03932         : public ConfigurationSetNameListener
03933       {
03934       public:
03935         Noname(Listener& obj, void (Listener::*memfunc)(const char*))
03936           : m_obj(obj), m_memfunc(memfunc)
03937         {
03938         }
03939         virtual void operator()(const char* config_set_name)
03940         {
03941           (m_obj.*m_memfunc)(config_set_name);
03942         }
03943       private:
03944         Listener& m_obj;
03945         typedef void (Listener::*Memfunc)(const char*);
03946         Memfunc m_memfunc;
03947       };
03948       Noname* listener(new Noname(obj, memfunc));
03949       addConfigurationSetNameListener(type, listener, true);
03950       return listener;
03951     }
03952 
03979     void
03980     removeConfigurationSetNameListener(ConfigurationSetNameListenerType type,
03981                                        ConfigurationSetNameListener* listener);
03982     
03983   protected:
04003     void shutdown();
04004 
04005     inline void preOnInitialize(UniqueId ec_id)
04006     {
04007       m_actionListeners.preaction_[PRE_ON_INITIALIZE].notify(ec_id);
04008     }
04009 
04010     inline void preOnFinalize(UniqueId ec_id)
04011     {
04012       m_actionListeners.preaction_[PRE_ON_FINALIZE].notify(ec_id);
04013     }
04014 
04015     inline void preOnStartup(UniqueId ec_id)
04016     {
04017       m_actionListeners.preaction_[PRE_ON_STARTUP].notify(ec_id);
04018     }
04019 
04020     inline void preOnShutdown(UniqueId ec_id)
04021     {
04022       m_actionListeners.preaction_[PRE_ON_SHUTDOWN].notify(ec_id);
04023     }
04024 
04025     inline void preOnActivated(UniqueId ec_id)
04026     {
04027       m_actionListeners.preaction_[PRE_ON_ACTIVATED].notify(ec_id);
04028     }
04029 
04030     inline void preOnDeactivated(UniqueId ec_id)
04031     {
04032       m_actionListeners.preaction_[PRE_ON_DEACTIVATED].notify(ec_id);
04033     }
04034 
04035     inline void preOnAborting(UniqueId ec_id)
04036     {
04037       m_actionListeners.preaction_[PRE_ON_ABORTING].notify(ec_id);
04038     }
04039 
04040     inline void preOnError(UniqueId ec_id)
04041     {
04042       m_actionListeners.preaction_[PRE_ON_ERROR].notify(ec_id);
04043     }
04044 
04045     inline void preOnReset(UniqueId ec_id)
04046     {
04047       m_actionListeners.preaction_[PRE_ON_RESET].notify(ec_id);
04048     }
04049 
04050     inline void preOnExecute(UniqueId ec_id)
04051     {
04052       m_actionListeners.preaction_[PRE_ON_EXECUTE].notify(ec_id);
04053     }
04054 
04055     inline void preOnStateUpdate(UniqueId ec_id)
04056     {
04057       m_actionListeners.preaction_[PRE_ON_STATE_UPDATE].notify(ec_id);
04058     }
04059 
04060     inline void preOnRateChanged(UniqueId ec_id)
04061     {
04062       m_actionListeners.preaction_[PRE_ON_RATE_CHANGED].notify(ec_id);
04063     }
04064 
04065     inline void postOnInitialize(UniqueId ec_id, ReturnCode_t ret)
04066     {
04067       m_actionListeners.postaction_[POST_ON_INITIALIZE].notify(ec_id, ret);
04068     }
04069 
04070     inline void postOnFinalize(UniqueId ec_id, ReturnCode_t ret)
04071     {
04072       m_actionListeners.postaction_[POST_ON_FINALIZE].notify(ec_id, ret);
04073     }
04074 
04075     inline void postOnStartup(UniqueId ec_id, ReturnCode_t ret)
04076     {
04077       m_actionListeners.postaction_[POST_ON_STARTUP].notify(ec_id, ret);
04078     }
04079 
04080     inline void postOnShutdown(UniqueId ec_id, ReturnCode_t ret)
04081     {
04082       m_actionListeners.postaction_[POST_ON_SHUTDOWN].notify(ec_id, ret);
04083     }
04084 
04085     inline void postOnActivated(UniqueId ec_id, ReturnCode_t ret)
04086     {
04087       m_actionListeners.postaction_[POST_ON_ACTIVATED].notify(ec_id, ret);
04088     }
04089 
04090     inline void postOnDeactivated(UniqueId ec_id, ReturnCode_t ret)
04091     {
04092       m_actionListeners.postaction_[POST_ON_DEACTIVATED].notify(ec_id, ret);
04093     }
04094 
04095     inline void postOnAborting(UniqueId ec_id, ReturnCode_t ret)
04096     {
04097       m_actionListeners.postaction_[POST_ON_ABORTING].notify(ec_id, ret);
04098     }
04099 
04100     inline void postOnError(UniqueId ec_id, ReturnCode_t ret)
04101     {
04102       m_actionListeners.postaction_[POST_ON_ERROR].notify(ec_id, ret);
04103     }
04104 
04105     inline void postOnReset(UniqueId ec_id, ReturnCode_t ret)
04106     {
04107       m_actionListeners.postaction_[POST_ON_RESET].notify(ec_id, ret);
04108     }
04109 
04110     inline void postOnExecute(UniqueId ec_id, ReturnCode_t ret)
04111     {
04112       m_actionListeners.postaction_[POST_ON_EXECUTE].notify(ec_id, ret);
04113     }
04114 
04115     inline void postOnStateUpdate(UniqueId ec_id, ReturnCode_t ret)
04116     {
04117       m_actionListeners.postaction_[POST_ON_STATE_UPDATE].notify(ec_id, ret);
04118     }
04119 
04120     inline void postOnRateChanged(UniqueId ec_id, ReturnCode_t ret)
04121     {
04122       m_actionListeners.postaction_[POST_ON_RATE_CHANGED].notify(ec_id, ret);
04123     }
04124 
04125     inline void onAddPort(const PortProfile& pprof)
04126     {
04127       m_actionListeners.portaction_[ADD_PORT].notify(pprof);
04128     }
04129     
04130     inline void onRemovePort(const PortProfile& pprof)
04131     {
04132       m_actionListeners.portaction_[REMOVE_PORT].notify(pprof);
04133     }
04134     
04135     inline void onAttachExecutionContext(UniqueId ec_id)
04136     {
04137       m_actionListeners.ecaction_[EC_ATTACHED].notify(ec_id);
04138     }
04139     
04140     inline void onDetachExecutionContext(UniqueId ec_id)
04141     {
04142       m_actionListeners.ecaction_[EC_DETACHED].notify(ec_id);
04143     }
04144     
04145   protected:
04153     mutable Logger rtclog;
04161     Manager* m_pManager;
04162     
04170     CORBA::ORB_var m_pORB;
04171     
04179     PortableServer::POA_var m_pPOA;
04180     
04181     
04182     
04183     
04191     SDOPackage::OrganizationList m_sdoOwnedOrganizations;
04192     
04200     SDOPackage::ServiceProfileList m_sdoSvcProfiles;
04201     
04209     struct svc_name
04210     {
04211       svc_name (const char* id) : m_id(id) {};
04212       bool operator()(const SDOPackage::ServiceProfile& prof)
04213       {
04214         return m_id == std::string(prof.id);
04215       }
04216       std::string m_id;
04217     };  
04218     
04226     SDOPackage::Configuration_impl* m_pSdoConfigImpl;
04227     
04235     SDOPackage::Configuration_var  m_pSdoConfig;
04236     
04244     SDOPackage::OrganizationList m_sdoOrganizations;
04245     
04253     SDOPackage::NVList m_sdoStatus;
04254     
04255     
04256     
04257     
04265     ComponentProfile m_profile;
04266     
04274     RTObject_var m_objref;
04275     
04283     PortAdmin m_portAdmin;
04284 
04292     std::vector<InPortBase*> m_inports;
04293 
04301     std::vector<OutPortBase*> m_outports;
04302     
04310     ExecutionContextServiceList m_ecMine;
04311     
04319     std::vector<ExecutionContextBase*> m_eclist;
04320     
04328     ExecutionContextServiceList m_ecOther;
04329     
04337     bool m_created;
04338     
04346     bool m_exiting;
04347     
04355     
04356     
04364     coil::Properties m_properties;
04365     
04373     ConfigAdmin m_configsets;
04374     
04382     SdoServiceAdmin m_sdoservice;
04383 
04391     bool m_readAll;
04392 
04400     bool m_writeAll;
04401 
04418     bool m_readAllCompletion;
04419 
04436     bool m_writeAllCompletion;
04437 
04451     ComponentActionListeners m_actionListeners;
04452 
04466     PortConnectListeners m_portconnListeners;
04467 
04468     
04469     
04470     
04478     struct nv_name
04479     {
04480       nv_name(const char* name) : m_name(name) {};
04481       bool operator()(const SDOPackage::NameValue& nv)
04482       {
04483         return m_name == std::string(nv.name);
04484       }
04485       std::string m_name;
04486     };  
04487     
04495     struct ec_copy
04496     {
04497       ec_copy(ExecutionContextList& eclist)
04498         : m_eclist(eclist)
04499       {
04500       }
04501       void operator()(ExecutionContextService_ptr ecs)
04502       {
04503         if (!::CORBA::is_nil(ecs))
04504           {
04505             CORBA_SeqUtil::push_back(m_eclist, ExecutionContext::_duplicate(ecs));
04506           }
04507       }
04508       ExecutionContextList& m_eclist;
04509     };  
04510 
04511     struct ec_find
04512     {
04513       ec_find(ExecutionContext_ptr& ec)
04514         : m_ec(ExecutionContext::_duplicate(ec))
04515       {
04516       }
04517       bool operator()(ExecutionContextService_ptr ecs)
04518       {
04519         try
04520           {
04521             if (!::CORBA::is_nil(ecs))
04522               {
04523                 ExecutionContext_var ec;
04524                 ec = ExecutionContext::_narrow(ecs);
04525                 return m_ec->_is_equivalent(ec);
04526               }
04527           }
04528         catch (...)
04529           {
04530             return false;
04531           }
04532         return false;
04533       }
04534       ExecutionContext_var m_ec;
04535 
04536     };  
04537     
04538     
04546     struct deactivate_comps
04547     {
04548       deactivate_comps(LightweightRTObject_ptr comp)
04549         : m_comp(RTC::LightweightRTObject::_duplicate(comp))
04550       {
04551       }
04552       void operator()(ExecutionContextService_ptr ec)
04553       {
04554         if (!::CORBA::is_nil(ec) && !ec->_non_existent())
04555           {
04556             ec->deactivate_component(RTC::LightweightRTObject::_duplicate(m_comp));
04557           }
04558       }
04559       LightweightRTObject_var m_comp;
04560     };  
04561   };  
04562 };  
04563 
04564 #ifdef WIN32
04565 #pragma warning( default : 4290 )
04566 #endif
04567 
04568 #endif // RTC_RTOBJECT