RTObject.h

説明を見る。
00001 // -*- C++ -*-
00019 #ifndef RTObject_h
00020 #define RTObject_h
00021 
00022 // CORBA header include
00023 #include "rtm/RTC.h"
00024 #include "rtm/Properties.h"
00025 #include "rtm/idl/RTCSkel.h"
00026 #include "rtm/idl/OpenRTMSkel.h"
00027 #include "rtm/PortBase.h"
00028 //#include "rtm/ObjectManager.h"
00029 #include "rtm/PortAdmin.h"
00030 #include <rtm/DataInPort.h>
00031 #include <rtm/DataOutPort.h>
00032 #include <rtm/InPort.h>
00033 #include <rtm/OutPort.h>
00034 #include <rtm/ConfigAdmin.h>
00035 
00036 // ACE
00037 #include <ace/Task.h>
00038 
00039 namespace SDOPackage
00040 {
00041   class Configuration_impl;
00042 };
00043 
00044 namespace RTC
00045 {
00046   class Manager;
00047   
00082   class RTObject_impl
00083     : public virtual POA_RTC::DataFlowComponent, 
00084       public virtual PortableServer::RefCountServantBase
00085   {
00086   public:
00105     RTObject_impl(Manager* manager);
00106     
00127     RTObject_impl(CORBA::ORB_ptr orb, PortableServer::POA_ptr poa);
00128     
00140     virtual ~RTObject_impl();
00141     
00142   protected:
00143     //============================================================
00144     // Overridden functions
00145     //============================================================
00173     // The initialize action (on CREATED->ALIVE transition)
00174     // formaer rtc_init_entry() 
00175     virtual ReturnCode_t onInitialize();
00176     
00204     // The finalize action (on ALIVE->END transition)
00205     // formaer rtc_exiting_entry()
00206     virtual ReturnCode_t onFinalize();
00207     
00239     // The startup action when ExecutionContext startup
00240     // former rtc_starting_entry()
00241     virtual ReturnCode_t onStartup(RTC::UniqueId ec_id);
00242     
00274     // The shutdown action when ExecutionContext stop
00275     // former rtc_stopping_entry()
00276     virtual ReturnCode_t onShutdown(RTC::UniqueId ec_id);
00277     
00309     // The activated action (Active state entry action)
00310     // former rtc_active_entry()
00311     virtual ReturnCode_t onActivated(RTC::UniqueId ec_id);
00312     
00344     // The deactivated action (Active state exit action)
00345     // former rtc_active_exit()
00346     virtual ReturnCode_t onDeactivated(RTC::UniqueId ec_id);
00347     
00383     // The execution action that is invoked periodically
00384     // former rtc_active_do()
00385     virtual ReturnCode_t onExecute(RTC::UniqueId ec_id);
00386     
00418     // The aborting action when main logic error occurred.
00419     // former rtc_aborting_entry()
00420     virtual ReturnCode_t onAborting(RTC::UniqueId ec_id);
00421     
00452     // The error action in ERROR state
00453     // former rtc_error_do()
00454     virtual ReturnCode_t onError(RTC::UniqueId ec_id);
00455     
00486     // The reset action that is invoked resetting
00487     // This is same but different the former rtc_init_entry()
00488     virtual ReturnCode_t onReset(RTC::UniqueId ec_id);
00489     
00525     // The state update action that is invoked after onExecute() action
00526     // no corresponding operation exists in OpenRTm-aist-0.2.0
00527     virtual ReturnCode_t onStateUpdate(RTC::UniqueId ec_id);
00528     
00564     // The action that is invoked when execution context's rate is changed
00565     // no corresponding operation exists in OpenRTm-aist-0.2.0
00566     virtual ReturnCode_t onRateChanged(RTC::UniqueId ec_id);
00567     
00568   public:
00569     //============================================================
00570     // RTC::LightweightRTObject
00571     //============================================================
00607     virtual ReturnCode_t initialize()
00608       throw (CORBA::SystemException);
00609     
00654     virtual ReturnCode_t finalize()
00655       throw (CORBA::SystemException);
00656     
00700     virtual ReturnCode_t exit()
00701       throw (CORBA::SystemException); 
00702     
00735     virtual CORBA::Boolean is_alive()
00736       throw (CORBA::SystemException);
00737     
00755     virtual ExecutionContextList* get_contexts()
00756       throw (CORBA::SystemException);
00757     
00785     virtual ExecutionContext_ptr get_context(UniqueId ec_id)
00786       throw (CORBA::SystemException);
00787     
00788     /*
00789       virtual UniqueId 
00790       set_execution_context_service(const ExecutionContextService_ptr ec);
00791     */
00792     
00823     UniqueId attach_executioncontext(ExecutionContext_ptr exec_context)
00824       throw (CORBA::SystemException);
00825     
00867     ReturnCode_t detach_executioncontext(UniqueId ec_id)
00868       throw (CORBA::SystemException);
00869     
00870     //============================================================
00871     // RTC::RTObject
00872     //============================================================
00892     virtual ComponentProfile* get_component_profile()
00893       throw (CORBA::SystemException);
00894     
00914     virtual PortList* get_ports()
00915       throw (CORBA::SystemException);
00916     
00938     virtual ExecutionContextServiceList* get_execution_context_services()
00939       throw (CORBA::SystemException);
00940     
00941     //============================================================
00942     // RTC::ComponentAction
00943     //============================================================
00968     virtual ReturnCode_t on_initialize()
00969       throw (CORBA::SystemException);
00970     
00995     virtual ReturnCode_t on_finalize()
00996       throw (CORBA::SystemException);
00997     
01026     virtual ReturnCode_t on_startup(UniqueId ec_id)
01027       throw (CORBA::SystemException);
01028     
01057     virtual ReturnCode_t on_shutdown(UniqueId ec_id)
01058       throw (CORBA::SystemException);
01059     
01086     virtual ReturnCode_t on_activated(UniqueId ec_id)
01087       throw (CORBA::SystemException);
01088     
01116     virtual ReturnCode_t on_deactivated(UniqueId ec_id)
01117       throw (CORBA::SystemException);
01118     
01151     virtual ReturnCode_t on_aborting(UniqueId ec_id)
01152       throw (CORBA::SystemException);
01153     
01197     virtual ReturnCode_t on_error(UniqueId ec_id)
01198       throw (CORBA::SystemException);
01199     
01233     virtual ReturnCode_t on_reset(UniqueId ec_id)
01234       throw (CORBA::SystemException);
01235     
01236     //============================================================
01237     // RTC::DataFlowComponentAction
01238     //============================================================
01280     virtual ReturnCode_t on_execute(UniqueId ec_id)
01281       throw (CORBA::SystemException);
01282     
01326     virtual ReturnCode_t on_state_update(UniqueId ec_id)
01327       throw (CORBA::SystemException);
01328     
01365     virtual ReturnCode_t on_rate_changed(UniqueId ec_id)
01366       throw (CORBA::SystemException);
01367     
01368     //============================================================
01369     // SDOPackage::SdoSystemElement
01370     //============================================================
01408     virtual SDOPackage::OrganizationList* get_owned_organizations()
01409       throw (CORBA::SystemException, SDOPackage::NotAvailable);
01410     
01411     //============================================================
01412     // SDOPackage::SDO
01413     //============================================================
01447     virtual char* get_sdo_id()
01448       throw (CORBA::SystemException,
01449              SDOPackage::NotAvailable, SDOPackage::InternalError);
01450     
01484     virtual char* get_sdo_type()
01485       throw (CORBA::SystemException, 
01486              SDOPackage::NotAvailable, SDOPackage::InternalError);
01487     
01524     virtual SDOPackage::DeviceProfile* get_device_profile()
01525       throw (CORBA::SystemException, 
01526              SDOPackage::NotAvailable, SDOPackage::InternalError);
01527     
01564     virtual SDOPackage::ServiceProfileList* get_service_profiles()
01565       throw (CORBA::SystemException, 
01566              SDOPackage::NotAvailable, SDOPackage::InternalError);
01567     
01609     virtual SDOPackage::ServiceProfile* get_service_profile(const char* id)
01610       throw (CORBA::SystemException, 
01611              SDOPackage::InvalidParameter, SDOPackage::NotAvailable,
01612              SDOPackage::InternalError);
01613     
01661     virtual SDOPackage::SDOService_ptr get_sdo_service(const char* id)
01662       throw (CORBA::SystemException, 
01663              SDOPackage::InvalidParameter, SDOPackage::NotAvailable,
01664              SDOPackage::InternalError);
01665     
01710     virtual SDOPackage::Configuration_ptr get_configuration()
01711       throw (CORBA::SystemException, 
01712              SDOPackage::InterfaceNotImplemented, SDOPackage::NotAvailable,
01713              SDOPackage::InternalError);
01714     
01758     virtual SDOPackage::Monitoring_ptr get_monitoring()
01759       throw (CORBA::SystemException, 
01760              SDOPackage::InterfaceNotImplemented, SDOPackage::NotAvailable,
01761              SDOPackage::InternalError);
01762     
01798     virtual SDOPackage::OrganizationList* get_organizations()
01799       throw (CORBA::SystemException, 
01800              SDOPackage::NotAvailable, SDOPackage::InternalError);
01801     
01833     virtual SDOPackage::NVList* get_status_list()
01834       throw (CORBA::SystemException, 
01835              SDOPackage::NotAvailable, SDOPackage::InternalError);
01836     
01873     virtual CORBA::Any* get_status(const char* name)
01874       throw (CORBA::SystemException, 
01875              SDOPackage::InvalidParameter, SDOPackage::NotAvailable,
01876              SDOPackage::InternalError);
01877     
01878     //============================================================
01879     // Local interfaces
01880     //============================================================
01900     const char* getInstanceName() {return m_profile.instance_name;}
01901     
01921     void setInstanceName(const char* instance_name);
01922     
01942     const char* getTypeName() {return m_profile.type_name;}
01943     
01963     const char* getDescription() { return m_profile.description;}
01964     
01985     const char* getVersion() {return m_profile.version;}
01986     
02006     const char* getVendor() {return m_profile.vendor;}
02007     
02027     const char* getCategory() {return m_profile.category;}
02028     
02048     std::vector<std::string> getNamingNames();
02049     
02069     void setObjRef(const RTObject_ptr rtobj);
02070     
02090     RTObject_ptr getObjRef() const;
02091     
02117     void setProperties(const Properties& prop);
02118     
02140     Properties& getProperties();
02141     
02174     template <typename VarType>
02175     bool bindParameter(const char* param_name, VarType& var,
02176                        const char* def_val,
02177                        bool (*trans)(VarType&, const char*) = ::stringTo)
02178     {
02179       m_configsets.bindParameter(param_name, var, def_val, trans);
02180       return true;
02181     }
02182     
02204     void updateParameters(const char* config_set);
02205     
02237     void registerPort(PortBase& port);
02238     
02265     template <class DataType, template <class DataType> class Buffer>
02266     void registerInPort(const char* name,
02267                         InPort<DataType, Buffer>& inport)
02268     {
02269       std::string propkey("port.dataport.");
02270       propkey += name;
02271       propkey += ".tcp_any";
02272       //      std::cout << "key: " << propkey << std::endl;
02273       //      std::cout << m_properties;
02274       m_properties[propkey];
02275       PortBase* port = new DataInPort(name, inport,
02276                                       *m_properties.getNode(propkey));
02277       registerPort(*port);
02278     }
02279     
02306     template <class DataType, template <class DataType> class Buffer>
02307     void registerOutPort(const char* name,
02308                          OutPort<DataType, Buffer>& outport)
02309     {
02310       std::string propkey("port.dataport.");
02311       propkey += name;
02312       propkey += ".tcp_any";
02313       //      std::cout << "key: " << propkey << std::endl;
02314       //      std::cout << m_properties;
02315       m_properties[propkey];
02316       PortBase* port = new DataOutPort(name, outport,
02317                                        *m_properties.getNode(propkey));
02318       registerPort(*port);
02319     }
02320     
02340     void deletePort(PortBase& port);
02341     
02361     void deletePortByName(const char* port_name);
02362     
02379     void finalizePorts();
02380     
02381     /*
02382       template <class DataType>
02383       void registerInPort(BufferBase<DataType>& buffer)
02384       {
02385       CorbaInPort<DataType>* port;
02386       p = new CorbaInPort<DataType>(buffer);
02387       Port_var inport;
02388       inport = new PortInPort();
02389       inport->setInPortRef(p->_this());
02390       }
02391     */
02392     
02393   protected:
02413     void shutdown();
02414     
02415   protected:
02423     Manager* m_pManager;
02424     
02432     CORBA::ORB_var m_pORB;
02433     
02441     PortableServer::POA_var m_pPOA;
02442     
02443     //============================================================
02444     // SDO 関係の変数
02445     //============================================================
02453     SDOPackage::OrganizationList m_sdoOwnedOrganizations;
02454     
02462     SDOPackage::ServiceProfileList m_sdoSvcProfiles;
02463     
02471     struct svc_name
02472     {
02473       svc_name (const char* id) : m_id(id) {};
02474       bool operator()(const SDOPackage::ServiceProfile& prof)
02475       {
02476         return m_id == std::string(prof.id);
02477       }
02478       std::string m_id;
02479     };
02480     
02488     SDOPackage::Configuration_impl* m_pSdoConfigImpl;
02489     
02497     SDOPackage::Configuration_var  m_pSdoConfig;
02498     
02506     SDOPackage::OrganizationList m_sdoOrganizations;
02507     
02515     SDOPackage::NVList m_sdoStatus;
02516     
02517     //============================================================
02518     // RTC 関係の変数
02519     //============================================================
02527     ComponentProfile m_profile;
02528     
02536     RTObject_ptr m_objref;
02537     
02545     PortAdmin m_portAdmin;
02546     
02554     ExecutionContextServiceList m_execContexts;
02555     
02563     bool m_created;
02564     
02572     bool m_alive;
02573     
02581     Properties m_properties;
02582     
02590     ConfigAdmin m_configsets;
02591     
02592     //------------------------------------------------------------
02593     // Functor
02594     //------------------------------------------------------------
02602     struct nv_name
02603     {
02604       nv_name(const char* name) : m_name(name) {};
02605       bool operator()(const SDOPackage::NameValue& nv)
02606       {
02607         return m_name == std::string(nv.name);
02608       }
02609       std::string m_name;
02610     };
02611     
02619     struct ec_copy
02620     {
02621       ec_copy(ExecutionContextList& eclist)
02622         : m_eclist(eclist)
02623       {
02624       }
02625       void operator()(ExecutionContextService_ptr ecs)
02626       {
02627         CORBA_SeqUtil::push_back(m_eclist, ExecutionContext::_duplicate(ecs));
02628       }
02629       ExecutionContextList& m_eclist;
02630     };
02631     //    ExecutionContextAdminList m_execContextList;
02632     
02640     struct deactivate_comps
02641     {
02642       deactivate_comps(LightweightRTObject_ptr comp)
02643         : m_comp(comp)
02644       {
02645       }
02646       void operator()(ExecutionContextService_ptr ec)
02647       {
02648         ec->deactivate_component(RTC::LightweightRTObject::_duplicate(m_comp));
02649       }
02650       LightweightRTObject_var m_comp;
02651     };
02652   };
02653 };
02654 #endif // RTObject

OpenRTMに対してWed May 21 05:17:25 2008に生成されました。  doxygen 1.5.3