Loads a Shared Object library.
The be moved, but not copied. When the object is destroyed, the library is closed. The caller is responsible for keeping the object alive while symbols from the object are being used.
Definition at line 13 of file DynamicLibrary.h.
Public Member Functions | |
DynamicLibrary (std::string libname_param, bool unique_name=false) | |
DynamicLibrary (DynamicLibrary &&other) | |
DynamicLibrary (const DynamicLibrary &)=delete | |
~DynamicLibrary () | |
void * | GetSymbol (const char *symbol) |
DynamicLibrary & | operator= (DynamicLibrary &&other) |
DynamicLibrary & | operator= (const DynamicLibrary &)=delete |
Private Member Functions | |
void | swap (DynamicLibrary &other) |
Private Attributes | |
std::string | fLibName |
void * | fLibrary |
std::string | fTempName |
#include <DynamicLibrary.h>
DynamicLibrary::DynamicLibrary | ( | std::string | libname_param, |
bool | unique_name = false |
||
) |
Loads a shared object library.
libname_param | Path to the library to be loaded. |
unique_name | Generates a uniquely named symlink to the file, which is then opened. |
dlopen/dlclose maintains a reference count, caching shared objects in case a library is loaded multiple times. However, if a library is going to change as the program runs, then this caching works against us. In this case, "unique_name" should be set to true.
Definition at line 29 of file DynamicLibrary.cxx.
References fLibName, fLibrary, fTempName, full_path(), and anonymous_namespace{DynamicLibrary.cxx}::incremental_id().
DynamicLibrary::~DynamicLibrary | ( | ) |
Destructs the shared object library.
Closes the shared object library. All symbols from the shared object library become invalid. The caller is responsible for keeping the DynamicLibrary alive, while symbols from the library are in use.
Definition at line 56 of file DynamicLibrary.cxx.
DynamicLibrary::DynamicLibrary | ( | DynamicLibrary && | other | ) |
|
delete |
void * DynamicLibrary::GetSymbol | ( | const char * | symbol | ) |
Extracts a symbol from the shared library.
Definition at line 84 of file DynamicLibrary.cxx.
References dlsym, and fLibrary.
Referenced by TGRSIOptions::FileAutoDetect().
DynamicLibrary & DynamicLibrary::operator= | ( | DynamicLibrary && | other | ) |
|
delete |
|
private |
Definition at line 77 of file DynamicLibrary.cxx.
References fLibName, fLibrary, and fTempName.
Referenced by DynamicLibrary(), and operator=().
|
private |
Definition at line 61 of file DynamicLibrary.h.
Referenced by DynamicLibrary(), and swap().
|
private |
Definition at line 60 of file DynamicLibrary.h.
Referenced by DynamicLibrary(), GetSymbol(), swap(), and ~DynamicLibrary().
|
private |
Definition at line 62 of file DynamicLibrary.h.
Referenced by DynamicLibrary(), swap(), and ~DynamicLibrary().