GSLAM  3.0.0
Public Types | Public Member Functions | Static Public Member Functions | List of all members
SharedLibrary Class Reference

The SharedLibrary class dynamically loads shared libraries at run-time. More...

Public Types

typedef std::mutex MutexRW
 
typedef std::unique_lock< std::mutex > WriteMutex
 

Public Member Functions

 SharedLibrary (const std::string &path)
 Creates a SharedLibrary object.
 
virtual ~SharedLibrary ()
 Creates a SharedLibrary object and loads a library from the given path.
 
bool load (const std::string &path, int flags=0)
 Destroys the SharedLibrary. The actual library remains loaded.
 
void unload ()
 Loads a shared library from the given path. Throws a LibraryAlreadyLoadedException if a library has already been loaded. Throws a LibraryLoadException if the library cannot be loaded.
 
bool isLoaded () const
 Unloads a shared library.
 
bool hasSymbol (const std::string &name)
 Returns true iff a library has been loaded.
 
void * getSymbol (const std::string &name)
 Returns true iff the loaded library contains a symbol with the given name.
 
const std::string & getPath () const
 Returns the address of the symbol with the given name. For functions, this is the entry point of the function. Throws a NotFoundException if the symbol does not exist.
 

Static Public Member Functions

static std::string suffix ()
 Returns the path of the library, as specified in a call to load() or the constructor.
 

Detailed Description

The SharedLibrary class dynamically loads shared libraries at run-time.