Belle II Software development
DynamicLoader Class Reference

Public Member Functions

 DynamicLoader (const std::string &path)
 
void * open (const std::string &lib_path)
 
void * load (const std::string &func_name)
 
void close ()
 

Private Attributes

void * m_handle
 

Detailed Description

Definition at line 19 of file DynamicLoader.h.

Constructor & Destructor Documentation

◆ DynamicLoader() [1/2]

DynamicLoader ( )
inline

Definition at line 22 of file DynamicLoader.h.

22{}

◆ DynamicLoader() [2/2]

DynamicLoader ( const std::string &  path)
inline

Definition at line 23 of file DynamicLoader.h.

24 {
25 open(path);
26 }

◆ ~DynamicLoader()

Definition at line 15 of file DynamicLoader.cc.

16{
17}

Member Function Documentation

◆ close()

void close ( )

Definition at line 19 of file DynamicLoader.cc.

20{
21 if (m_handle != NULL) {
22 dlclose(m_handle);
23 m_handle = NULL;
24 }
25}

◆ load()

void * load ( const std::string &  func_name)

Definition at line 37 of file DynamicLoader.cc.

38{
39 char* error = NULL;
40 void* func = dlsym(m_handle, funcname.c_str());
41 if ((error = dlerror()) != NULL) {
42 throw (DynamicLoadException("dlopen: %s", error));
43 }
44 return func;
45}

◆ open()

void * open ( const std::string &  lib_path)

Definition at line 27 of file DynamicLoader.cc.

28{
29 void* handle = dlopen(lib_path.c_str(), RTLD_LAZY);
30 if (!handle) {
31 throw (DynamicLoadException("dlopen: %s", dlerror()));
32 }
33 m_handle = handle;
34 return handle;
35}

Member Data Documentation

◆ m_handle

void* m_handle
private

Definition at line 35 of file DynamicLoader.h.


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