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

RtcManager.h

説明を見る。
00001 // -*- C++ -*-
00020 #ifndef RtcManager_h
00021 #define RtcManager_h
00022 
00023 
00024 // CORBA includes
00025 //#include <RTC.h>
00026 
00027 // STL includes
00028 #include <list>
00029 #include <map>
00030 #include <memory>
00031 #include <string>
00032 #include <vector>
00033 #include <fstream>
00034 
00035 // ACE includes
00036 #include <ace/DLL.h>
00037 #include <ace/Signal.h>
00038 
00039 // Boost includes
00040 #include <boost/function.hpp>
00041 #include <boost/bind.hpp>
00042 
00043 // CORBA stub include
00044 #include "rtm/idl/RTCManagerSkel.h"
00045 #include "rtm/idl/RTCManagerStub.h"
00046 #include "rtm/RtcModuleProfile.h"
00047 #include "rtm/RtcBase.h"
00048 #include "rtm/RtcFactory.h"
00049 #include "rtm/RtcSystemLogger.h"
00050 
00051 // RTM includes
00052 
00053 namespace RTM
00054 {
00055   
00056   // Use std:: namespace
00057   using namespace std;
00058   
00059   // Pre-declaration of classes
00060   
00061   class RtcManager;
00062   class RtcNaming;
00063   class RtcConfig;
00064   
00065 #define RtcMgrCmd boost::function2<bool, vector<string>&, vector<string>& > 
00066   
00067   typedef void (*RtcModuleInitProc)(RtcManager* manager);  
00068   
00091   class RtcManager :
00092     public virtual POA_RTM::RTCManager, 
00093                                                         public virtual PortableServer::RefCountServantBase,
00094                                                                                                                    public ACE_Task<ACE_MT_SYNCH>
00095   {
00096         
00097   public:
00112     RtcManager(int argc, char** argv);
00113         void shutdown();
00121     virtual ~RtcManager();
00122         
00130         int open(void *args);
00131         
00139         int svc(void);
00140 
00141         int close(unsigned long flags);
00142         
00143     //============================================================
00144     //
00145     // <<< CORBA interfaces >>>
00146     //
00147     //============================================================
00148         
00149         
00170     virtual RtmRes load(const char* pathname, const char* initfunc);
00171         
00189     virtual RtmRes unload(const char* pathname);
00190         
00210     virtual RTCBase_ptr create_component(const char* module_name,
00211                                                                                  const char* category_name,
00212                                                                                  CORBA::String_out instance_name);
00213         
00233     virtual RtmRes delete_component(const char* instance_name,
00234                                                                         const char* category_name);
00235         
00249     virtual RTCFactoryList* factory_list();
00250         
00264     virtual RTCBaseList* component_list();
00265         
00279     virtual RtmRes command(const char* cmd, CORBA::String_out ret);
00280         
00281     // end of CORBA interface definition
00282     //============================================================
00283         
00284         
00285         
00286     //============================================================
00287     //
00288     // <<< Local interfaces >>>
00289     //
00290     //============================================================
00300     void initManager();
00301         
00311     void runManager();
00312         
00322     void runManagerNoBlocking();
00323         
00333     bool activateManager();
00334         
00344         void initModuleProc(RtcModuleInitProc proc);
00345         
00355     bool createCommand(string cmd,
00356                                            boost::function2<bool,
00357                                            vector<string>&, vector<string>&>  func);
00358         
00368     bool registerComponent(RtcModuleProfile& profile,
00369                                                    RtcNewFunc new_func,
00370                                                    RtcDeleteFunc delete_func);
00371         
00381         bool registerComponent(RtcFactoryBase* factory);
00382         
00383         
00393     RtcBase* createComponent(const string& module_name,
00394                                                          const string& category_name,
00395                                                          string& comp_name);
00396         
00406     RtcBase* createComponent(const string& module_name,
00407                                                          const string& category_name);
00408 
00409         
00419     void cleanupComponent(const string& instance_name,
00420                                                   const string& category_name);
00421         
00422         
00432     std::vector<RTCBase_ptr> findComponents(const string& comp_name);
00433         
00443     std::string bindInOut(RTCBase_ptr comp_in,
00444                                                   const std::string& inp_name,
00445                                                   RTCBase_ptr comp_out,
00446                                                   const std::string& outp_name,
00447                                                   RTM::SubscriptionType sub_type = RTM::OPS_NEW);
00457     std::string bindInOutByName(const std::string& comp_name_in,
00458                                                                 const std::string& inp_name,
00459                                                                 const std::string& comp_name_out,
00460                                                                 const std::string& outp_name,
00461                                                                 RTM::SubscriptionType sub_type = RTM::OPS_NEW);
00462         
00472     CORBA::ORB_var getORB();
00473         
00483     PortableServer::POA_var getPOA();
00484 
00485         RtcLogbuf& getLogbuf() {return m_Logbuf;}
00486         RtcConfig& getConfig() {return (*m_apConfig);}
00487 
00488 
00489         
00490     //============================================================
00491     // Commands
00492         
00493     bool loadCmd(const vector<string>& cmd, vector<string>& retval);
00494     bool unloadCmd(const vector<string>& cmd, vector<string>& retval);
00495     bool createComponentCmd(const vector<string>& cmd, vector<string>& retval);
00496     bool listComponent(const vector<string>& cmd, vector<string>& retval);
00497     bool listModule(const vector<string>& cmd, vector<string>& retval);
00498     bool commandListCmd(const vector<string>& cmd, vector<string>& retval);
00499 
00500   private:
00504     bool initORB();
00505         
00509     bool initPOA();
00510 
00511         bool initLogger();
00512         bool initMasterLogger();
00513         void loadMasterLogger();
00514 
00515         
00519     bool findPath(string path, string &full_path);
00520         
00524     bool libnameToInitFunc(const char* libname,
00525                                                    const char* initfunc,
00526                                                    string &initfunc_name);
00527         
00528         void shutdownAllComponents();
00529         
00530   private:
00538     auto_ptr<RtcConfig> m_apConfig;
00539         
00547     auto_ptr<RtcNaming> m_apNaming;
00548         
00556     CORBA::ORB_var m_pORB;
00557         
00565     PortableServer::POA_var m_pPOA;
00566         
00574     PortableServer::POAManager_var m_pPOAManager;
00575         
00583     map<string, boost::function2<bool, vector<string>&, vector<string>&> > m_CmdMap;
00584         
00592     list<string> m_LibraryLoadPath;
00593         
00595         /*    struct Factory {
00596                   
00597         RtcModuleProfile _profile;
00598         RtcNewFunc _new;
00599         RtcDeleteFunc _delete;
00600         int _num;
00601     };
00602         */
00603         
00611         struct FactoryMap {
00613       ACE_Thread_Mutex _mutex;
00615           std::map<std::string, std::map<std::string, RtcFactoryBase*> > _map;
00616         };
00617         
00625         FactoryMap m_FactoryMap;
00626         
00634     struct DLL {
00635       int _refCount;
00636       ACE_DLL _dll;
00637     };
00638         
00646     map<string, DLL> m_Lib; // Library name <=> DLL manager
00647 
00648         ACE_Sig_Action* m_SigAction;
00649         ACE_Sig_Action* m_SigHupAction;
00650         ACE_Sig_Action* m_SigIntAction;
00651         ACE_Sig_Action* m_SigKillAction;
00652         ACE_Sig_Action* m_SigSegvAction;
00653         ACE_Sig_Action* m_SigBusAction;
00654 
00655   public:
00663     struct ComponentMap {
00665       ACE_Thread_Mutex _mutex;
00666       std::map<string, std::map<string, RtcBase*> > _map;
00667     };
00678     ComponentMap m_Components;
00679         
00687     typedef bool (*RtcComponentInit)(RtcManager* manager);
00688         
00696     string m_ManagerName;
00697 
00705         RtcLogbuf m_Logbuf;
00713         RtcMedLogbuf m_MedLogbuf;
00721         RtcLogStream rtcout;
00722 
00723         TimedString m_LoggerOut;
00724         typedef OutPortAny<TimedString> LogOutPort;
00725         LogOutPort* m_pLoggerOutPort;
00726 
00727         class LogEmitter
00728           : public sync_callback<char>
00729         {
00730         public:
00731           LogEmitter(OutPortAny<TimedString>& port, TimedString& var)
00732                 : m_OutPort(port), m_Var(var)
00733           {
00734           }
00735           virtual int operator()(const char* s)
00736           {
00737                 m_Var.data = CORBA::string_dup(s);
00738                 m_OutPort.write();
00739           }
00740         protected:
00741           OutPortAny<TimedString>& m_OutPort;
00742           TimedString& m_Var;
00743         };
00744         
00745         LogEmitter* m_pLogEmitter;
00746         RTCBase_var m_pMasterLogger;    
00747   };
00748 
00749 
00750 }; // end of namespace RTM
00751 
00752 #endif // 

OpenRTMに対してWed Apr 6 14:22:11 2005に生成されました。 doxygen 1.3.6