EventAnalysis  1.0.0
Public Member Functions | Private Attributes | List of all members
EA::DynamicLoader Class Reference

Class to dynamically load and manage shared libraries. More...

#include <DynamicLoader.h>

Public Member Functions

 ~DynamicLoader ()
 Destructor. More...
 
template<class T >
bool AddPluginFolders (const T &foldersList)
 Adds plugin folders. More...
 
bool LoadPlugin (const std::string &pluginName)
 Loads a plugin library. More...
 
void AutoLoad (const std::string &autoLoadFolder="")
 Loads all the shared libraries in a given folder. More...
 

Private Attributes

std::vector< std::string > _pluginFolders
 
std::vector< void * > _files
 

Detailed Description

Class to dynamically load and manage shared libraries.

This class dynamically loads shared libraries. It takes care of opening and closing libraries, but does not fetch any symbol. It maintains a list of opened libraries, which are closed when the loader is destroyed.

Constructor & Destructor Documentation

◆ ~DynamicLoader()

EA::DynamicLoader::~DynamicLoader ( )

Destructor.

Closes all the loaded libraries.

Member Function Documentation

◆ AddPluginFolders()

template<class T >
bool EA::DynamicLoader::AddPluginFolders ( const T &  foldersList)

Adds plugin folders.

Adds folders where plugin libraries specified as relative paths will be searched.

Parameters
foldersa container with a list of folders (each folder as a std::string)
Returns
true if the folders have been correctly added to the folders list.

◆ AutoLoad()

void EA::DynamicLoader::AutoLoad ( const std::string &  autoLoadFolder = "")

Loads all the shared libraries in a given folder.

This method loads all the libraries (.so files) in the given folder.

Parameters
autoLoadFolderthe folder containing the libraries to be automatically loaded.

◆ LoadPlugin()

bool EA::DynamicLoader::LoadPlugin ( const std::string &  pluginName)

Loads a plugin library.

This method loads a plugin library using dlopen. No symbol is fetched.

#pluginName identifies the plugin library to be loaded. It can be specified in several ways:

1) /path/to/libPlugin.so

If given as an absolute path then the path is used as is.

2) ../relativePath/to/libPlugin.so or libPlugin.so

If given as a relative path or a simple file name then the file will be searched relatively to the folders specified by calling AddPluginFolders.

3) Plugin

If given as a simple plugin name then the library file name is obtained by prepending "lib" and appending ".so" to the plugin name, and then the search is performed as in 2).

Parameters
pluginNameThe name of the desired plugin (see above for a detailed description of the format).
Returns
true if the library has been loaded, false otherwise.

Member Data Documentation

◆ _files

std::vector<void *> EA::DynamicLoader::_files
private

◆ _pluginFolders

std::vector<std::string> EA::DynamicLoader::_pluginFolders
private

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