OpenWalnut  1.5.0dev
Classes | Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
WModuleLoader Class Reference

Loads module prototypes from shared objects in a given directory and injects it into the module factory. More...

#include <WModuleLoader.h>

+ Collaboration diagram for WModuleLoader:

Classes

struct  PostponedLoad
 Helper to store information on a lib which gets initialized later. More...
 

Public Types

typedef std::shared_ptr< WModuleLoaderSPtr
 Shared pointer abbreviation. More...
 
typedef std::shared_ptr< const WModuleLoaderConstSPtr
 Const pointer abbreviation. More...
 

Public Member Functions

 WModuleLoader ()
 Constructor. More...
 
 ~WModuleLoader ()
 Destructor, closes all handles to shared libraries. More...
 
void load (WSharedAssociativeContainer< std::set< std::shared_ptr< WModule > > >::WriteTicket ticket)
 Load the module prototypes from the shared libraries. More...
 
void initializeExtensions ()
 The loader also stores information on which library provides the arbitrary registration mechanism. More...
 

Static Public Member Functions

static std::string getModulePrefix ()
 Returns the prefix of a shared module library filename. More...
 

Private Member Functions

void load (WSharedAssociativeContainer< std::set< std::shared_ptr< WModule > > >::WriteTicket ticket, boost::filesystem::path dir, unsigned int level=0)
 Load the module prototypes from the shared libraries from the specified directory. More...
 

Private Attributes

std::vector< std::shared_ptr< WSharedLib > > m_libs
 All the loaded shared libraries. More...
 
std::vector< PostponedLoadm_arbitraryRegisterLibs
 The libs which need to be initialized when OW is loaded completely. More...
 

Detailed Description

Loads module prototypes from shared objects in a given directory and injects it into the module factory.

Definition at line 42 of file WModuleLoader.h.

Member Typedef Documentation

◆ ConstSPtr

typedef std::shared_ptr< const WModuleLoader > WModuleLoader::ConstSPtr

Const pointer abbreviation.

Definition at line 53 of file WModuleLoader.h.

◆ SPtr

typedef std::shared_ptr< WModuleLoader > WModuleLoader::SPtr

Shared pointer abbreviation.

Definition at line 48 of file WModuleLoader.h.

Constructor & Destructor Documentation

◆ WModuleLoader()

WModuleLoader::WModuleLoader ( )
explicit

Constructor.

It does not load any files. Use load to do this.

Definition at line 37 of file WModuleLoader.cpp.

◆ ~WModuleLoader()

WModuleLoader::~WModuleLoader ( )

Destructor, closes all handles to shared libraries.

Definition at line 42 of file WModuleLoader.cpp.

References m_libs.

Member Function Documentation

◆ getModulePrefix()

std::string WModuleLoader::getModulePrefix ( )
static

Returns the prefix of a shared module library filename.

Returns
the prefix.

Definition at line 200 of file WModuleLoader.cpp.

References WSharedLib::getSystemPrefix().

Referenced by load().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initializeExtensions()

void WModuleLoader::initializeExtensions ( )

The loader also stores information on which library provides the arbitrary registration mechanism.

This cannot be called during load, as OW is not completely initialized at this point. So we do this here. Call this after startup, before project loading.

Definition at line 188 of file WModuleLoader.cpp.

References wlog::debug(), and m_arbitraryRegisterLibs.

+ Here is the call graph for this function:

◆ load() [1/2]

void WModuleLoader::load ( WSharedAssociativeContainer< std::set< std::shared_ptr< WModule > > >::WriteTicket  ticket)

Load the module prototypes from the shared libraries.

Parameters
ticketA write ticket to a shared container.

Definition at line 164 of file WModuleLoader.cpp.

References WLogger::addLogMessage(), WPathHelper::getAllModulePaths(), and WLogger::getLogger().

Referenced by load().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ load() [2/2]

void WModuleLoader::load ( WSharedAssociativeContainer< std::set< std::shared_ptr< WModule > > >::WriteTicket  ticket,
boost::filesystem::path  dir,
unsigned int  level = 0 
)
private

Load the module prototypes from the shared libraries from the specified directory.

It traverses the subdirectories and searches there. Traversion depth is 1.

Parameters
ticketA write ticket to a shared container.
dirthe directory to load
levelthe traversion level

Definition at line 48 of file WModuleLoader.cpp.

References WLogger::addLogMessage(), wlog::debug(), WLogger::getLogger(), getModulePrefix(), WPathHelper::getModuleResourcePath(), WSharedLib::getSystemSuffix(), load(), m_arbitraryRegisterLibs, m_libs, wlog::warn(), and WException::what().

+ Here is the call graph for this function:

Member Data Documentation

◆ m_arbitraryRegisterLibs

std::vector< PostponedLoad > WModuleLoader::m_arbitraryRegisterLibs
private

The libs which need to be initialized when OW is loaded completely.

Definition at line 134 of file WModuleLoader.h.

Referenced by initializeExtensions(), and load().

◆ m_libs

std::vector< std::shared_ptr< WSharedLib > > WModuleLoader::m_libs
private

All the loaded shared libraries.

Get freed on destruction. So do NOT free this instance while the libs are used.

Definition at line 90 of file WModuleLoader.h.

Referenced by load(), and ~WModuleLoader().


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