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

ModuleManager.h

説明を見る。
00001 // -*- C++ -*-
00019 /*
00020  * $Log: ModuleManager.h,v $
00021  * Revision 1.2  2006/10/17 10:06:47  n-ando
00022  * Now class ModuleManager is in RTC namespace.
00023  *
00024  * Revision 1.1  2006/09/20 08:47:33  n-ando
00025  * The first commit of module management class.
00026  *
00027  *
00028  */
00029 
00030 #ifndef ModuleManager_h
00031 #define ModuleManager_h
00032 
00033 // STL includes
00034 #include <string>
00035 #include <vector>
00036 #include <map>
00037 
00038 // ACE includes
00039 #include <ace/DLL.h>
00040 
00041 // RTC includes
00042 #include <rtm/Properties.h>
00043 
00044 
00045 #define CONFIG_EXT    "manager.modules.config_ext"
00046 #define CONFIG_PATH   "manager.modules.config_path"
00047 #define DETECT_MOD    "manager.modules.detect_loadable"
00048 #define MOD_LOADPTH   "manager.modules.load_path"
00049 #define INITFUNC_SFX  "manager.modules.init_func_suffix"
00050 #define INITFUNC_PFX  "manager.modules.init_func_prefix"
00051 #define ALLOW_ABSPATH "manager.modules.abs_path_allowed"
00052 #define ALLOW_URL     "manager.modules.download_allowed"
00053 #define MOD_DWNDIR    "manager.modules.download_dir"
00054 #define MOD_DELMOD    "manager.modules.download_cleanup"
00055 #define MOD_PRELOAD   "manager.modules.preload"
00056 
00057 namespace RTC
00058 {
00071   class ModuleManager
00072   {
00073   public:
00074     ModuleManager(Properties& prop);
00075     
00076     ~ModuleManager();
00077     
00078     struct Error
00079     {
00080       Error(const std::string& _reason)
00081         : reason(_reason) {}
00082       std::string reason;
00083     };
00084     
00085     struct NotFound
00086     {
00087       NotFound(const std::string& _name)
00088         : name(_name) {}
00089       std::string name;
00090     };
00091     
00092     struct FileNotFound
00093       : public NotFound
00094     {
00095       FileNotFound(const std::string& _name)
00096         : NotFound(_name) {}
00097     };
00098     
00099     struct ModuleNotFound
00100       : public NotFound
00101     {
00102       ModuleNotFound(const std::string& _name)
00103         : NotFound(_name) {}
00104     };
00105     
00106     struct SymbolNotFound
00107       : public NotFound
00108     {
00109       SymbolNotFound(const std::string& _name)
00110         : NotFound(_name) {}
00111     };
00112     
00113     struct NotAllowedOperation
00114       : public Error
00115     {
00116       NotAllowedOperation(const std::string& _reason)
00117         : Error(_reason) {}
00118     };
00119     
00120     struct InvalidArguments
00121       : public Error
00122     {
00123       InvalidArguments(const std::string& _reason)
00124         : Error(_reason) {}
00125     };
00126     
00127     struct InvalidOperation
00128       : public Error
00129     {
00130       InvalidOperation(const std::string& _reason)
00131         : Error(_reason) {}
00132     };
00133     typedef void (*ModuleInitFunc)(void);
00159     std::string load(const std::string& file_name);
00160     std::string load(const std::string& file_name, const std::string& init_func);
00161     
00169     void unload(const std::string& file_name);
00170     
00171     
00179     void unloadAll();
00180     
00181     
00189     void* symbol(const std::string& file_name, const std::string& func_name)
00190       throw (ModuleNotFound, SymbolNotFound);
00191     
00199     void setLoadpath(const std::vector<std::string>& load_path);
00200     inline std::vector<std::string> getLoadPath()
00201     {
00202       return m_loadPath;
00203     }
00204     
00212     void addLoadpath(const std::vector<std::string>& load_path);
00213     
00214     
00222     std::vector<std::string> getLoadedModules();
00223     
00224     
00232     std::vector<std::string> getLoadableModules();
00233     
00234     
00242     inline void allowAbsolutePath()
00243     {
00244       m_absoluteAllowed = true;
00245     }
00246     
00254     inline void disallowAbsolutePath()
00255     {
00256       m_absoluteAllowed = false;
00257     }
00258     
00259     
00267     inline void allowModuleDownload()
00268     {
00269       m_downloadAllowed = true;
00270     }
00271     
00272     
00280     inline void disallowModuleDownload()
00281     {
00282       m_downloadAllowed = false;
00283     }
00284     
00285     
00293     std::string findFile(const std::string& fname,
00294                          const std::vector<std::string>& load_path);
00295     
00296     
00304     bool fileExist(const std::string& filename);
00305     
00306     
00314     std::string getInitFuncName(const std::string& file_path);
00315     
00316     
00317   protected:
00318     struct DLL
00319     {
00320       ACE_DLL dll;
00321     };
00322     
00323     typedef std::vector<std::string>     StringVector;
00324     typedef StringVector::iterator       StringVectorItr;
00325     typedef StringVector::const_iterator StringVectorConstItr;
00326     
00327     typedef std::map<std::string, DLL> DllMap;
00328     typedef DllMap::iterator           DllMapItr;
00329     typedef DllMap::const_iterator     DllMapConstItr;
00330     
00331     Properties& m_properties;
00332     
00333     DllMap m_modules;
00334     
00335     StringVector m_loadPath;
00336     StringVector m_configPath;
00337     bool m_downloadAllowed;
00338     bool m_absoluteAllowed;
00339     
00340     std::string m_initFuncSuffix;
00341     std::string m_initFuncPrefix;
00342     
00343   };   // class ModuleManager
00344 };     // namespace RTC  
00345   
00346 #endif // ModuleManager_h
00347   

OpenRTMに対してFri Sep 21 12:03:22 2007に生成されました。  doxygen 1.4.1