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

RTObject.h

説明を見る。
00001 // -*- C++ -*-
00019 /*
00020  * $Log: RTObject.h,v $
00021  * Revision 1.7.2.1  2007/07/20 16:06:13  n-ando
00022  * CORBA interface inconsistency was fixed.
00023  *
00024  * Revision 1.7  2007/04/23 04:57:44  n-ando
00025  * Finalization processed was modified.
00026  * Configuration admin class was introduced.
00027  *
00028  * Revision 1.6  2007/04/13 15:55:43  n-ando
00029  * RTObject interface operations in RTC.idl were changed.
00030  * - attach_executioncontext()
00031  * - detach_executioncontext()
00032  *
00033  * Revision 1.5  2007/01/14 22:59:01  n-ando
00034  * A bug fix about template argument for buffer-type.
00035  *
00036  * Revision 1.4  2007/01/14 19:46:14  n-ando
00037  * The component action implementation functions for Users' business logic
00038  * were added (i.e onInitialize(), onExecute(), etc..)
00039  *
00040  * Revision 1.3  2007/01/12 14:38:48  n-ando
00041  * The registeInPort()/registerOutPort functions are added.
00042  *
00043  * Revision 1.2  2007/01/09 15:21:47  n-ando
00044  * SDO interfaces are marged.
00045  * Some RTObject's operation signatures were changed.
00046  *
00047  * Revision 1.1  2006/09/11 19:04:38  n-ando
00048  * The first commit.
00049  *
00050  *
00051  */
00052 
00053 #ifndef RTObject_h
00054 #define RTObject_h
00055 
00056 // CORBA header include
00057 #include "rtm/RTC.h"
00058 #include "rtm/Properties.h"
00059 #include "rtm/idl/RTCSkel.h"
00060 #include "rtm/idl/OpenRTMSkel.h"
00061 #include "rtm/PortBase.h"
00062 //#include "rtm/ObjectManager.h"
00063 #include "rtm/PortAdmin.h"
00064 #include <rtm/DataInPort.h>
00065 #include <rtm/DataOutPort.h>
00066 #include <rtm/InPort.h>
00067 #include <rtm/OutPort.h>
00068 #include <rtm/ConfigAdmin.h>
00069 
00070 // ACE
00071 #include <ace/Task.h>
00072 
00073 
00074 namespace SDOPackage
00075 {
00076   class Configuration_impl;
00077 };
00078 
00079 namespace RTC
00080 {
00081   class Manager;
00082 
00083   class RTObject_impl
00084     : public virtual POA_RTC::DataFlowComponent, 
00085       public virtual PortableServer::RefCountServantBase
00086   {
00087   public:
00088     RTObject_impl(Manager* manager);
00089     RTObject_impl(CORBA::ORB_ptr orb, PortableServer::POA_ptr poa);
00090     virtual ~RTObject_impl();
00091 
00092 
00093   protected:
00094     //============================================================
00095     // Overridden functions
00096     //============================================================
00097     // The initialize action (on CREATED->ALIVE transition)
00098     // formaer rtc_init_entry() 
00099     virtual ReturnCode_t onInitialize();
00100     
00101     // The finalize action (on ALIVE->END transition)
00102     // formaer rtc_exiting_entry()
00103     virtual ReturnCode_t onFinalize();
00104     
00105     // The startup action when ExecutionContext startup
00106     // former rtc_starting_entry()
00107     virtual ReturnCode_t onStartup(RTC::UniqueId ec_id);
00108     
00109     // The shutdown action when ExecutionContext stop
00110     // former rtc_stopping_entry()
00111     virtual ReturnCode_t onShutdown(RTC::UniqueId ec_id);
00112     
00113     // The activated action (Active state entry action)
00114     // former rtc_active_entry()
00115     virtual ReturnCode_t onActivated(RTC::UniqueId ec_id);
00116     
00117     // The deactivated action (Active state exit action)
00118     // former rtc_active_exit()
00119     virtual ReturnCode_t onDeactivated(RTC::UniqueId ec_id);
00120     
00121     // The execution action that is invoked periodically
00122     // former rtc_active_do()
00123     virtual ReturnCode_t onExecute(RTC::UniqueId ec_id);
00124     
00125     // The aborting action when main logic error occurred.
00126     // former rtc_aborting_entry()
00127     virtual ReturnCode_t onAborting(RTC::UniqueId ec_id);
00128     
00129     // The error action in ERROR state
00130     // former rtc_error_do()
00131     virtual ReturnCode_t onError(RTC::UniqueId ec_id);
00132     
00133     // The reset action that is invoked resetting
00134     // This is same but different the former rtc_init_entry()
00135     virtual ReturnCode_t onReset(RTC::UniqueId ec_id);
00136     
00137     // The state update action that is invoked after onExecute() action
00138     // no corresponding operation exists in OpenRTm-aist-0.2.0
00139     virtual ReturnCode_t onStateUpdate(RTC::UniqueId ec_id);
00140 
00141     // The action that is invoked when execution context's rate is changed
00142     // no corresponding operation exists in OpenRTm-aist-0.2.0
00143     virtual ReturnCode_t onRateChanged(RTC::UniqueId ec_id);
00144 
00145 
00146   public:
00147     //============================================================
00148     // RTC::LightweightRTObject
00149     //============================================================
00180     virtual ReturnCode_t initialize();
00181 
00182 
00220     virtual ReturnCode_t finalize();
00221 
00222 
00258     virtual ReturnCode_t exit(); 
00259 
00280     virtual CORBA::Boolean is_alive();
00281 
00282 
00290     virtual ExecutionContextList* get_contexts();
00291 
00299     virtual ExecutionContext_ptr get_context(UniqueId ec_id);
00300 
00301     /*
00302     virtual UniqueId 
00303     set_execution_context_service(const ExecutionContextService_ptr ec);
00304     */
00305 
00306     //============================================================
00307     // RTC::RTObject
00308     //============================================================
00324     virtual ComponentProfile* get_component_profile();
00325 
00326 
00342     virtual PortList* get_ports();
00343 
00344 
00362     virtual ExecutionContextServiceList* get_execution_context_services();
00363 
00364 
00365 
00366     // RTC::ComponentAction
00367     UniqueId attach_executioncontext(ExecutionContext_ptr exec_context);
00368     ReturnCode_t detach_executioncontext(UniqueId ec_id);
00369     virtual ReturnCode_t on_initialize();
00370     virtual ReturnCode_t on_finalize();
00371     virtual ReturnCode_t on_startup(UniqueId ec_id);
00372     virtual ReturnCode_t on_shutdown(UniqueId ec_id);
00373     virtual ReturnCode_t on_activated(UniqueId ec_id);
00374     virtual ReturnCode_t on_deactivated(UniqueId ec_id);
00375     virtual ReturnCode_t on_aborting(UniqueId ec_id);
00376     virtual ReturnCode_t on_error(UniqueId ec_id);
00377     virtual ReturnCode_t on_reset(UniqueId ec_id);
00378 
00379     virtual ReturnCode_t on_execute(UniqueId ec_id);
00380     virtual ReturnCode_t on_state_update(UniqueId ec_id);
00381     virtual ReturnCode_t on_rate_changed(UniqueId ec_id);
00382 
00383 
00384 
00385     //============================================================
00386     // SDOPackage::SdoSystemElement
00387     //============================================================
00409     virtual SDOPackage::OrganizationList* get_owned_organizations()
00410       throw (SDOPackage::NotAvailable);
00411 
00412 
00413     //============================================================
00414     // SDOPackage::SDO
00415     //============================================================
00445     virtual char* get_sdo_id()
00446       throw (SDOPackage::NotAvailable, SDOPackage::InternalError);
00447     
00477     virtual char* get_sdo_type()
00478       throw (SDOPackage::NotAvailable, SDOPackage::InternalError);
00479 
00510     virtual SDOPackage::DeviceProfile* get_device_profile()
00511       throw (SDOPackage::NotAvailable, SDOPackage::InternalError);
00512     
00544     virtual SDOPackage::ServiceProfileList* get_service_profiles()
00545       throw (SDOPackage::InvalidParameter, SDOPackage::NotAvailable,
00546              SDOPackage::InternalError);
00547     
00576     virtual SDOPackage::ServiceProfile* get_service_profile(const char* id)
00577       throw (SDOPackage::InvalidParameter, SDOPackage::NotAvailable,
00578              SDOPackage::InternalError);
00579     
00607     virtual SDOPackage::SDOService_ptr get_sdo_service(const char* id)
00608       throw (SDOPackage::InvalidParameter, SDOPackage::NotAvailable,
00609              SDOPackage::InternalError);
00610     
00650     virtual SDOPackage::Configuration_ptr get_configuration()
00651       throw (SDOPackage::InterfaceNotImplemented, SDOPackage::NotAvailable,
00652              SDOPackage::InternalError);
00653     
00692     virtual SDOPackage::Monitoring_ptr get_monitoring()
00693       throw (SDOPackage::InterfaceNotImplemented, SDOPackage::NotAvailable,
00694              SDOPackage::InternalError);
00695 
00726     virtual SDOPackage::OrganizationList* get_organizations()
00727       throw (SDOPackage::NotAvailable, SDOPackage::InternalError);
00728     
00755     virtual SDOPackage::NVList* get_status_list()
00756       throw (SDOPackage::NotAvailable, SDOPackage::InternalError);
00757     
00787     virtual CORBA::Any* get_status(const char* name)
00788       throw (SDOPackage::InvalidParameter, SDOPackage::NotAvailable,
00789              SDOPackage::InternalError);
00790 
00791 
00792 
00793     //============================================================
00794     // Local interfaces
00795     //============================================================
00796     const char* getInstanceName() {return m_profile.instance_name;}
00797     void setInstanceName(const char* instance_name);
00798     const char* getTypeName() {return m_profile.type_name;}
00799     const char* getDescription() { return m_profile.description;}
00800     const char* getVersion() {return m_profile.version;}
00801     const char* getVendor() {return m_profile.vendor;}
00802     const char* getCategory() {return m_profile.category;}
00803 
00804     std::vector<std::string> getNamingNames();
00805 
00806     void setObjRef(const RTObject_ptr rtobj);
00807     RTObject_ptr getObjRef() const;
00808 
00809 
00810 
00836     void setProperties(const Properties& prop);
00837 
00859     Properties& getProperties();
00860 
00861 
00862     template <typename VarType>
00863     bool bindParameter(const char* param_name, VarType& var,
00864                        const char* def_val,
00865                        bool (*trans)(VarType&, const char*) = ::stringTo)
00866     {
00867       m_configsets.bindParameter(param_name, var, def_val, trans);
00868       return true;
00869     }
00870 
00871     void updateParameters(const char* config_set);
00872 
00904     void registerPort(PortBase& port);
00905 
00906     template <class DataType, template <class DataType> class Buffer>
00907     void registerInPort(const char* name,
00908                         InPort<DataType, Buffer>& inport)
00909     {
00910       std::string propkey("port.dataport.");
00911       propkey += name;
00912       propkey += ".tcp_any";
00913       //      std::cout << "key: " << propkey << std::endl;
00914       //      std::cout << m_properties;
00915       m_properties[propkey];
00916       PortBase* port = new DataInPort(name, inport,
00917                                       *m_properties.getNode(propkey));
00918       registerPort(*port);
00919     }
00920 
00921     template <class DataType, template <class DataType> class Buffer>
00922     void registerOutPort(const char* name,
00923                          OutPort<DataType, Buffer>& outport)
00924     {
00925       std::string propkey("port.dataport.");
00926       propkey += name;
00927       propkey += ".tcp_any";
00928       //      std::cout << "key: " << propkey << std::endl;
00929       //      std::cout << m_properties;
00930       m_properties[propkey];
00931       PortBase* port = new DataOutPort(name, outport,
00932                                        *m_properties.getNode(propkey));
00933       registerPort(*port);
00934     }
00935       
00936 
00962     void deletePort(PortBase& port);
00963     void deletePortByName(const char* port_name);
00964     void finalizePorts();
00965 
00966 
00967 
00968     /*
00969     template <class DataType>
00970     void registerInPort(BufferBase<DataType>& buffer)
00971     {
00972       CorbaInPort<DataType>* port;
00973       p = new CorbaInPort<DataType>(buffer);
00974       Port_var inport;
00975       inport = new PortInPort();
00976       inport->setInPortRef(p->_this());
00977     }
00978     */
00979 
00980   protected:
00981     void shutdown();
00982 
00983 
00984 
00985 
00986 
00987   protected:
00988     Manager* m_pManager;
00989     CORBA::ORB_var m_pORB;
00990     PortableServer::POA_var m_pPOA;
00991 
00992     //============================================================
00993     // SDO 関係の変数
00994     //============================================================
00998     SDOPackage::OrganizationList m_sdoOwnedOrganizations;
00999 
01003     SDOPackage::ServiceProfileList m_sdoSvcProfiles;
01004 
01008     struct svc_name
01009     {
01010       svc_name (const char* id) : m_id(id) {};
01011       bool operator()(const SDOPackage::ServiceProfile& prof)
01012       {
01013         return m_id == std::string(prof.id);
01014       }
01015       std::string m_id;
01016     };
01017 
01021     SDOPackage::Configuration_impl* m_pSdoConfigImpl;
01022     SDOPackage::Configuration_var  m_pSdoConfig;
01023 
01027     SDOPackage::OrganizationList m_sdoOrganizations;
01028 
01032     SDOPackage::NVList m_sdoStatus;
01033 
01034     
01035     //============================================================
01036     // RTC 関係の変数
01037     //============================================================
01041     ComponentProfile m_profile;
01042 
01043     RTObject_ptr m_objref;
01047     PortAdmin m_portAdmin;
01048 
01049     ExecutionContextServiceList m_execContexts;
01050 
01051     bool m_created;
01052     bool m_alive;
01053 
01057     Properties m_properties;
01058 
01059     ConfigAdmin m_configsets;
01060 
01061     //------------------------------------------------------------
01062     // Functor
01063     //------------------------------------------------------------
01064     struct nv_name
01065     {
01066       nv_name(const char* name) : m_name(name) {};
01067       bool operator()(const SDOPackage::NameValue& nv)
01068       {
01069         return m_name == std::string(nv.name);
01070       }
01071       std::string m_name;
01072     };
01073 
01074 
01075     struct ec_copy
01076     {
01077       ec_copy(ExecutionContextList& eclist)
01078         : m_eclist(eclist)
01079       {
01080       }
01081       void operator()(ExecutionContextService_ptr ecs)
01082       {
01083         CORBA_SeqUtil::push_back(m_eclist, ExecutionContext::_duplicate(ecs));
01084       }
01085       ExecutionContextList& m_eclist;
01086     };
01087     //    ExecutionContextAdminList m_execContextList;
01088 
01089     struct deactivate_comps
01090     {
01091       deactivate_comps(LightweightRTObject_ptr comp)
01092         : m_comp(comp)
01093       {
01094       }
01095       void operator()(ExecutionContextService_ptr ec)
01096       {
01097         ec->deactivate_component(RTC::LightweightRTObject::_duplicate(m_comp));
01098       }
01099       LightweightRTObject_var m_comp;
01100     };
01101 
01102 
01103   };
01104 };
01105 #endif // RTObject

OpenRTMに対してFri Oct 5 05:14:57 2007に生成されました。  doxygen 1.4.1