GRSISort "v4.0.0.5"
An extension of the ROOT analysis Framework
Loading...
Searching...
No Matches
DynamicLibrary Class Reference

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.

Definition at line 13 of file DynamicLibrary.h.

Public Member Functions

 DynamicLibrary (const DynamicLibrary &)=delete
 
 DynamicLibrary (DynamicLibrary &&other) noexcept
 
 DynamicLibrary (std::string libname_param, bool unique_name=false)
 
 ~DynamicLibrary ()
 
void * GetSymbol (const char *symbol)
 
DynamicLibraryoperator= (const DynamicLibrary &)=delete
 
DynamicLibraryoperator= (DynamicLibrary &&other) noexcept
 

Private Member Functions

void swap (DynamicLibrary &other)
 

Private Attributes

std::string fLibName
 
void * fLibrary
 
std::string fTempName
 
+ Collaboration diagram for DynamicLibrary:

Constructor & Destructor Documentation

◆ DynamicLibrary() [1/3]

DynamicLibrary::DynamicLibrary ( std::string libname_param,
bool unique_name = false )
explicit

Loads a shared object library.

Parameters
libname_paramPath 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.

Definition at line 27 of file DynamicLibrary.cxx.

References fLibName, fLibrary, fTempName, and full_path().

◆ ~DynamicLibrary()

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.

Definition at line 54 of file DynamicLibrary.cxx.

References fLibrary, and fTempName.

◆ DynamicLibrary() [2/3]

DynamicLibrary::DynamicLibrary ( DynamicLibrary && other)
noexcept

Move constructor.

Definition at line 64 of file DynamicLibrary.cxx.

◆ DynamicLibrary() [3/3]

DynamicLibrary::DynamicLibrary ( const DynamicLibrary & )
delete

Member Function Documentation

◆ GetSymbol()

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

Extracts a symbol from the shared library.

Definition at line 82 of file DynamicLibrary.cxx.

References dlsym, and fLibrary.

Referenced by TGRSIOptions::FileAutoDetect().

◆ operator=() [1/2]

DynamicLibrary & DynamicLibrary::operator= ( const DynamicLibrary & )
delete

◆ operator=() [2/2]

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

Move assignment operator.

Definition at line 69 of file DynamicLibrary.cxx.

◆ swap()

void DynamicLibrary::swap ( DynamicLibrary & other)
private

Definition at line 75 of file DynamicLibrary.cxx.

References fLibName, fLibrary, and fTempName.

Member Data Documentation

◆ fLibName

std::string DynamicLibrary::fLibName
private

Definition at line 61 of file DynamicLibrary.h.

Referenced by DynamicLibrary(), and swap().

◆ fLibrary

void* DynamicLibrary::fLibrary
private

Definition at line 60 of file DynamicLibrary.h.

Referenced by DynamicLibrary(), ~DynamicLibrary(), GetSymbol(), and swap().

◆ fTempName

std::string DynamicLibrary::fTempName
private

Definition at line 62 of file DynamicLibrary.h.

Referenced by DynamicLibrary(), ~DynamicLibrary(), and swap().