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
02327 ConfigAdmin& getConfigService() { return m_configsets; }
02328
02350 void updateParameters(const char* config_set);
02351
02385 bool addPort(PortBase& port);
02419 bool addPort(PortService_ptr port);
02453 bool addPort(CorbaPort& port);
02485 void registerPort(PortBase& port);
02517 void registerPort(PortService_ptr port);
02549 void registerPort(CorbaPort& port);
02550
02579 bool addInPort(const char* name, InPortBase& inport);
02606 void registerInPort(const char* name, InPortBase& inport);
02607
02636 bool addOutPort(const char* name, OutPortBase& outport);
02663 void registerOutPort(const char* name, OutPortBase& outport);
02664
02686 bool removeInPort(InPortBase& port);
02687
02709 bool removeOutPort(OutPortBase& port);
02710
02732 bool removePort(PortBase& port);
02754 bool removePort(PortService_ptr port);
02776 bool removePort(CorbaPort& port);
02796 void deletePort(PortBase& port);
02816 void deletePort(PortService_ptr port);
02836 void deletePort(CorbaPort& port);
02837
02857 void deletePortByName(const char* port_name);
02858
02909 ExecutionContext_ptr getExecutionContext(RTC::UniqueId ec_id);
02910
02963 double getExecutionRate(RTC::UniqueId ec_id);
02964
03018 ReturnCode_t setExecutionRate(RTC::UniqueId ec_id, double rate);
03019
03072 bool isOwnExecutionContext(RTC::UniqueId ec_id);
03073
03112 ReturnCode_t deactivate(RTC::UniqueId ec_id);
03113
03150 ReturnCode_t activate(RTC::UniqueId ec_id);
03151
03186 ReturnCode_t reset(RTC::UniqueId ec_id);
03187
03195 bool addSdoServiceProvider(const SDOPackage::ServiceProfile& prof,
03196 SdoServiceProviderBase* provider);
03197
03205 bool removeSdoServiceProvider(const char* id);
03206
03214 bool addSdoServiceConsumer(const SDOPackage::ServiceProfile& prof);
03215
03223 bool removeSdoServiceConsumer(const char* id);
03224
03245 bool readAll();
03246
03267 bool writeAll();
03268
03303 void setReadAll(bool read=true, bool completion=false);
03304
03339 void setWriteAll(bool write=true, bool completion=false);
03340
03341
03358 void finalizePorts();
03359
03360
03372 void finalizeContexts();
03373
03374
03447 typedef PreComponentActionListener PreCompActionListener;
03448 typedef PreComponentActionListenerType PreCompActionListenerType;
03449 void
03450 addPreComponentActionListener(PreComponentActionListenerType listener_type,
03451 PreComponentActionListener* listener,
03452 bool autoclean = true);
03453
03454
03455 template <class Listener>
03456 PreComponentActionListener*
03457 addPreComponentActionListener(PreCompActionListenerType listener_type,
03458 Listener& obj,
03459 void (Listener::*memfunc)(UniqueId ec_id))
03460 {
03461 class Noname
03462 : public PreComponentActionListener
03463 {
03464 public:
03465 Noname(Listener& obj, void (Listener::*memfunc)(UniqueId))
03466 : m_obj(obj), m_memfunc(memfunc)
03467 {
03468 }
03469 void operator()(UniqueId ec_id)
03470 {
03471 (m_obj.*m_memfunc)(ec_id);
03472 }
03473 private:
03474 Listener& m_obj;
03475 typedef void (Listener::*Memfunc)(UniqueId ec_id);
03476 Memfunc m_memfunc;
03477 };
03478 Noname* listener(new Noname(obj, memfunc));
03479 addPreComponentActionListener(listener_type, listener, true);
03480 return listener;
03481 }
03482
03502 void
03503 removePreComponentActionListener(
03504 PreComponentActionListenerType listener_type,
03505 PreComponentActionListener* listener);
03506
03507
03580 typedef PostComponentActionListener PostCompActionListener;
03581 typedef PostComponentActionListenerType PostCompActionListenerType;
03582 void
03583 addPostComponentActionListener(
03584 PostComponentActionListenerType listener_type,
03585 PostComponentActionListener* listener,
03586 bool autoclean = true);
03587
03588 template <class Listener>
03589 PostComponentActionListener*
03590 addPostComponentActionListener(PostCompActionListenerType listener_type,
03591 Listener& obj,
03592 void (Listener::*memfunc)(UniqueId ec_id,
03593 ReturnCode_t ret))
03594 {
03595 class Noname
03596 : public PostComponentActionListener
03597 {
03598 public:
03599 Noname(Listener& obj, void (Listener::*memfunc)(UniqueId, ReturnCode_t))
03600 : m_obj(obj), m_memfunc(memfunc)
03601 {
03602 }
03603 void operator()(UniqueId ec_id, ReturnCode_t ret)
03604 {
03605 (m_obj.*m_memfunc)(ec_id, ret);
03606 }
03607 private:
03608 Listener& m_obj;
03609 typedef void (Listener::*Memfunc)(UniqueId ec_id, ReturnCode_t ret);
03610 Memfunc m_memfunc;
03611 };
03612 Noname* listener(new Noname(obj, memfunc));
03613 addPostComponentActionListener(listener_type, listener, true);
03614 return listener;
03615 }
03616
03636 void
03637 removePostComponentActionListener(
03638 PostComponentActionListenerType listener_type,
03639 PostComponentActionListener* listener);
03640
03641
03642
03696 void
03697 addPortActionListener(PortActionListenerType listener_type,
03698 PortActionListener* listener,
03699 bool autoclean = true);
03700
03701 template <class Listener>
03702 PortActionListener*
03703 addPortActionListener(PortActionListenerType listener_type,
03704 Listener& obj,
03705 void (Listener::*memfunc)(const RTC::PortProfile&))
03706 {
03707 class Noname
03708 : public PortActionListener
03709 {
03710 public:
03711 Noname(Listener& obj,
03712 void (Listener::*memfunc)(const RTC::PortProfile&))
03713 : m_obj(obj), m_memfunc(memfunc)
03714 {
03715 }
03716 void operator()(const RTC::PortProfile& pprofile)
03717 {
03718 (m_obj.*m_memfunc)(pprofile);
03719 }
03720 private:
03721 Listener& m_obj;
03722 typedef void (Listener::*Memfunc)(const RTC::PortProfile&);
03723 Memfunc m_memfunc;
03724 };
03725 Noname* listener(new Noname(obj, memfunc));
03726 addPortActionListener(listener_type, listener, true);
03727 return listener;
03728 }
03729
03749 void
03750 removePortActionListener(PortActionListenerType listener_type,
03751 PortActionListener* listener);
03752
03753
03754
03808 typedef ExecutionContextActionListenerType ECActionListenerType;
03809 typedef ExecutionContextActionListener ECActionListener;
03810 void addExecutionContextActionListener(ECActionListenerType listener_type,
03811 ECActionListener* listener,
03812 bool autoclean = true);
03813
03814 template <class Listener>
03815 ECActionListener*
03816 addExecutionContextActionListener(ECActionListenerType listener_type,
03817 Listener& obj,
03818 void (Listener::*memfunc)(UniqueId))
03819 {
03820 class Noname
03821 : public ECActionListener
03822 {
03823 public:
03824 Noname(Listener& obj, void (Listener::*memfunc)(UniqueId))
03825 : m_obj(obj), m_memfunc(memfunc)
03826 {
03827 }
03828 void operator()(UniqueId ec_id)
03829 {
03830 (m_obj.*m_memfunc)(ec_id);
03831 }
03832 private:
03833 Listener& m_obj;
03834 typedef void (Listener::*Memfunc)(UniqueId);
03835 Memfunc m_memfunc;
03836 };
03837 Noname* listener(new Noname(obj, memfunc));
03838 addExecutionContextActionListener(listener_type, listener, true);
03839 return listener;
03840 }
03841
03842
03862 void
03863 removeExecutionContextActionListener(ECActionListenerType listener_type,
03864 ECActionListener* listener);
03865
03866
03921 void addPortConnectListener(PortConnectListenerType listener_type,
03922 PortConnectListener* listener,
03923 bool autoclean = true);
03924
03925 template <class Listener>
03926 PortConnectListener*
03927 addPortConnectListener(PortConnectListenerType listener_type,
03928 Listener& obj,
03929 void (Listener::*memfunc)(const char*,
03930 ConnectorProfile&))
03931 {
03932 class Noname
03933 : public PortConnectListener
03934 {
03935 public:
03936 Noname(Listener& obj,
03937 void (Listener::*memfunc)(const char*, ConnectorProfile&))
03938 : m_obj(obj), m_memfunc(memfunc)
03939 {
03940 }
03941 void operator()(const char* portname, ConnectorProfile& cprofile)
03942 {
03943 (m_obj.*m_memfunc)(portname, cprofile);
03944 }
03945 private:
03946 Listener& m_obj;
03947 typedef void (Listener::*Memfunc)(const char*, ConnectorProfile&);
03948 Memfunc m_memfunc;
03949 };
03950 Noname* listener(new Noname(obj, memfunc));
03951 addPortConnectListener(listener_type, listener, true);
03952 return listener;
03953 }
03954
03955
03975 void
03976 removePortConnectListener(PortConnectListenerType listener_type,
03977 PortConnectListener* listener);
03978
04037 void addPortConnectRetListener(PortConnectRetListenerType listener_type,
04038 PortConnectRetListener* listener,
04039 bool autoclean = true);
04040
04041 template <class Listener>
04042 PortConnectRetListener*
04043 addPortConnectRetListener(PortConnectRetListenerType listener_type,
04044 Listener& obj,
04045 void (Listener::*memfunc)(const char*,
04046 ConnectorProfile&,
04047 ReturnCode_t))
04048 {
04049 class Noname
04050 : public PortConnectRetListener
04051 {
04052 public:
04053 Noname(Listener& obj,
04054 void (Listener::*memfunc)(const char*,
04055 ConnectorProfile&,
04056 ReturnCode_t))
04057 : m_obj(obj), m_memfunc(memfunc)
04058 {
04059 }
04060 void operator()(const char* portname,
04061 ConnectorProfile& cprofile,
04062 ReturnCode_t ret)
04063 {
04064 (m_obj.*m_memfunc)(portname, cprofile, ret);
04065 }
04066 private:
04067 Listener& m_obj;
04068 typedef void (Listener::*Memfunc)(const char* portname,
04069 ConnectorProfile& cprofile,
04070 ReturnCode_t ret);
04071 Memfunc m_memfunc;
04072 };
04073 Noname* listener(new Noname(obj, memfunc));
04074 addPortConnectRetListener(listener_type, listener, true);
04075 return listener;
04076 }
04077
04078
04098 void
04099 removePortConnectRetListener(PortConnectRetListenerType listener_type,
04100 PortConnectRetListener* listener);
04101
04102
04135 void addConfigurationParamListener(ConfigurationParamListenerType type,
04136 ConfigurationParamListener* listener,
04137 bool autoclean = true);
04138
04139 template <class Listener>
04140 ConfigurationParamListener*
04141 addConfigurationParamListener(ConfigurationParamListenerType listener_type,
04142 Listener& obj,
04143 void (Listener::*memfunc)(const char*,
04144 const char*))
04145 {
04146 class Noname
04147 : public ConfigurationParamListener
04148 {
04149 public:
04150 Noname(Listener& obj,
04151 void (Listener::*memfunc)(const char*, const char*))
04152 : m_obj(obj), m_memfunc(memfunc)
04153 {
04154 }
04155 void operator()(const char* config_set_name,
04156 const char* config_param_name)
04157 {
04158 (m_obj.*m_memfunc)(config_set_name, config_param_name);
04159 }
04160 private:
04161 Listener& m_obj;
04162 typedef void (Listener::*Memfunc)(const char*, const char*);
04163 Memfunc m_memfunc;
04164 };
04165 Noname* listener(new Noname(obj, memfunc));
04166 addConfigurationParamListener(listener_type, listener, true);
04167 return listener;
04168 }
04169
04194 void removeConfigurationParamListener(ConfigurationParamListenerType type,
04195 ConfigurationParamListener* listener);
04196
04228 void addConfigurationSetListener(ConfigurationSetListenerType type,
04229 ConfigurationSetListener* listener,
04230 bool autoclean = true);
04231
04232 template <class Listener>
04233 ConfigurationSetListener*
04234 addConfigurationSetListener(ConfigurationSetListenerType listener_type,
04235 Listener& obj,
04236 void (Listener::*memfunc)
04237 (const coil::Properties& config_set))
04238 {
04239 class Noname
04240 : public ConfigurationSetListener
04241 {
04242 public:
04243 Noname(Listener& obj,
04244 void (Listener::*memfunc)(const coil::Properties& config_set))
04245 : m_obj(obj), m_memfunc(memfunc)
04246 {
04247 }
04248 virtual void operator()(const coil::Properties& config_set)
04249 {
04250 (m_obj.*m_memfunc)(config_set);
04251 }
04252 private:
04253 Listener& m_obj;
04254 typedef void (Listener::*Memfunc)(const coil::Properties& config_set);
04255 Memfunc m_memfunc;
04256 };
04257 Noname* listener(new Noname(obj, memfunc));
04258 addConfigurationSetListener(listener_type, listener, true);
04259 return listener;
04260 }
04261
04284 void removeConfigurationSetListener(ConfigurationSetListenerType type,
04285 ConfigurationSetListener* listener);
04286
04321 void
04322 addConfigurationSetNameListener(ConfigurationSetNameListenerType type,
04323 ConfigurationSetNameListener* listener,
04324 bool autoclean = true);
04325
04326 template <class Listener>
04327 ConfigurationSetNameListener*
04328 addConfigurationSetNameListener(ConfigurationSetNameListenerType type,
04329 Listener& obj,
04330 void (Listener::*memfunc)(const char*))
04331 {
04332 class Noname
04333 : public ConfigurationSetNameListener
04334 {
04335 public:
04336 Noname(Listener& obj, void (Listener::*memfunc)(const char*))
04337 : m_obj(obj), m_memfunc(memfunc)
04338 {
04339 }
04340 virtual void operator()(const char* config_set_name)
04341 {
04342 (m_obj.*m_memfunc)(config_set_name);
04343 }
04344 private:
04345 Listener& m_obj;
04346 typedef void (Listener::*Memfunc)(const char*);
04347 Memfunc m_memfunc;
04348 };
04349 Noname* listener(new Noname(obj, memfunc));
04350 addConfigurationSetNameListener(type, listener, true);
04351 return listener;
04352 }
04353
04380 void
04381 removeConfigurationSetNameListener(ConfigurationSetNameListenerType type,
04382 ConfigurationSetNameListener* listener);
04383
04384 protected:
04404 void shutdown();
04405
04406 inline void preOnInitialize(UniqueId ec_id)
04407 {
04408 m_actionListeners.preaction_[PRE_ON_INITIALIZE].notify(ec_id);
04409 }
04410
04411 inline void preOnFinalize(UniqueId ec_id)
04412 {
04413 m_actionListeners.preaction_[PRE_ON_FINALIZE].notify(ec_id);
04414 }
04415
04416 inline void preOnStartup(UniqueId ec_id)
04417 {
04418 m_actionListeners.preaction_[PRE_ON_STARTUP].notify(ec_id);
04419 }
04420
04421 inline void preOnShutdown(UniqueId ec_id)
04422 {
04423 m_actionListeners.preaction_[PRE_ON_SHUTDOWN].notify(ec_id);
04424 }
04425
04426 inline void preOnActivated(UniqueId ec_id)
04427 {
04428 m_actionListeners.preaction_[PRE_ON_ACTIVATED].notify(ec_id);
04429 }
04430
04431 inline void preOnDeactivated(UniqueId ec_id)
04432 {
04433 m_actionListeners.preaction_[PRE_ON_DEACTIVATED].notify(ec_id);
04434 }
04435
04436 inline void preOnAborting(UniqueId ec_id)
04437 {
04438 m_actionListeners.preaction_[PRE_ON_ABORTING].notify(ec_id);
04439 }
04440
04441 inline void preOnError(UniqueId ec_id)
04442 {
04443 m_actionListeners.preaction_[PRE_ON_ERROR].notify(ec_id);
04444 }
04445
04446 inline void preOnReset(UniqueId ec_id)
04447 {
04448 m_actionListeners.preaction_[PRE_ON_RESET].notify(ec_id);
04449 }
04450
04451 inline void preOnExecute(UniqueId ec_id)
04452 {
04453 m_actionListeners.preaction_[PRE_ON_EXECUTE].notify(ec_id);
04454 }
04455
04456 inline void preOnStateUpdate(UniqueId ec_id)
04457 {
04458 m_actionListeners.preaction_[PRE_ON_STATE_UPDATE].notify(ec_id);
04459 }
04460
04461 inline void preOnRateChanged(UniqueId ec_id)
04462 {
04463 m_actionListeners.preaction_[PRE_ON_RATE_CHANGED].notify(ec_id);
04464 }
04465
04466 inline void postOnInitialize(UniqueId ec_id, ReturnCode_t ret)
04467 {
04468 m_actionListeners.postaction_[POST_ON_INITIALIZE].notify(ec_id, ret);
04469 }
04470
04471 inline void postOnFinalize(UniqueId ec_id, ReturnCode_t ret)
04472 {
04473 m_actionListeners.postaction_[POST_ON_FINALIZE].notify(ec_id, ret);
04474 }
04475
04476 inline void postOnStartup(UniqueId ec_id, ReturnCode_t ret)
04477 {
04478 m_actionListeners.postaction_[POST_ON_STARTUP].notify(ec_id, ret);
04479 }
04480
04481 inline void postOnShutdown(UniqueId ec_id, ReturnCode_t ret)
04482 {
04483 m_actionListeners.postaction_[POST_ON_SHUTDOWN].notify(ec_id, ret);
04484 }
04485
04486 inline void postOnActivated(UniqueId ec_id, ReturnCode_t ret)
04487 {
04488 m_actionListeners.postaction_[POST_ON_ACTIVATED].notify(ec_id, ret);
04489 }
04490
04491 inline void postOnDeactivated(UniqueId ec_id, ReturnCode_t ret)
04492 {
04493 m_actionListeners.postaction_[POST_ON_DEACTIVATED].notify(ec_id, ret);
04494 }
04495
04496 inline void postOnAborting(UniqueId ec_id, ReturnCode_t ret)
04497 {
04498 m_actionListeners.postaction_[POST_ON_ABORTING].notify(ec_id, ret);
04499 }
04500
04501 inline void postOnError(UniqueId ec_id, ReturnCode_t ret)
04502 {
04503 m_actionListeners.postaction_[POST_ON_ERROR].notify(ec_id, ret);
04504 }
04505
04506 inline void postOnReset(UniqueId ec_id, ReturnCode_t ret)
04507 {
04508 m_actionListeners.postaction_[POST_ON_RESET].notify(ec_id, ret);
04509 }
04510
04511 inline void postOnExecute(UniqueId ec_id, ReturnCode_t ret)
04512 {
04513 m_actionListeners.postaction_[POST_ON_EXECUTE].notify(ec_id, ret);
04514 }
04515
04516 inline void postOnStateUpdate(UniqueId ec_id, ReturnCode_t ret)
04517 {
04518 m_actionListeners.postaction_[POST_ON_STATE_UPDATE].notify(ec_id, ret);
04519 }
04520
04521 inline void postOnRateChanged(UniqueId ec_id, ReturnCode_t ret)
04522 {
04523 m_actionListeners.postaction_[POST_ON_RATE_CHANGED].notify(ec_id, ret);
04524 }
04525
04526 inline void onAddPort(const PortProfile& pprof)
04527 {
04528 m_actionListeners.portaction_[ADD_PORT].notify(pprof);
04529 }
04530
04531 inline void onRemovePort(const PortProfile& pprof)
04532 {
04533 m_actionListeners.portaction_[REMOVE_PORT].notify(pprof);
04534 }
04535
04536 inline void onAttachExecutionContext(UniqueId ec_id)
04537 {
04538 m_actionListeners.ecaction_[EC_ATTACHED].notify(ec_id);
04539 }
04540
04541 inline void onDetachExecutionContext(UniqueId ec_id)
04542 {
04543 m_actionListeners.ecaction_[EC_DETACHED].notify(ec_id);
04544 }
04545
04546 ReturnCode_t getInheritedECOptions(coil::Properties& default_opts);
04547
04551 ReturnCode_t
04552 getPrivateContextOptions(std::vector<coil::Properties>& ec_args);
04553
04557 ReturnCode_t
04558 getGlobalContextOptions(coil::Properties& global_ec_props);
04559
04563 ReturnCode_t
04564 getContextOptions(std::vector<coil::Properties>& ec_args);
04565
04569 ReturnCode_t findExistingEC(coil::Properties& ec_arg,
04570 RTC::ExecutionContextBase*& ec);
04574 ReturnCode_t createContexts(std::vector<coil::Properties>& ec_args);
04575
04576
04577 protected:
04585 mutable Logger rtclog;
04593 Manager* m_pManager;
04594
04602 CORBA::ORB_var m_pORB;
04603
04611 PortableServer::POA_var m_pPOA;
04612
04613
04614
04615
04623 SDOPackage::OrganizationList m_sdoOwnedOrganizations;
04624
04632 struct svc_name
04633 {
04634 svc_name (const char* id) : m_id(id) {};
04635 bool operator()(const SDOPackage::ServiceProfile& prof)
04636 {
04637 return m_id == std::string(prof.id);
04638 }
04639 std::string m_id;
04640 };
04641
04649 SDOPackage::Configuration_impl* m_pSdoConfigImpl;
04650
04658 SDOPackage::Configuration_var m_pSdoConfig;
04659
04667 SDOPackage::OrganizationList m_sdoOrganizations;
04668
04676 SDOPackage::NVList m_sdoStatus;
04677
04678
04679
04680
04688 ComponentProfile m_profile;
04689
04697 RTObject_var m_objref;
04698
04706 PortAdmin m_portAdmin;
04707
04715 std::vector<InPortBase*> m_inports;
04716
04724 std::vector<OutPortBase*> m_outports;
04725
04733 ExecutionContextServiceList m_ecMine;
04734
04742 std::vector<ExecutionContextBase*> m_eclist;
04743
04751 ExecutionContextServiceList m_ecOther;
04752
04760 bool m_created;
04761
04769 bool m_exiting;
04770
04778
04779
04787 coil::Properties m_properties;
04788
04796 ConfigAdmin m_configsets;
04797
04805 SdoServiceAdmin m_sdoservice;
04806
04814 bool m_readAll;
04815
04823 bool m_writeAll;
04824
04841 bool m_readAllCompletion;
04842
04859 bool m_writeAllCompletion;
04860
04874 ComponentActionListeners m_actionListeners;
04875
04889 PortConnectListeners m_portconnListeners;
04890
04891
04892
04893
04901 struct nv_name
04902 {
04903 nv_name(const char* name) : m_name(name) {};
04904 bool operator()(const SDOPackage::NameValue& nv)
04905 {
04906 return m_name == std::string(nv.name);
04907 }
04908 std::string m_name;
04909 };
04910
04918 struct ec_copy
04919 {
04920 ec_copy(ExecutionContextList& eclist)
04921 : m_eclist(eclist)
04922 {
04923 }
04924 void operator()(ExecutionContextService_ptr ecs)
04925 {
04926 if (!::CORBA::is_nil(ecs))
04927 {
04928 CORBA_SeqUtil::push_back(m_eclist,
04929 ExecutionContext::_duplicate(ecs));
04930 }
04931 }
04932 ExecutionContextList& m_eclist;
04933 };
04941 struct ec_find
04942 {
04943 ec_find(ExecutionContext_ptr& ec)
04944 : m_ec(ExecutionContext::_duplicate(ec))
04945 {
04946 }
04947 bool operator()(ExecutionContextService_ptr ecs)
04948 {
04949 try
04950 {
04951 if (!::CORBA::is_nil(ecs))
04952 {
04953 ExecutionContext_var ec;
04954 ec = ExecutionContext::_narrow(ecs);
04955 return m_ec->_is_equivalent(ec);
04956 }
04957 }
04958 catch (...)
04959 {
04960 return false;
04961 }
04962 return false;
04963 }
04964 ExecutionContext_var m_ec;
04965
04966 };
04967
04968
04976 struct deactivate_comps
04977 {
04978 deactivate_comps(LightweightRTObject_ptr comp)
04979 : m_comp(RTC::LightweightRTObject::_duplicate(comp))
04980 {
04981 }
04982 void operator()(ExecutionContextService_ptr ec)
04983 {
04984 if (!::CORBA::is_nil(ec) && !ec->_non_existent())
04985 {
04986
04987 ec->deactivate_component(RTC::LightweightRTObject::_duplicate(m_comp));
04988 ec->stop();
04989 }
04990 }
04991 LightweightRTObject_var m_comp;
04992 };
04993 };
04994 };
04995
04996 #ifdef WIN32
04997 #pragma warning( default : 4290 )
04998 #endif
04999
05000 #endif // RTC_RTOBJECT