CLAM-Development
1.1
|
00001 #ifndef RunTimeLibraryLoader_hxx 00002 #define RunTimeLibraryLoader_hxx 00003 00004 #include <string> 00005 #include <vector> 00006 #include <map> 00007 #include <list> 00008 00009 00010 class RunTimeLibraryLoader 00011 { 00012 public: 00013 00014 virtual ~RunTimeLibraryLoader() {} 00015 virtual void Load() const; 00016 virtual void ReLoad(); 00017 00018 const std::string CompletePathFor(const std::string & subpathAndName) const; // if subpathAndName exists on environment paths, returns full path 00019 00020 // static methods for dynamic libraries handles 00021 static void * FullyLoadLibrary(const std::string & libraryPath); 00022 static void * LazyLoadLibrary(const std::string & libraryPath); 00023 static bool ReleaseLibraryHandler(void * handle, const std::string pluginFullFilename=""); 00024 static const std::string LibraryLoadError(); 00025 static const std::string FileOfSymbol (void * symbolAddress); 00026 00027 protected: 00028 void LoadLibrariesFromPath(const std::string & path) const; 00029 std::vector<std::string> SplitPathVariable(const std::string & pathVariable) const; 00030 void * GetLibraryHandler(const std::string & libraryPath) const; 00031 const char * pathSeparator() const 00032 { 00033 return 00034 #ifdef WIN32 00035 ";"; 00036 #else 00037 ":"; 00038 #endif 00039 } 00040 // to implement by subclasses (ex. Ladspa, CLAM processings, etc) 00041 virtual const char ** standardPaths() const = 0; 00042 virtual const char * homePath() const = 0; 00043 virtual const char * pathEnvironmentVar() const = 0; 00044 virtual const char * libraryType() const = 0; 00045 virtual const bool needReleaseHandlerOnReload() const =0; 00046 virtual void SetupLibrary( void* handle, const std::string & pluginFullFilename ) const {} 00047 const std::string getPathFromFullFileName(const std::string & fullFileNameConst) const 00048 { 00049 std::string fullFileName = fullFileNameConst; 00050 return fullFileName.substr(0,fullFileName.rfind("/")); 00051 } 00052 bool IsOnPath(const std::string & path) const; 00053 virtual const std::list<std::string> GetUsedLibraries(); 00054 00055 private: 00056 const std::string GetPaths() const; 00057 }; 00058 00059 #endif //RunTimeLibraryLoader_hxx 00060