A class for handling shared libraries (DLLs, SO, DyLibs).
More...
#include <Library.h>
|
void * | getAddress (const std::string &symbol) const throw (Exception) |
| It returns the address where the given symbol is loaded into memory. More...
|
|
const std::string & | getFileName () const throw () |
| It returns the library file name as informed in the constructor. More...
|
|
bool | isLoaded () const throw () |
| It returns true if the shared library is loaded otherwise return false. More...
|
|
| Library (const std::string &fileName, bool delayLoad=false) throw (Exception) |
| Loads a new library specified by the file name. More...
|
|
void | load () throw (Exception) |
| It loads the shared library to memory. More...
|
|
void | unload () throw (Exception) |
| It forces the unload of the shared library from memory. More...
|
|
| ~Library () |
| The destructor will automatically unload the library from memory. More...
|
|
|
static void | addSearchDir (const std::string &d) throw (Exception) |
| It adds the informed dir to the path used by the operational system to lookup for shared libraries. More...
|
|
static std::string | getNativeName (const std::string &name) throw () |
| Given a library name without file extensions, prefixes and nor suffixes it will construct a library name according to the specifc platform. More...
|
|
static std::string | getSearchPath () throw (Exception) |
| It returns the system lookup path. More...
|
|
static void | resetSearchPath () throw (Exception) |
| It comes back the application lookupo path to the original state, before any addPath has been called. More...
|
|
A class for handling shared libraries (DLLs, SO, DyLibs).
- Note
- If the library you are trying to load has dependencies on other shared libraries then these are automatically loaded by the underlying operational system. The dependencies must be in a folder where the system can search for these dependencies.
-
This class is based on pimpl idiom.
Definition at line 58 of file Library.h.
te::common::Library::Library |
( |
const std::string & |
fileName, |
|
|
bool |
delayLoad = false |
|
) |
| |
throw | ( | Exception |
| ) | | |
Loads a new library specified by the file name.
File name may be a relative or absolute path. If just the name of the library is given the class will look for the library in the operational system specific locations.
- Parameters
-
fileName | The library file name. The file name may contain the full library path. |
delayLoad | If true the client object must call explicitly the load method before trying to access any symbol in the library. |
- Exceptions
-
Exception | It throws an exception if delayLoad is true and the library can not be loaded. |
te::common::Library::~Library |
( |
| ) |
|
The destructor will automatically unload the library from memory.
static void te::common::Library::addSearchDir |
( |
const std::string & |
d | ) |
|
throw | ( | Exception |
| ) | | |
|
static |
It adds the informed dir to the path used by the operational system to lookup for shared libraries.
- Parameters
-
d | A directory to be added to the lookup of shared libraries. |
- Exceptions
-
Exception | It throws an exception if the path couldn't be added to the search path. |
- Note
- Not thread-safe.
void* te::common::Library::getAddress |
( |
const std::string & |
symbol | ) |
const |
throw | ( | Exception |
| ) | | |
It returns the address where the given symbol is loaded into memory.
- Parameters
-
symbol | The name of the symbol inside the library you are searching for. It may be for instance a function name. |
- Returns
- The address where the symbol is loaded.
- Exceptions
-
Exception | It throws an exception if it is not possible to locate the given symbol. |
- Note
- Thread-safe.
const std::string& te::common::Library::getFileName |
( |
| ) |
const |
throw | ( | |
| ) | | |
It returns the library file name as informed in the constructor.
- Returns
- The library file name as informed in the constructor.
- Note
- Thread-safe.
static std::string te::common::Library::getNativeName |
( |
const std::string & |
name | ) |
|
throw | ( | |
| ) | | |
|
static |
Given a library name without file extensions, prefixes and nor suffixes it will construct a library name according to the specifc platform.
- Returns
- The library file name according to the specifc platform.
- Note
- Thread-safe.
static std::string te::common::Library::getSearchPath |
( |
| ) |
|
throw | ( | Exception |
| ) | | |
|
static |
It returns the system lookup path.
- Returns
- The system lookup path.
- Exceptions
-
Exception | It throws an exception if the search path couldn't be reset. |
- Note
- Thread-safe.
bool te::common::Library::isLoaded |
( |
| ) |
const |
throw | ( | |
| ) | | |
It returns true if the shared library is loaded otherwise return false.
- Returns
- True if the shared library is loaded otherwise returns false.
- Note
- Thread-safe.
void te::common::Library::load |
( |
| ) |
|
throw | ( | Exception |
| ) | | |
It loads the shared library to memory.
If the library was already loaded this method doesn't perform operations.
- Exceptions
-
Exception | If the library can not be load to memory this method raises an exception. |
- Note
- Not thread-safe.
static void te::common::Library::resetSearchPath |
( |
| ) |
|
throw | ( | Exception |
| ) | | |
|
static |
It comes back the application lookupo path to the original state, before any addPath has been called.
- Exceptions
-
Exception | It throws an exception if the search path couldn't be reset. |
- Note
- Not thread-safe.
void te::common::Library::unload |
( |
| ) |
|
throw | ( | Exception |
| ) | | |
It forces the unload of the shared library from memory.
If the library wasn't previously loaded or if it was already unloaded this method doesn't perform operations.
- Exceptions
-
Exception | If the library can not be unload from memory this method raises an exception. |
- Note
- Not thread-safe.
Impl* te::common::Library::m_pImpl |
|
private |
A pointer to the real implementation.
Definition at line 179 of file Library.h.
The documentation for this class was generated from the following file:
- /home/castejon/castejon_files/develop/terralib5/git_master/terralib5/src/terralib/common/Library.h