GRSISort
Created by P.C. Bender
Developement Team: P.C. Bender, R. Dunlop, V. Bildstein
An extension of the ROOT analysis Framework
DynamicLibrary Class Reference

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 (std::string libname_param, bool unique_name=false)
 
 DynamicLibrary (DynamicLibrary &&other)
 
 DynamicLibrary (const DynamicLibrary &)=delete
 
 ~DynamicLibrary ()
 
void * GetSymbol (const char *symbol)
 
DynamicLibraryoperator= (DynamicLibrary &&other)
 
DynamicLibraryoperator= (const DynamicLibrary &)=delete
 

Private Member Functions

void swap (DynamicLibrary &other)
 

Private Attributes

std::string fLibName
 
void * fLibrary
 
std::string fTempName
 

#include <DynamicLibrary.h>

+ Collaboration diagram for DynamicLibrary:

Constructor & Destructor Documentation

◆ DynamicLibrary() [1/3]

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

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 29 of file DynamicLibrary.cxx.

References fLibName, fLibrary, fTempName, full_path(), and anonymous_namespace{DynamicLibrary.cxx}::incremental_id().

◆ ~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 56 of file DynamicLibrary.cxx.

References fLibrary, and fTempName.

◆ DynamicLibrary() [2/3]

DynamicLibrary::DynamicLibrary ( DynamicLibrary &&  other)

Moves constructor.

Definition at line 66 of file DynamicLibrary.cxx.

References swap().

◆ 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 84 of file DynamicLibrary.cxx.

References dlsym, and fLibrary.

Referenced by TGRSIOptions::FileAutoDetect().

◆ operator=() [1/2]

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

Move assignment operator.

Definition at line 71 of file DynamicLibrary.cxx.

References swap().

◆ operator=() [2/2]

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

◆ swap()

void DynamicLibrary::swap ( DynamicLibrary other)
private

Definition at line 77 of file DynamicLibrary.cxx.

References fLibName, fLibrary, and fTempName.

Referenced by DynamicLibrary(), and operator=().

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(), GetSymbol(), swap(), and ~DynamicLibrary().

◆ fTempName

std::string DynamicLibrary::fTempName
private

Definition at line 62 of file DynamicLibrary.h.

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