CppUnit project page | FAQ

Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
DynamicLibraryManager Class Reference

Manages dynamic libraries. More...

`#include <DynamicLibraryManager.h>`

## Public Types
typedef void * | Symbol
typedef void * | LibraryHandle

## Public Member Functions
| DynamicLibraryManager (const std::string &libraryFileName)
| Loads the specified library.
| ~DynamicLibraryManager ()
| Releases the loaded library..
Symbol | findSymbol (const std::string &symbol)
| Returns a pointer on the specified symbol exported by the library.

## Private Member Functions
void | loadLibrary (const std::string &libraryName)
void | releaseLibrary ()
LibraryHandle | doLoadLibrary (const std::string &libraryName)
void | doReleaseLibrary ()
Symbol | doFindSymbol (const std::string &symbol)
std::string | getLastErrorDetail () const
| DynamicLibraryManager (const DynamicLibraryManager &copy)
| Prevents the use of the copy constructor.
void | operator= (const DynamicLibraryManager &copy)
| Prevents the use of the copy operator.

## Private Attributes
LibraryHandle | m_libraryHandle
std::string | m_libraryName

## Detailed Description

Manages dynamic libraries.

The Dynamic Library Manager provides a platform independent way to work with dynamic library. It load a specific dynamic library, and can returns specific symbol exported by the dynamic library.

If an error occurs, a DynamicLibraryManagerException is thrown.

## Member Typedef Documentation

## ◆ LibraryHandle

typedef void* DynamicLibraryManager::LibraryHandle

## ◆ Symbol

typedef void* DynamicLibraryManager::Symbol

## Constructor & Destructor Documentation

## ◆ DynamicLibraryManager() [1/2]

CPPUNIT_NS_BEGIN DynamicLibraryManager::DynamicLibraryManager | ( | const std::string & | libraryFileName | ) |

Loads the specified library.

Parameters

  libraryFileName | Name of the library to load.

Exceptions

  DynamicLibraryManagerException | if a failure occurs while loading the library (fail to found or load the library).

## ◆ ~DynamicLibraryManager()

DynamicLibraryManager::~DynamicLibraryManager | ( |  | ) |

Releases the loaded library..

## ◆ DynamicLibraryManager() [2/2]

DynamicLibraryManager::DynamicLibraryManager | ( | const DynamicLibraryManager & | copy | ) |
| private

Prevents the use of the copy constructor.

## Member Function Documentation

## ◆ doFindSymbol()

Symbol DynamicLibraryManager::doFindSymbol | ( | const std::string & | symbol | ) |
| private

Returns a pointer on the specified symbol exported by the library.

May throw any exceptions (indicates failure).

Parameters

  symbol | Name of the symbol exported by the library.

Returns
  Pointer on the symbol. `NULL` indicates failure.

## ◆ doLoadLibrary()

LibraryHandle DynamicLibraryManager::doLoadLibrary | ( | const std::string & | libraryName | ) |
| private

Loads the specified library.

May throw any exceptions (indicates failure).

Parameters

  libraryName | Name of the library to load.

Returns
  Handle of the loaded library. `NULL` indicates failure.

## ◆ doReleaseLibrary()

void DynamicLibraryManager::doReleaseLibrary | ( |  | ) |
| private

Releases the loaded library.

The handle of the library to free is in `m_libraryHandle`. It is never `NULL`.

Warning
  Must NOT throw any exceptions (called from destructor).

## ◆ findSymbol()

DynamicLibraryManager::Symbol DynamicLibraryManager::findSymbol | ( | const std::string & | symbol | ) |

Returns a pointer on the specified symbol exported by the library.

Parameters

  symbol | Name of the symbol exported by the library.

Returns
  Pointer on the symbol. Should be casted to the actual type. Never `NULL`.

Exceptions

  DynamicLibraryManagerException | if the symbol is not found.

## ◆ getLastErrorDetail()

std::string DynamicLibraryManager::getLastErrorDetail | ( |  | ) | const
| private

Returns detailed information about doLoadLibrary() failure.

Called just after a failed call to doLoadLibrary() to get extra error information.

Returns
  Detailed information about the failure of the call to doLoadLibrary() that just failed.

## ◆ loadLibrary()

void DynamicLibraryManager::loadLibrary | ( | const std::string & | libraryName | ) |
| private

Loads the specified library.

Parameters

  libraryName | Name of the library to load.

Exceptions

  DynamicLibraryManagerException | if a failure occurs while loading the library (fail to found or load the library).

## ◆ operator=()

void DynamicLibraryManager::operator= | ( | const DynamicLibraryManager & | copy | ) |
| private

Prevents the use of the copy operator.

## ◆ releaseLibrary()

void DynamicLibraryManager::releaseLibrary | ( |  | ) |
| private

Releases the loaded library.

Warning
  Must NOT throw any exceptions (called from destructor).

## Member Data Documentation

## ◆ m_libraryHandle

LibraryHandle DynamicLibraryManager::m_libraryHandle
| private

## ◆ m_libraryName

std::string DynamicLibraryManager::m_libraryName
| private

The documentation for this class was generated from the following files:

- DynamicLibraryManager.h
- DynamicLibraryManager.cpp

| Send comments to: CppUnit Developers