Mantid
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
Mantid::Kernel::LibraryManagerImpl Class Reference

Class for opening shared libraries. More...

#include <LibraryManager.h>

Public Types

enum  LoadLibraries { Recursive , NonRecursive }
 

Public Member Functions

 LibraryManagerImpl (const LibraryManagerImpl &)=delete
 
int openLibraries (const std::string &libpath, LoadLibraries loadingBehaviour, const std::vector< std::string > &excludes)
 Opens suitable DLLs on a given path. More...
 
LibraryManagerImploperator= (const LibraryManagerImpl &)=delete
 

Private Member Functions

bool isExcluded (const std::string &filename, const std::vector< std::string > &excludes) const
 Returns true if the library has been requested to be excluded. More...
 
bool isLoaded (const std::string &filename) const
 Check if the library has already been loaded. More...
 
 LibraryManagerImpl ()
 Private Constructor. More...
 
int openLibraries (const Poco::File &libpath, LoadLibraries loadingBehaviour, const std::vector< std::string > &excludes)
 Load libraries from the given Poco::File path Private so Poco::File doesn't leak to the public interface. More...
 
int openLibrary (const Poco::File &filepath, const std::string &cacheKey)
 Load a given library. More...
 
bool shouldBeLoaded (const std::string &filename, const std::vector< std::string > &excludes) const
 Check if the library should be loaded. More...
 
 ~LibraryManagerImpl ()=default
 Private Destructor. More...
 

Private Attributes

std::unordered_map< std::string, LibraryWrapperm_openedLibs
 Storage for the LibraryWrappers. More...
 

Friends

struct Mantid::Kernel::CreateUsingNew< LibraryManagerImpl >
 

Detailed Description

Class for opening shared libraries.

Author
ISIS, STFC
Date
15/10/2007

Definition at line 33 of file LibraryManager.h.

Member Enumeration Documentation

◆ LoadLibraries

Enumerator
Recursive 
NonRecursive 

Definition at line 35 of file LibraryManager.h.

Constructor & Destructor Documentation

◆ LibraryManagerImpl() [1/2]

Mantid::Kernel::LibraryManagerImpl::LibraryManagerImpl ( const LibraryManagerImpl )
delete

◆ LibraryManagerImpl() [2/2]

Mantid::Kernel::LibraryManagerImpl::LibraryManagerImpl ( )
private

Private Constructor.

Constructor.

Definition at line 25 of file LibraryManager.cpp.

References Mantid::Kernel::Logger::debug(), and Mantid::Kernel::DateAndTimeHelpers::g_log.

◆ ~LibraryManagerImpl()

Mantid::Kernel::LibraryManagerImpl::~LibraryManagerImpl ( )
privatedefault

Private Destructor.

Member Function Documentation

◆ isExcluded()

bool Mantid::Kernel::LibraryManagerImpl::isExcluded ( const std::string &  filename,
const std::vector< std::string > &  excludes 
) const
private

Returns true if the library has been requested to be excluded.

Returns true if the name contains one of the strings given in the exclude list.

Each string from the variable is searched for with the filename so an exact match is not necessary. This avoids having to specify prefixes and suffixes for different platforms, i.e. 'plugins.exclude = MantidKernel' will exclude libMantidKernel.so

Parameters
filenameThe filename of the library (no directory)
excludesA list of substrings to exclude library from loading
Returns
True if the library should be skipped

Definition at line 118 of file LibraryManager.cpp.

Referenced by shouldBeLoaded().

◆ isLoaded()

bool Mantid::Kernel::LibraryManagerImpl::isLoaded ( const std::string &  filename) const
private

Check if the library has already been loaded.

Check if the library been loaded already?

Parameters
filenameThe filename of the library, i.e no directory
Returns
True if the library has been seen before

Definition at line 104 of file LibraryManager.cpp.

References m_openedLibs.

Referenced by shouldBeLoaded().

◆ openLibraries() [1/2]

int Mantid::Kernel::LibraryManagerImpl::openLibraries ( const Poco::File &  libpath,
LibraryManagerImpl::LoadLibraries  loadingBehaviour,
const std::vector< std::string > &  excludes 
)
private

Load libraries from the given Poco::File path Private so Poco::File doesn't leak to the public interface.

Opens suitable DLLs on a given path.

Parameters
libpathA Poco::File object pointing to a directory where the libraries are.
loadingBehaviourControl how libraries are searched for
excludesIf not empty then each string is considered as a substring to search within each library to be opened. If the substring is found then the library is not opened.
Returns
The number of libraries opened.

Definition at line 63 of file LibraryManager.cpp.

References Mantid::Kernel::Logger::error(), Mantid::Kernel::DateAndTimeHelpers::g_log, openLibraries(), openLibrary(), Recursive, and shouldBeLoaded().

◆ openLibraries() [2/2]

int Mantid::Kernel::LibraryManagerImpl::openLibraries ( const std::string &  filepath,
LoadLibraries  loadingBehaviour,
const std::vector< std::string > &  excludes 
)

Opens suitable DLLs on a given path.

Parameters
filepathThe filepath to the directory where the libraries are.
loadingBehaviourControl how libraries are searched for
excludesIf not empty then each string is considered as a substring to search within each library to be opened. If the substring is found then the library is not opened.
Returns
The number of libraries opened.

Definition at line 36 of file LibraryManager.cpp.

References Mantid::Kernel::Logger::debug(), Mantid::Kernel::Logger::error(), Mantid::Kernel::DateAndTimeHelpers::g_log, and openLibraries().

Referenced by openLibraries().

◆ openLibrary()

int Mantid::Kernel::LibraryManagerImpl::openLibrary ( const Poco::File &  filepath,
const std::string &  cacheKey 
)
private

Load a given library.

Load a library.

Parameters
filepath:: A Poco::File The full path to a library as a string
cacheKey:: An identifier for the cache if loading is successful
Returns
1 if the file loaded successfully, 0 otherwise

Definition at line 133 of file LibraryManager.cpp.

References Mantid::Kernel::Logger::debug(), Mantid::Kernel::DateAndTimeHelpers::g_log, Mantid::Kernel::Logger::is(), m_openedLibs, and Mantid::Kernel::LibraryWrapper::openLibrary().

Referenced by openLibraries().

◆ operator=()

LibraryManagerImpl & Mantid::Kernel::LibraryManagerImpl::operator= ( const LibraryManagerImpl )
delete

◆ shouldBeLoaded()

bool Mantid::Kernel::LibraryManagerImpl::shouldBeLoaded ( const std::string &  filename,
const std::vector< std::string > &  excludes 
) const
private

Check if the library should be loaded.

Parameters
filenameThe filename of the library, i.e no directory
excludesIf not empty then each string is considered as a substring to search within each library to be opened. If the substring is found then the library is not opened.
Returns
True if loading should be attempted

Definition at line 95 of file LibraryManager.cpp.

References isExcluded(), isLoaded(), and Mantid::Kernel::DllOpen::isValidFilename().

Referenced by openLibraries().

Friends And Related Function Documentation

◆ Mantid::Kernel::CreateUsingNew< LibraryManagerImpl >

Definition at line 39 of file LibraryManager.h.

Member Data Documentation

◆ m_openedLibs

std::unordered_map<std::string, LibraryWrapper> Mantid::Kernel::LibraryManagerImpl::m_openedLibs
private

Storage for the LibraryWrappers.

Definition at line 63 of file LibraryManager.h.

Referenced by isLoaded(), and openLibrary().


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