メインページ | ネームスペース一覧 | クラス階層 | 構成 | Directories | ファイル一覧 | ネームスペースメンバ | 構成メンバ | ファイルメンバ

RTObject.h

説明を見る。
00001 // -*- C++ -*-
00019 /*
00020  * $Log: RTObject.h,v $
00021  * Revision 1.5  2007/01/14 22:59:01  n-ando
00022  * A bug fix about template argument for buffer-type.
00023  *
00024  * Revision 1.4  2007/01/14 19:46:14  n-ando
00025  * The component action implementation functions for Users' business logic
00026  * were added (i.e onInitialize(), onExecute(), etc..)
00027  *
00028  * Revision 1.3  2007/01/12 14:38:48  n-ando
00029  * The registeInPort()/registerOutPort functions are added.
00030  *
00031  * Revision 1.2  2007/01/09 15:21:47  n-ando
00032  * SDO interfaces are marged.
00033  * Some RTObject's operation signatures were changed.
00034  *
00035  * Revision 1.1  2006/09/11 19:04:38  n-ando
00036  * The first commit.
00037  *
00038  *
00039  */
00040 
00041 #ifndef RTObject_h
00042 #define RTObject_h
00043 
00044 // CORBA header include
00045 #include "rtm/RTC.h"
00046 #include "rtm/Properties.h"
00047 #include "rtm/idl/RTCSkel.h"
00048 #include "rtm/PortBase.h"
00049 //#include "rtm/ObjectManager.h"
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 // ACE
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     // Overridden functions
00082     //============================================================
00083     // The initialize action (on CREATED->ALIVE transition)
00084     // formaer rtc_init_entry() 
00085     virtual ReturnCode_t onInitialize();
00086     
00087     // The finalize action (on ALIVE->END transition)
00088     // formaer rtc_exiting_entry()
00089     virtual ReturnCode_t onFinalize();
00090     
00091     // The startup action when ExecutionContext startup
00092     // former rtc_starting_entry()
00093     virtual ReturnCode_t onStartup(RTC::UniqueId ec_id);
00094     
00095     // The shutdown action when ExecutionContext stop
00096     // former rtc_stopping_entry()
00097     virtual ReturnCode_t onShutdown(RTC::UniqueId ec_id);
00098     
00099     // The activated action (Active state entry action)
00100     // former rtc_active_entry()
00101     virtual ReturnCode_t onActivated(RTC::UniqueId ec_id);
00102     
00103     // The deactivated action (Active state exit action)
00104     // former rtc_active_exit()
00105     virtual ReturnCode_t onDeactivated(RTC::UniqueId ec_id);
00106     
00107     // The execution action that is invoked periodically
00108     // former rtc_active_do()
00109     virtual ReturnCode_t onExecute(RTC::UniqueId ec_id);
00110     
00111     // The aborting action when main logic error occurred.
00112     // former rtc_aborting_entry()
00113     virtual ReturnCode_t onAborting(RTC::UniqueId ec_id);
00114     
00115     // The error action in ERROR state
00116     // former rtc_error_do()
00117     virtual ReturnCode_t onError(RTC::UniqueId ec_id);
00118     
00119     // The reset action that is invoked resetting
00120     // This is same but different the former rtc_init_entry()
00121     virtual ReturnCode_t onReset(RTC::UniqueId ec_id);
00122     
00123     // The state update action that is invoked after onExecute() action
00124     // no corresponding operation exists in OpenRTm-aist-0.2.0
00125     virtual ReturnCode_t onStateUpdate(RTC::UniqueId ec_id);
00126 
00127     // The action that is invoked when execution context's rate is changed
00128     // no corresponding operation exists in OpenRTm-aist-0.2.0
00129     virtual ReturnCode_t onRateChanged(RTC::UniqueId ec_id);
00130 
00131 
00132   public:
00133     //============================================================
00134     // RTC::LightweightRTObject
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     // RTC::RTObject
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     // RTC::ComponentAction
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     // SDOPackage::SdoSystemElement
00360     //============================================================
00382     virtual SDOPackage::OrganizationList* get_owned_organizations()
00383       throw (SDOPackage::NotAvailable);
00384 
00385 
00386     //============================================================
00387     // SDOPackage::SDO
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     // Local interfaces
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     template <class DataType>
00918     void registerInPort(BufferBase<DataType>& buffer)
00919     {
00920       CorbaInPort<DataType>* port;
00921       p = new CorbaInPort<DataType>(buffer);
00922       Port_var inport;
00923       inport = new PortInPort();
00924       inport->setInPortRef(p->_this());
00925     }
00926     */
00927 
00928 
00929 
00930 
00931 
00932   protected:
00933     //============================================================
00934     // SDO 関係の変数
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     // RTC 関係の変数
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     //    ExecutionContextAdminList m_execContextList;
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

OpenRTMに対してMon Jan 15 12:14:44 2007に生成されました。  doxygen 1.4.1