#include <SealSharedLib.h>
Classes | |
struct | LibraryInfo |
Public Types | |
typedef void * | Data |
typedef void(* | Function )(void) |
typedef Callback1< const LibraryInfo & > | InfoHandler |
Public Member Functions | |
void | release (void) |
void | abandon (void) |
Data | data (const std::string &name, bool mangle=true) const |
Function | function (const std::string &name, bool mangle=true) const |
Static Public Member Functions | |
static std::string | path (void) |
static void | path (const std::string &path) |
static std::string | libname (const std::string &name) |
static std::string | symname (const std::string &name) |
static SharedLibrary * | self (void) |
static SharedLibrary * | load (const std::string &name) |
static void | loaded (const InfoHandler &handler) |
Protected Member Functions | |
SharedLibrary (void *handle) | |
~SharedLibrary (void) |
Shared library services.
Athena::SharedLibrary::SharedLibrary | ( | void * | handle | ) | [protected] |
Athena::SharedLibrary::~SharedLibrary | ( | void | ) | [protected] |
Protected destructor for cleaning up a library object. The real destruction happens in release() or abadon().
void Athena::SharedLibrary::abandon | ( | void | ) |
Abandon a library. This simply destroys the shared library object (this
) without releasing the underlying dynamic object.
SharedLibrary::Data Athena::SharedLibrary::data | ( | const std::string & | name, | |
bool | mangle = true | |||
) | const |
Locate and return a reference to a data symbol called name. If no such symbol exists, returns a null pointer. If mangle is the default true
, the symbol is mangled to the platform convention, typically prepending an underscore if required. The mangling does not refer to C++ name mangling, but to the mangling required to convert C identifiers to run-time symbol names; see symname() for details.
SharedLibrary::Function Athena::SharedLibrary::function | ( | const std::string & | name, | |
bool | mangle = true | |||
) | const |
Locate and return a reference to a function symbol called name. If no such symbol exists, returns a null pointer. If mangle is the default true
, the symbol is mangled to the platform convention, typically prepending an underscore if required. The mangling does not refer to C++ name mangling, but to the mangling required to convert C identifiers to run-time symbol names; see symname() for details.
std::string Athena::SharedLibrary::libname | ( | const std::string & | name | ) | [static] |
Return a shared library name that follows the system conventions for naming shared library. name is the basic name of the shared library, without the name prefix ("lib" on unix) or the extension (".so", ".sl", ".dylib" or ".dll"). name must not have any directory components.
SharedLibrary * Athena::SharedLibrary::load | ( | const std::string & | name | ) | [static] |
Load a shared library and return an object representing it. The returned object is allocated with new
. The caller must release the object with either release() or abandon(). The method throws a SharedLibraryError if the operation is not supported or some failure occurs. Please note that on several systems failure to properly load a library, e.g. due to missing symbols, is effectively fatal.
void Athena::SharedLibrary::loaded | ( | const InfoHandler & | handler | ) | [static] |
Iterate and provide information about all currently loaded shared libraries.
void Athena::SharedLibrary::release | ( | void | ) |
Release a shared library. This unloads any library the object currently refers to, then deletes this
. Note that releasing the library does not guarantee that it will actually be unloaded. If there are outstanding references to the library, explicit or implicit, the library will remain in memory.
SharedLibrary * Athena::SharedLibrary::self | ( | void | ) | [static] |
std::string Athena::SharedLibrary::symname | ( | const std::string & | name | ) | [static] |
Transform 'extern "C"' symbol name into a name suitable for lookup in a shared library, e.g. with data() or function(). Normally the latter two automatically perform the necessary mangling by calling this function, but the clients can also do the mangling themselves. The name should be in the form it is spelled in C source code.