00001
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 #ifndef RTObject_h
00042 #define RTObject_h
00043
00044
00045 #include "rtm/RTC.h"
00046 #include "rtm/Properties.h"
00047 #include "rtm/idl/RTCSkel.h"
00048 #include "rtm/PortBase.h"
00049
00050 #include "rtm/PortAdmin.h"
00051 #include <rtm/DataInPort.h>
00052 #include <rtm/DataOutPort.h>
00053 #include <rtm/InPort.h>
00054 #include <rtm/OutPort.h>
00055
00056
00057 #include <ace/Task.h>
00058
00059
00060 namespace SDOPackage
00061 {
00062 class Configuration_impl;
00063 };
00064
00065 namespace RTC
00066 {
00067 class Manager;
00068
00069 class RTObject_impl
00070 : public virtual POA_RTC::DataFlowComponent,
00071 public virtual PortableServer::RefCountServantBase
00072 {
00073 public:
00074 RTObject_impl(Manager* manager);
00075 RTObject_impl(CORBA::ORB_ptr orb, PortableServer::POA_ptr poa);
00076 virtual ~RTObject_impl();
00077
00078
00079 protected:
00080
00081
00082
00083
00084
00085 virtual ReturnCode_t onInitialize();
00086
00087
00088
00089 virtual ReturnCode_t onFinalize();
00090
00091
00092
00093 virtual ReturnCode_t onStartup(RTC::UniqueId ec_id);
00094
00095
00096
00097 virtual ReturnCode_t onShutdown(RTC::UniqueId ec_id);
00098
00099
00100
00101 virtual ReturnCode_t onActivated(RTC::UniqueId ec_id);
00102
00103
00104
00105 virtual ReturnCode_t onDeactivated(RTC::UniqueId ec_id);
00106
00107
00108
00109 virtual ReturnCode_t onExecute(RTC::UniqueId ec_id);
00110
00111
00112
00113 virtual ReturnCode_t onAborting(RTC::UniqueId ec_id);
00114
00115
00116
00117 virtual ReturnCode_t onError(RTC::UniqueId ec_id);
00118
00119
00120
00121 virtual ReturnCode_t onReset(RTC::UniqueId ec_id);
00122
00123
00124
00125 virtual ReturnCode_t onStateUpdate(RTC::UniqueId ec_id);
00126
00127
00128
00129 virtual ReturnCode_t onRateChanged(RTC::UniqueId ec_id);
00130
00131
00132 public:
00133
00134
00135
00166 virtual ReturnCode_t initialize();
00167
00168
00206 virtual ReturnCode_t finalize();
00207
00208
00244 virtual ReturnCode_t exit();
00245
00266 virtual CORBA::Boolean is_alive();
00267
00268
00276 virtual ExecutionContextList* get_contexts();
00277
00278 virtual UniqueId
00279 set_execution_context_service(const ExecutionContextService_ptr ec);
00280
00281
00282
00283
00299 virtual ComponentProfile* get_component_profile();
00300
00301
00317 virtual PortList* get_ports();
00318
00319
00337 virtual ExecutionContextServiceList* get_execution_context_services();
00338
00339
00340
00341
00342 virtual ReturnCode_t on_initialize();
00343 virtual ReturnCode_t on_finalize();
00344 virtual ReturnCode_t on_startup(UniqueId ec_id);
00345 virtual ReturnCode_t on_shutdown(UniqueId ec_id);
00346 virtual ReturnCode_t on_activated(UniqueId ec_id);
00347 virtual ReturnCode_t on_deactivated(UniqueId ec_id);
00348 virtual ReturnCode_t on_aborting(UniqueId ec_id);
00349 virtual ReturnCode_t on_error(UniqueId ec_id);
00350 virtual ReturnCode_t on_reset(UniqueId ec_id);
00351
00352 virtual ReturnCode_t on_execute(UniqueId ec_id);
00353 virtual ReturnCode_t on_state_update(UniqueId ec_id);
00354 virtual ReturnCode_t on_rate_changed(UniqueId ec_id);
00355
00356
00357
00358
00359
00360
00382 virtual SDOPackage::OrganizationList* get_owned_organizations()
00383 throw (SDOPackage::NotAvailable);
00384
00385
00386
00387
00388
00418 virtual char* get_sdo_id()
00419 throw (SDOPackage::NotAvailable, SDOPackage::InternalError);
00420
00450 virtual char* get_sdo_type()
00451 throw (SDOPackage::NotAvailable, SDOPackage::InternalError);
00452
00483 virtual SDOPackage::DeviceProfile* get_device_profile()
00484 throw (SDOPackage::NotAvailable, SDOPackage::InternalError);
00485
00517 virtual SDOPackage::ServiceProfileList* get_service_profiles()
00518 throw (SDOPackage::InvalidParameter, SDOPackage::NotAvailable,
00519 SDOPackage::InternalError);
00520
00549 virtual SDOPackage::ServiceProfile* get_service_profile(const char* id)
00550 throw (SDOPackage::InvalidParameter, SDOPackage::NotAvailable,
00551 SDOPackage::InternalError);
00552
00580 virtual SDOPackage::SDOService_ptr get_sdo_service(const char* id)
00581 throw (SDOPackage::InvalidParameter, SDOPackage::NotAvailable,
00582 SDOPackage::InternalError);
00583
00623 virtual SDOPackage::Configuration_ptr get_configuration()
00624 throw (SDOPackage::InterfaceNotImplemented, SDOPackage::NotAvailable,
00625 SDOPackage::InternalError);
00626
00665 virtual SDOPackage::Monitoring_ptr get_monitoring()
00666 throw (SDOPackage::InterfaceNotImplemented, SDOPackage::NotAvailable,
00667 SDOPackage::InternalError);
00668
00699 virtual SDOPackage::OrganizationList* get_organizations()
00700 throw (SDOPackage::NotAvailable, SDOPackage::InternalError);
00701
00728 virtual SDOPackage::NVList* get_status_list()
00729 throw (SDOPackage::NotAvailable, SDOPackage::InternalError);
00730
00760 virtual CORBA::Any* get_status(const char* name)
00761 throw (SDOPackage::InvalidParameter, SDOPackage::NotAvailable,
00762 SDOPackage::InternalError);
00763
00764
00765
00766
00767
00768
00769 const char* getInstanceName() {return m_profile.instance_name;}
00770 void setInstanceName(const char* instance_name);
00771 const char* getTypeName() {return m_profile.type_name;}
00772 const char* getDescription() { return m_profile.description;}
00773 const char* getVersion() {return m_profile.version;}
00774 const char* getVendor() {return m_profile.vendor;}
00775 const char* getCategory() {return m_profile.category;}
00776
00777 std::vector<std::string> getNamingNames();
00778
00779 void setObjRef(const RTObject_ptr rtobj);
00780 RTObject_ptr getObjRef() const;
00781
00782
00783
00809 void setProperties(const Properties& prop);
00810
00832 Properties& getProperties();
00833
00834
00866 void registerPort(PortBase& port);
00867
00868 template <class DataType, template <class DataType> class Buffer>
00869 void registerInPort(const char* name,
00870 InPort<DataType, Buffer>& inport)
00871 {
00872 PortBase* port = new DataInPort(name, inport);
00873 registerPort(*port);
00874 }
00875
00876 template <class DataType, template <class DataType> class Buffer>
00877 void registerOutPort(const char* name,
00878 OutPort<DataType, Buffer>& outport)
00879 {
00880 PortBase* port = new DataOutPort(name, outport);
00881 registerPort(*port);
00882 }
00883
00884
00910 void deletePort(PortBase& port);
00911 void deletePortByName(const char* port_name);
00912 void finalizePorts();
00913
00914
00915
00916
00917
00918
00919
00920
00921
00922
00923
00924
00925
00926
00927
00928
00929
00930
00931
00932 protected:
00933
00934
00935
00939 SDOPackage::OrganizationList m_sdoOwnedOrganizations;
00940
00944 SDOPackage::ServiceProfileList m_sdoSvcProfiles;
00945
00949 struct svc_name
00950 {
00951 svc_name (const char* id) : m_id(id) {};
00952 bool operator()(const SDOPackage::ServiceProfile& prof)
00953 {
00954 return m_id == std::string(prof.id);
00955 }
00956 std::string m_id;
00957 };
00958
00962 SDOPackage::Configuration_impl* m_pSdoConfigImpl;
00963 SDOPackage::Configuration_var m_pSdoConfig;
00964
00968 SDOPackage::OrganizationList m_sdoOrganizations;
00969
00973 SDOPackage::NVList m_sdoStatus;
00974
00975
00976
00977
00978
00982 ComponentProfile m_profile;
00983
00984 RTObject_ptr m_objref;
00988 PortAdmin m_portAdmin;
00989
00990 ExecutionContextServiceList m_execContexts;
00991
00992 bool m_created;
00993 bool m_alive;
00994
00998 Properties m_properties;
00999
01000 struct nv_name
01001 {
01002 nv_name(const char* name) : m_name(name) {};
01003 bool operator()(const SDOPackage::NameValue& nv)
01004 {
01005 return m_name == std::string(nv.name);
01006 }
01007 std::string m_name;
01008 };
01009
01010
01011 struct ec_copy
01012 {
01013 ec_copy(ExecutionContextList& eclist)
01014 : m_eclist(eclist)
01015 {
01016 }
01017 void operator()(ExecutionContextService_ptr ecs)
01018 {
01019 CORBA_SeqUtil::push_back(m_eclist, ExecutionContext::_duplicate(ecs));
01020 }
01021 ExecutionContextList& m_eclist;
01022 };
01023
01024
01025 struct deactivate_comps
01026 {
01027 deactivate_comps(LightweightRTObject_ptr comp)
01028 : m_comp(comp)
01029 {
01030 }
01031 void operator()(ExecutionContextService_ptr ec)
01032 {
01033 ec->deactivate_component(RTC::LightweightRTObject::_duplicate(m_comp));
01034 }
01035 LightweightRTObject_var m_comp;
01036 };
01037
01038
01039 };
01040 };
01041 #endif // RTObject