CLAM-Development  1.4.0
RunTimeLibraryLoader.hxx
Go to the documentation of this file.
1 #ifndef RunTimeLibraryLoader_hxx
2 #define RunTimeLibraryLoader_hxx
3 
4 #include <string>
5 #include <vector>
6 #include <map>
7 #include <list>
8 
9 
11 {
12 public:
13 
14  virtual ~RunTimeLibraryLoader() {}
15  void Load() const;
16  void ReLoad();
17 
18  const std::string CompletePathFor(const std::string & subpathAndName) const; // if subpathAndName exists on environment paths, returns full path
19 
20  // static methods for dynamic libraries handles
21  static void * FullyLoadLibrary(const std::string & libraryPath);
22  static void * LazyLoadLibrary(const std::string & libraryPath);
23  static bool ReleaseLibraryHandler(void * handle, const std::string pluginFullFilename="");
24  static const std::string LibraryLoadError();
25  static const std::string FileOfSymbol (void * symbolAddress);
26  static void * GetSymbol(void * libraryHandler, const std::string & symbolName);
27 
28 protected:
29  void LoadLibrariesFromPath(const std::string & path) const;
30  std::vector<std::string> SplitPathVariable(const std::string & pathVariable) const;
31  void * GetLibraryHandler(const std::string & libraryPath) const;
32  const char * pathSeparator() const
33  {
34  return
35  #ifdef WIN32
36  ";";
37  #else
38  ":";
39  #endif
40  }
41  // to implement by subclasses (ex. Ladspa, CLAM processings, etc)
42  virtual const char ** standardPaths() const = 0;
43  virtual const char * homePath() const = 0;
44  virtual const char * pathEnvironmentVar() const = 0;
45  virtual const char * libraryType() const = 0;
46  virtual const bool needReleaseHandlerOnReload() const =0;
47  virtual void SetupLibrary( void* handle, const std::string & pluginFullFilename ) const {}
48  const std::string getPathFromFullFileName(const std::string & fullFileNameConst) const
49  {
50  std::string fullFileName = fullFileNameConst;
51  return fullFileName.substr(0,fullFileName.rfind("/"));
52  }
53  bool IsOnPath(const std::string & path) const;
54  virtual std::list<std::string> GetUsedLibraries();
55 
56 private:
57  const std::string GetPaths() const;
58 };
59 
60 #endif //RunTimeLibraryLoader_hxx
61