Pyrogenesis
13997
|
#include <DllLoader.h>
Public Member Functions | |
DllLoader (const char *name) | |
Prepare the DLL loader. More... | |
~DllLoader () | |
bool | LoadDLL () |
Attempt to load and initialise the library, if not already. More... | |
bool | IsLoaded () const |
Check whether the library has been loaded successfully. More... | |
void | Unload () |
Unload the library, if it has been loaded already. More... | |
template<typename T > | |
void | LoadSymbol (const char *name, T &fptr) const |
Attempt to load a named symbol from the library. More... | |
Static Public Member Functions | |
static void | OverrideLibdir (const char *libdir) |
Override the build-time setting of the directory to search for libraries. More... | |
Private Member Functions | |
void | LoadSymbolInternal (const char *name, void **fptr) const |
Private Attributes | |
const char * | m_Name |
void * | m_Handle |
Definition at line 27 of file DllLoader.h.
DllLoader::DllLoader | ( | const char * | name | ) |
Prepare the DLL loader.
Does no actual work.
name | base name of the library (from which we'll derive "name.dll", "libname_dbg.so", etc). Pointer must remain valid for this object's lifetime (which is fine if you just use a string literal). |
Definition at line 136 of file DllLoader.cpp.
DllLoader::~DllLoader | ( | ) |
Definition at line 141 of file DllLoader.cpp.
bool DllLoader::IsLoaded | ( | ) | const |
Check whether the library has been loaded successfully.
Returns false before LoadDLL has been called; otherwise returns the same as LoadDLL did.
Definition at line 147 of file DllLoader.cpp.
bool DllLoader::LoadDLL | ( | ) |
Attempt to load and initialise the library, if not already.
Can be harmlessly called multiple times. Returns false if unsuccessful.
Definition at line 152 of file DllLoader.cpp.
void DllLoader::LoadSymbol | ( | const char * | name, |
T & | fptr | ||
) | const |
Attempt to load a named symbol from the library.
If IsLoaded is false, throws PSERROR_DllLoader_DllNotLoaded. If it cannot load the symbol, throws PSERROR_DllLoader_SymbolNotFound. In both cases, sets fptr to NULL. Otherwise, fptr is set to point to the loaded function.
PSERROR_DllLoader |
Definition at line 86 of file DllLoader.h.
|
private |
Definition at line 181 of file DllLoader.cpp.
|
static |
Override the build-time setting of the directory to search for libraries.
Definition at line 195 of file DllLoader.cpp.
void DllLoader::Unload | ( | ) |
Unload the library, if it has been loaded already.
(Usually not needed, since the destructor will unload it.)
Definition at line 172 of file DllLoader.cpp.
|
private |
Definition at line 82 of file DllLoader.h.
|
private |
Definition at line 81 of file DllLoader.h.