GRUTinizer
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
DynamicLibrary Class Reference

Loads a Shared Object library. More...

#include <DynamicLibrary.h>

Public Member Functions

 DynamicLibrary (std::string libname, bool unique_name=false)
 Loads a shared object library.
 ~DynamicLibrary ()
 Destructs the shared object library.
 DynamicLibrary (DynamicLibrary &&other)
 Moves constructor.
DynamicLibraryoperator= (DynamicLibrary &&other)
 Move assignment operator.
 DynamicLibrary (const DynamicLibrary &)
DynamicLibraryoperator= (const DynamicLibrary &)
void * GetSymbol (const char *symbol)
 Extracts a symbol from the shared library.

Private Member Functions

void swap (DynamicLibrary &other)

Private Attributes

void * library

Detailed Description

Loads a Shared Object library.

The be moved, but not copied. When the object is destroyed, the library is closed. The caller is responsible for keeping the object alive while symbols from the object are being used.

Constructor & Destructor Documentation

DynamicLibrary::DynamicLibrary ( std::string  libname,
bool  unique_name = false 
)

Loads a shared object library.

Parameters
libnamePath to the library to be loaded.
unique_nameGenerates a uniquely named symlink to the file, which is then opened.

dlopen/dlclose maintains a reference count, caching shared objects in case a library is loaded multiple times. However, if a library is going to change as the program runs, then this caching works against us. In this case, "unique_name" should be set to true.

DynamicLibrary::~DynamicLibrary ( )

Destructs the shared object library.

Closes the shared object library. All symbols from the shared object library become invalid. The caller is responsible for keeping the DynamicLibrary alive, while symbols from the library are in use.

DynamicLibrary::DynamicLibrary ( DynamicLibrary &&  other)

Moves constructor.

DynamicLibrary::DynamicLibrary ( const DynamicLibrary )

Member Function Documentation

void * DynamicLibrary::GetSymbol ( const char *  symbol)

Extracts a symbol from the shared library.

DynamicLibrary & DynamicLibrary::operator= ( DynamicLibrary &&  other)

Move assignment operator.

DynamicLibrary& DynamicLibrary::operator= ( const DynamicLibrary )
void DynamicLibrary::swap ( DynamicLibrary other)
private

Member Data Documentation

void* DynamicLibrary::library
private

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