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

RtcManager.h

説明を見る。
00001 // -*- C++ -*-
00019 /*
00020  * $Log: RtcManager.h,v $
00021  * Revision 1.1.1.1  2005/05/12 09:06:18  n-ando
00022  * Public release.
00023  *
00024  *
00025  */
00026 
00027 #ifndef RtcManager_h
00028 #define RtcManager_h
00029 
00030 
00031 // CORBA includes
00032 //#include <RTC.h>
00033 
00034 // STL includes
00035 #include <list>
00036 #include <map>
00037 #include <memory>
00038 #include <string>
00039 #include <vector>
00040 #include <fstream>
00041 
00042 // ACE includes
00043 #include <ace/DLL.h>
00044 #include <ace/Signal.h>
00045 
00046 // Boost includes
00047 #include <boost/function.hpp>
00048 #include <boost/bind.hpp>
00049 
00050 // CORBA stub include
00051 #include "rtm/idl/RTCManagerSkel.h"
00052 #include "rtm/idl/RTCManagerStub.h"
00053 #include "rtm/RtcModuleProfile.h"
00054 #include "rtm/RtcBase.h"
00055 #include "rtm/RtcFactory.h"
00056 #include "rtm/RtcSystemLogger.h"
00057 
00058 // RTM includes
00059 
00060 namespace RTM
00061 {
00062   
00063   // Use std:: namespace
00064   using namespace std;
00065   
00066   // Pre-declaration of classes
00067   
00068   class RtcManager;
00069   class RtcNaming;
00070   class RtcConfig;
00071   
00072 #define RtcMgrCmd boost::function2<bool, vector<string>&, vector<string>& > 
00073   
00074   typedef void (*RtcModuleInitProc)(RtcManager* manager);  
00075   
00098   class RtcManager :
00099     public virtual POA_RTM::RTCManager, 
00100                                                         public virtual PortableServer::RefCountServantBase,
00101                                                                                                                    public ACE_Task<ACE_MT_SYNCH>
00102   {
00103         
00104   public:
00119     RtcManager(int argc, char** argv);
00120         void shutdown();
00128     virtual ~RtcManager();
00129         
00137         int open(void *args);
00138         
00146         int svc(void);
00147 
00148         int close(unsigned long flags);
00149         
00150     //============================================================
00151     //
00152     // <<< CORBA interfaces >>>
00153     //
00154     //============================================================
00155         
00156         
00177     virtual RtmRes load(const char* pathname, const char* initfunc);
00178         
00196     virtual RtmRes unload(const char* pathname);
00197         
00217     virtual RTCBase_ptr create_component(const char* module_name,
00218                                                                                  const char* category_name,
00219                                                                                  CORBA::String_out instance_name);
00220         
00240     virtual RtmRes delete_component(const char* instance_name,
00241                                                                         const char* category_name);
00242         
00256     virtual RTCFactoryList* factory_list();
00257         
00271     virtual RTCBaseList* component_list();
00272         
00286     virtual RtmRes command(const char* cmd, CORBA::String_out ret);
00287         
00288     // end of CORBA interface definition
00289     //============================================================
00290         
00291         
00292         
00293     //============================================================
00294     //
00295     // <<< Local interfaces >>>
00296     //
00297     //============================================================
00307     void initManager();
00308         
00318     void runManager();
00319         
00329     void runManagerNoBlocking();
00330         
00340     bool activateManager();
00341         
00351         void initModuleProc(RtcModuleInitProc proc);
00352         
00362     bool createCommand(string cmd,
00363                                            boost::function2<bool,
00364                                            vector<string>&, vector<string>&>  func);
00365         
00375     bool registerComponent(RtcModuleProfile& profile,
00376                                                    RtcNewFunc new_func,
00377                                                    RtcDeleteFunc delete_func);
00378         
00388         bool registerComponent(RtcFactoryBase* factory);
00389         
00390         
00400     RtcBase* createComponent(const string& module_name,
00401                                                          const string& category_name,
00402                                                          string& comp_name);
00403         
00413     RtcBase* createComponent(const string& module_name,
00414                                                          const string& category_name);
00415 
00416         
00426     void cleanupComponent(const string& instance_name,
00427                                                   const string& category_name);
00428         
00429         
00439     std::vector<RTCBase_ptr> findComponents(const string& comp_name);
00440         
00450     std::string bindInOut(RTCBase_ptr comp_in,
00451                                                   const std::string& inp_name,
00452                                                   RTCBase_ptr comp_out,
00453                                                   const std::string& outp_name,
00454                                                   RTM::SubscriptionType sub_type = RTM::OPS_NEW);
00464     std::string bindInOutByName(const std::string& comp_name_in,
00465                                                                 const std::string& inp_name,
00466                                                                 const std::string& comp_name_out,
00467                                                                 const std::string& outp_name,
00468                                                                 RTM::SubscriptionType sub_type = RTM::OPS_NEW);
00469         
00479     CORBA::ORB_var getORB();
00480         
00490     PortableServer::POA_var getPOA();
00491 
00492         RtcLogbuf& getLogbuf() {return m_Logbuf;}
00493         RtcConfig& getConfig() {return (*m_apConfig);}
00494 
00495 
00496         
00497     //============================================================
00498     // Commands
00499         
00500     bool loadCmd(const vector<string>& cmd, vector<string>& retval);
00501     bool unloadCmd(const vector<string>& cmd, vector<string>& retval);
00502     bool createComponentCmd(const vector<string>& cmd, vector<string>& retval);
00503     bool listComponent(const vector<string>& cmd, vector<string>& retval);
00504     bool listModule(const vector<string>& cmd, vector<string>& retval);
00505     bool commandListCmd(const vector<string>& cmd, vector<string>& retval);
00506 
00507   private:
00511     bool initORB();
00512         
00516     bool initPOA();
00517 
00518         bool initLogger();
00519         bool initMasterLogger();
00520         void loadMasterLogger();
00521 
00522         
00526     bool findPath(string path, string &full_path);
00527         
00531     bool libnameToInitFunc(const char* libname,
00532                                                    const char* initfunc,
00533                                                    string &initfunc_name);
00534         
00535         void shutdownAllComponents();
00536         
00537   private:
00545     auto_ptr<RtcConfig> m_apConfig;
00546         
00554     auto_ptr<RtcNaming> m_apNaming;
00555         
00563     CORBA::ORB_var m_pORB;
00564         
00572     PortableServer::POA_var m_pPOA;
00573         
00581     PortableServer::POAManager_var m_pPOAManager;
00582         
00590     map<string, boost::function2<bool, vector<string>&, vector<string>&> > m_CmdMap;
00591         
00599     list<string> m_LibraryLoadPath;
00600         
00602         /*    struct Factory {
00603                   
00604         RtcModuleProfile _profile;
00605         RtcNewFunc _new;
00606         RtcDeleteFunc _delete;
00607         int _num;
00608     };
00609         */
00610         
00618         struct FactoryMap {
00620       ACE_Thread_Mutex _mutex;
00622           std::map<std::string, std::map<std::string, RtcFactoryBase*> > _map;
00623         };
00624         
00632         FactoryMap m_FactoryMap;
00633         
00641     struct DLL {
00642       int _refCount;
00643       ACE_DLL _dll;
00644     };
00645         
00653     map<string, DLL> m_Lib; // Library name <=> DLL manager
00654 
00655         ACE_Sig_Action* m_SigAction;
00656         ACE_Sig_Action* m_SigHupAction;
00657         ACE_Sig_Action* m_SigIntAction;
00658         ACE_Sig_Action* m_SigKillAction;
00659         ACE_Sig_Action* m_SigSegvAction;
00660         ACE_Sig_Action* m_SigBusAction;
00661 
00662   public:
00670     struct ComponentMap {
00672       ACE_Thread_Mutex _mutex;
00673       std::map<string, std::map<string, RtcBase*> > _map;
00674     };
00685     ComponentMap m_Components;
00686         
00694     typedef bool (*RtcComponentInit)(RtcManager* manager);
00695         
00703     string m_ManagerName;
00704 
00712         RtcLogbuf m_Logbuf;
00720         RtcMedLogbuf m_MedLogbuf;
00728         RtcLogStream rtcout;
00729 
00730         TimedString m_LoggerOut;
00731         typedef OutPortAny<TimedString> LogOutPort;
00732         LogOutPort* m_pLoggerOutPort;
00733 
00734         class LogEmitter
00735           : public RtcSyncCallback
00736         {
00737         public:
00738           LogEmitter(OutPortAny<TimedString>& port, TimedString& var)
00739                 : m_OutPort(port), m_Var(var)
00740           {
00741           }
00742           virtual int operator()(const char* s)
00743           {
00744                 m_Var.data = CORBA::string_dup(s);
00745                 m_OutPort.write();
00746           }
00747         protected:
00748           OutPortAny<TimedString>& m_OutPort;
00749           TimedString& m_Var;
00750         };
00751         
00752         LogEmitter* m_pLogEmitter;
00753         RTCBase_var m_pMasterLogger;    
00754   };
00755 
00756 
00757 }; // end of namespace RTM
00758 
00759 #endif // RtcManager_h

OpenRTMに対してMon May 23 03:13:42 2005に生成されました。 doxygen 1.3.6