Classes | Typedefs | Functions
class_loader::impl Namespace Reference

Classes

class  AbstractMetaObject
 Abstract base class for factories where polymorphic type variable indicates base class for plugin interface. B The base class interface for the plugin. More...
 
class  AbstractMetaObjectBase
 A base class for MetaObjects that excludes a polymorphic type parameter. Subclasses are class templates though. More...
 
class  MetaObject
 The actual factory. C The derived class (the actual plugin) B The base class interface for the plugin. More...
 

Typedefs

typedef std::string BaseClassName
 
typedef std::map< BaseClassName, FactoryMapBaseToFactoryMapMap
 
typedef std::vector< class_loader::ClassLoader * > ClassLoaderVector
 
typedef std::string ClassName
 
typedef std::map< ClassName, impl::AbstractMetaObjectBase * > FactoryMap
 
typedef std::pair< LibraryPath, Poco::SharedLibrary * > LibraryPair
 
typedef std::string LibraryPath
 
typedef std::vector< LibraryPairLibraryVector
 
typedef std::vector< AbstractMetaObjectBase * > MetaObjectVector
 

Functions

void addClassLoaderOwnerForAllExistingMetaObjectsForLibrary (const std::string &library_path, ClassLoader *loader)
 
MetaObjectVector allMetaObjects (const FactoryMap &factories)
 
MetaObjectVector allMetaObjects ()
 
MetaObjectVector allMetaObjectsForClassLoader (const ClassLoader *owner)
 
MetaObjectVector allMetaObjectsForLibrary (const std::string &library_path)
 
MetaObjectVector allMetaObjectsForLibraryOwnedBy (const std::string &library_path, const ClassLoader *owner)
 
bool areThereAnyExistingMetaObjectsForLibrary (const std::string &library_path)
 
template<typename Base >
BasecreateInstance (const std::string &derived_class_name, ClassLoader *loader)
 This function creates an instance of a plugin class given the derived name of the class and returns a pointer of the Base class type. More...
 
void destroyMetaObjectsForLibrary (const std::string &library_path, FactoryMap &factories, const ClassLoader *loader)
 
void destroyMetaObjectsForLibrary (const std::string &library_path, const ClassLoader *loader)
 
MetaObjectVector filterAllMetaObjectsAssociatedWithLibrary (const MetaObjectVector &to_filter, const std::string &library_path)
 
MetaObjectVector filterAllMetaObjectsOwnedBy (const MetaObjectVector &to_filter, const ClassLoader *owner)
 
LibraryVector::iterator findLoadedLibrary (const std::string &library_path)
 
CLASS_LOADER_PUBLIC std::vector< std::string > getAllLibrariesUsedByClassLoader (const ClassLoader *loader)
 This function returns the names of all libraries in use by a given class loader. More...
 
template<typename Base >
std::vector< std::string > getAvailableClasses (ClassLoader *loader)
 This function returns all the available class_loader in the plugin system that are derived from Base and within scope of the passed ClassLoader. More...
 
CLASS_LOADER_PUBLIC ClassLoadergetCurrentlyActiveClassLoader ()
 Gets the ClassLoader currently in scope which used when a library is being loaded. More...
 
ClassLoader *& getCurrentlyActiveClassLoaderReference ()
 
CLASS_LOADER_PUBLIC std::string getCurrentlyLoadingLibraryName ()
 When a library is being loaded, in order for factories to know which library they are being associated with, they use this function to query which library is being loaded. More...
 
std::string & getCurrentlyLoadingLibraryNameReference ()
 
CLASS_LOADER_PUBLIC FactoryMapgetFactoryMapForBaseClass (const std::string &typeid_base_class_name)
 This function extracts a reference to the FactoryMap for appropriate base class out of the global plugin base to factory map. This function should be used by functions in this namespace that need to access the various factories so as to make sure the right key is generated to index into the global map. More...
 
template<typename Base >
FactoryMapgetFactoryMapForBaseClass ()
 Same as above but uses a type parameter instead of string for more safety if info is available. More...
 
CLASS_LOADER_PUBLIC BaseToFactoryMapMapgetGlobalPluginBaseToFactoryMapMap ()
 Gets a handle to a global data structure that holds a map of base class names (Base class describes plugin interface) to a FactoryMap which holds the factories for the various different concrete classes that can be instantiated. Note that the Base class is NOT THE LITERAL CLASSNAME, but rather the result of typeid(Base).name() which sometimes is the literal class name (as on Windows) but is often in mangled form (as on Linux). More...
 
CLASS_LOADER_PUBLIC LibraryVectorgetLoadedLibraryVector ()
 Gets a handle to a list of open libraries in the form of LibraryPairs which encode the library path+name and the handle to the underlying Poco::SharedLibrary. More...
 
CLASS_LOADER_PUBLIC boost::recursive_mutex & getLoadedLibraryVectorMutex ()
 To provide thread safety, all exposed plugin functions can only be run serially by multiple threads. This is implemented by using critical sections enforced by a single mutex which is locked and released with the following two functions. More...
 
MetaObjectVectorgetMetaObjectGraveyard ()
 
CLASS_LOADER_PUBLIC boost::recursive_mutex & getPluginBaseToFactoryMapMapMutex ()
 
CLASS_LOADER_PUBLIC bool hasANonPurePluginLibraryBeenOpened ()
 Indicates if a library containing more than just plugins has been opened by the running process. More...
 
CLASS_LOADER_PUBLIC void hasANonPurePluginLibraryBeenOpened (bool hasIt)
 Sets a flag indicating if a library containing more than just plugins has been opened by the running process. More...
 
bool & hasANonPurePluginLibraryBeenOpenedReference ()
 
void insertMetaObjectIntoGraveyard (AbstractMetaObjectBase *meta_obj)
 
CLASS_LOADER_PUBLIC bool isLibraryLoaded (const std::string &library_path, ClassLoader *loader)
 Indicates if passed library loaded within scope of a ClassLoader. The library maybe loaded in memory, but to the class loader it may not be. More...
 
CLASS_LOADER_PUBLIC bool isLibraryLoadedByAnybody (const std::string &library_path)
 Indicates if passed library has been loaded by ANY ClassLoader. More...
 
CLASS_LOADER_PUBLIC void loadLibrary (const std::string &library_path, ClassLoader *loader)
 Loads a library into memory if it has not already been done so. Attempting to load an already loaded library has no effect. More...
 
CLASS_LOADER_PUBLIC void printDebugInfoToScreen ()
 
void purgeGraveyardOfMetaobjects (const std::string &library_path, ClassLoader *loader, bool delete_objs)
 
template<typename Derived , typename Base >
void registerPlugin (const std::string &class_name, const std::string &base_class_name)
 This function is called by the CLASS_LOADER_REGISTER_CLASS macro in plugin_register_macro.h to register factories. Classes that use that macro will cause this function to be invoked when the library is loaded. The function will create a MetaObject (i.e. factory) for the corresponding Derived class and insert it into the appropriate FactoryMap in the global Base-to-FactoryMap map. Note that the passed class_name is the literal class name and not the mangled version. More...
 
void revivePreviouslyCreateMetaobjectsFromGraveyard (const std::string &library_path, ClassLoader *loader)
 
CLASS_LOADER_PUBLIC void setCurrentlyActiveClassLoader (ClassLoader *loader)
 Sets the ClassLoader currently in scope which used when a library is being loaded. More...
 
CLASS_LOADER_PUBLIC void setCurrentlyLoadingLibraryName (const std::string &library_name)
 When a library is being loaded, in order for factories to know which library they are being associated with, this function is called to set the name of the library currently being loaded. More...
 
CLASS_LOADER_PUBLIC void unloadLibrary (const std::string &library_path, ClassLoader *loader)
 Unloads a library if it loaded in memory and cleans up its corresponding class factories. If it is not loaded, the function has no effect. More...
 

Typedef Documentation

◆ BaseClassName

typedef std::string class_loader::impl::BaseClassName

Definition at line 69 of file class_loader_core.hpp.

◆ BaseToFactoryMapMap

Definition at line 71 of file class_loader_core.hpp.

◆ ClassLoaderVector

Definition at line 53 of file meta_object.hpp.

◆ ClassName

typedef std::string class_loader::impl::ClassName

Definition at line 68 of file class_loader_core.hpp.

◆ FactoryMap

Definition at line 70 of file class_loader_core.hpp.

◆ LibraryPair

typedef std::pair<LibraryPath, Poco::SharedLibrary *> class_loader::impl::LibraryPair

Definition at line 72 of file class_loader_core.hpp.

◆ LibraryPath

typedef std::string class_loader::impl::LibraryPath

Definition at line 67 of file class_loader_core.hpp.

◆ LibraryVector

Definition at line 73 of file class_loader_core.hpp.

◆ MetaObjectVector

Definition at line 74 of file class_loader_core.hpp.

Function Documentation

◆ addClassLoaderOwnerForAllExistingMetaObjectsForLibrary()

void class_loader::impl::addClassLoaderOwnerForAllExistingMetaObjectsForLibrary ( const std::string &  library_path,
ClassLoader loader 
)

Definition at line 333 of file class_loader_core.cpp.

◆ allMetaObjects() [1/2]

MetaObjectVector class_loader::impl::allMetaObjects ( const FactoryMap factories)

Definition at line 142 of file class_loader_core.cpp.

◆ allMetaObjects() [2/2]

MetaObjectVector class_loader::impl::allMetaObjects ( )

Definition at line 151 of file class_loader_core.cpp.

◆ allMetaObjectsForClassLoader()

MetaObjectVector class_loader::impl::allMetaObjectsForClassLoader ( const ClassLoader owner)

Definition at line 192 of file class_loader_core.cpp.

◆ allMetaObjectsForLibrary()

MetaObjectVector class_loader::impl::allMetaObjectsForLibrary ( const std::string &  library_path)

Definition at line 198 of file class_loader_core.cpp.

◆ allMetaObjectsForLibraryOwnedBy()

MetaObjectVector class_loader::impl::allMetaObjectsForLibraryOwnedBy ( const std::string &  library_path,
const ClassLoader owner 
)

Definition at line 204 of file class_loader_core.cpp.

◆ areThereAnyExistingMetaObjectsForLibrary()

bool class_loader::impl::areThereAnyExistingMetaObjectsForLibrary ( const std::string &  library_path)

Definition at line 272 of file class_loader_core.cpp.

◆ createInstance()

template<typename Base >
Base* class_loader::impl::createInstance ( const std::string &  derived_class_name,
ClassLoader loader 
)

This function creates an instance of a plugin class given the derived name of the class and returns a pointer of the Base class type.

Parameters
derived_class_name- The name of the derived class (unmangled)
loader- The ClassLoader whose scope we are within
Returns
A pointer to newly created plugin, note caller is responsible for object destruction

Definition at line 244 of file class_loader_core.hpp.

◆ destroyMetaObjectsForLibrary() [1/2]

void class_loader::impl::destroyMetaObjectsForLibrary ( const std::string &  library_path,
FactoryMap factories,
const ClassLoader loader 
)

Definition at line 219 of file class_loader_core.cpp.

◆ destroyMetaObjectsForLibrary() [2/2]

void class_loader::impl::destroyMetaObjectsForLibrary ( const std::string &  library_path,
const ClassLoader loader 
)

Definition at line 253 of file class_loader_core.cpp.

◆ filterAllMetaObjectsAssociatedWithLibrary()

MetaObjectVector class_loader::impl::filterAllMetaObjectsAssociatedWithLibrary ( const MetaObjectVector to_filter,
const std::string &  library_path 
)

Definition at line 179 of file class_loader_core.cpp.

◆ filterAllMetaObjectsOwnedBy()

MetaObjectVector class_loader::impl::filterAllMetaObjectsOwnedBy ( const MetaObjectVector to_filter,
const ClassLoader owner 
)

Definition at line 167 of file class_loader_core.cpp.

◆ findLoadedLibrary()

LibraryVector::iterator class_loader::impl::findLoadedLibrary ( const std::string &  library_path)

Definition at line 278 of file class_loader_core.cpp.

◆ getAllLibrariesUsedByClassLoader()

std::vector< std::string > class_loader::impl::getAllLibrariesUsedByClassLoader ( const ClassLoader loader)

This function returns the names of all libraries in use by a given class loader.

Parameters
loader- The ClassLoader whose scope we are within
Returns
A vector of strings where each string is the path+name of each library that are within a ClassLoader's visible scope

Definition at line 317 of file class_loader_core.cpp.

◆ getAvailableClasses()

template<typename Base >
std::vector<std::string> class_loader::impl::getAvailableClasses ( ClassLoader loader)

This function returns all the available class_loader in the plugin system that are derived from Base and within scope of the passed ClassLoader.

Parameters
loader- The pointer to the ClassLoader whose scope we are within,
Returns
A vector of strings where each string is a plugin we can create

Definition at line 296 of file class_loader_core.hpp.

◆ getCurrentlyActiveClassLoader()

ClassLoader * class_loader::impl::getCurrentlyActiveClassLoader ( )

Gets the ClassLoader currently in scope which used when a library is being loaded.

Returns
A pointer to the currently active ClassLoader.

Definition at line 112 of file class_loader_core.cpp.

◆ getCurrentlyActiveClassLoaderReference()

ClassLoader* & class_loader::impl::getCurrentlyActiveClassLoaderReference ( )

Definition at line 106 of file class_loader_core.cpp.

◆ getCurrentlyLoadingLibraryName()

std::string class_loader::impl::getCurrentlyLoadingLibraryName ( )

When a library is being loaded, in order for factories to know which library they are being associated with, they use this function to query which library is being loaded.

Returns
The currently set loading library name as a string

Definition at line 95 of file class_loader_core.cpp.

◆ getCurrentlyLoadingLibraryNameReference()

std::string& class_loader::impl::getCurrentlyLoadingLibraryNameReference ( )

Definition at line 89 of file class_loader_core.cpp.

◆ getFactoryMapForBaseClass() [1/2]

FactoryMap & class_loader::impl::getFactoryMapForBaseClass ( const std::string &  typeid_base_class_name)

This function extracts a reference to the FactoryMap for appropriate base class out of the global plugin base to factory map. This function should be used by functions in this namespace that need to access the various factories so as to make sure the right key is generated to index into the global map.

Returns
A reference to the FactoryMap contained within the global Base-to-FactoryMap map.

Definition at line 66 of file class_loader_core.cpp.

◆ getFactoryMapForBaseClass() [2/2]

template<typename Base >
FactoryMap& class_loader::impl::getFactoryMapForBaseClass ( )

Same as above but uses a type parameter instead of string for more safety if info is available.

Returns
A reference to the FactoryMap contained within the global Base-to-FactoryMap map.

Definition at line 138 of file class_loader_core.hpp.

◆ getGlobalPluginBaseToFactoryMapMap()

BaseToFactoryMapMap & class_loader::impl::getGlobalPluginBaseToFactoryMapMap ( )

Gets a handle to a global data structure that holds a map of base class names (Base class describes plugin interface) to a FactoryMap which holds the factories for the various different concrete classes that can be instantiated. Note that the Base class is NOT THE LITERAL CLASSNAME, but rather the result of typeid(Base).name() which sometimes is the literal class name (as on Windows) but is often in mangled form (as on Linux).

Returns
A reference to the global base to factory map

Definition at line 60 of file class_loader_core.cpp.

◆ getLoadedLibraryVector()

LibraryVector & class_loader::impl::getLoadedLibraryVector ( )

Gets a handle to a list of open libraries in the form of LibraryPairs which encode the library path+name and the handle to the underlying Poco::SharedLibrary.

Returns
A reference to the global vector that tracks loaded libraries

Definition at line 83 of file class_loader_core.cpp.

◆ getLoadedLibraryVectorMutex()

boost::recursive_mutex & class_loader::impl::getLoadedLibraryVectorMutex ( )

To provide thread safety, all exposed plugin functions can only be run serially by multiple threads. This is implemented by using critical sections enforced by a single mutex which is locked and released with the following two functions.

Returns
A reference to the global mutex

Definition at line 48 of file class_loader_core.cpp.

◆ getMetaObjectGraveyard()

MetaObjectVector& class_loader::impl::getMetaObjectGraveyard ( )

Definition at line 77 of file class_loader_core.cpp.

◆ getPluginBaseToFactoryMapMapMutex()

boost::recursive_mutex & class_loader::impl::getPluginBaseToFactoryMapMapMutex ( )

Definition at line 54 of file class_loader_core.cpp.

◆ hasANonPurePluginLibraryBeenOpened() [1/2]

bool class_loader::impl::hasANonPurePluginLibraryBeenOpened ( )

Indicates if a library containing more than just plugins has been opened by the running process.

Returns
True if a non-pure plugin library has been opened, otherwise false

Definition at line 129 of file class_loader_core.cpp.

◆ hasANonPurePluginLibraryBeenOpened() [2/2]

void class_loader::impl::hasANonPurePluginLibraryBeenOpened ( bool  hasIt)

Sets a flag indicating if a library containing more than just plugins has been opened by the running process.

Parameters
hasIt- The flag

Definition at line 134 of file class_loader_core.cpp.

◆ hasANonPurePluginLibraryBeenOpenedReference()

bool& class_loader::impl::hasANonPurePluginLibraryBeenOpenedReference ( )

Definition at line 123 of file class_loader_core.cpp.

◆ insertMetaObjectIntoGraveyard()

void class_loader::impl::insertMetaObjectIntoGraveyard ( AbstractMetaObjectBase meta_obj)

Definition at line 209 of file class_loader_core.cpp.

◆ isLibraryLoaded()

bool class_loader::impl::isLibraryLoaded ( const std::string &  library_path,
ClassLoader loader 
)

Indicates if passed library loaded within scope of a ClassLoader. The library maybe loaded in memory, but to the class loader it may not be.

Parameters
library_path- The name of the library we wish to check is open
loader- The pointer to the ClassLoader whose scope we are within
Returns
true if the library is loaded within loader's scope, else false

Definition at line 304 of file class_loader_core.cpp.

◆ isLibraryLoadedByAnybody()

bool class_loader::impl::isLibraryLoadedByAnybody ( const std::string &  library_path)

Indicates if passed library has been loaded by ANY ClassLoader.

Parameters
library_path- The name of the library we wish to check is open
Returns
true if the library is loaded in memory, otherwise false

Definition at line 289 of file class_loader_core.cpp.

◆ loadLibrary()

void class_loader::impl::loadLibrary ( const std::string &  library_path,
ClassLoader loader 
)

Loads a library into memory if it has not already been done so. Attempting to load an already loaded library has no effect.

Parameters
library_path- The name of the library to open
loader- The pointer to the ClassLoader whose scope we are within

Definition at line 428 of file class_loader_core.cpp.

◆ printDebugInfoToScreen()

void class_loader::impl::printDebugInfoToScreen ( )

Definition at line 567 of file class_loader_core.cpp.

◆ purgeGraveyardOfMetaobjects()

void class_loader::impl::purgeGraveyardOfMetaobjects ( const std::string &  library_path,
ClassLoader loader,
bool  delete_objs 
)

Definition at line 374 of file class_loader_core.cpp.

◆ registerPlugin()

template<typename Derived , typename Base >
void class_loader::impl::registerPlugin ( const std::string &  class_name,
const std::string &  base_class_name 
)

This function is called by the CLASS_LOADER_REGISTER_CLASS macro in plugin_register_macro.h to register factories. Classes that use that macro will cause this function to be invoked when the library is loaded. The function will create a MetaObject (i.e. factory) for the corresponding Derived class and insert it into the appropriate FactoryMap in the global Base-to-FactoryMap map. Note that the passed class_name is the literal class name and not the mangled version.

Parameters
Derived- parameteric type indicating concrete type of plugin
Base- parameteric type indicating base type of plugin
class_name- the literal name of the class being registered (NOT MANGLED)

Definition at line 176 of file class_loader_core.hpp.

◆ revivePreviouslyCreateMetaobjectsFromGraveyard()

void class_loader::impl::revivePreviouslyCreateMetaobjectsFromGraveyard ( const std::string &  library_path,
ClassLoader loader 
)

Definition at line 350 of file class_loader_core.cpp.

◆ setCurrentlyActiveClassLoader()

void class_loader::impl::setCurrentlyActiveClassLoader ( ClassLoader loader)

Sets the ClassLoader currently in scope which used when a library is being loaded.

Parameters
loader- pointer to the currently active ClassLoader.

Definition at line 117 of file class_loader_core.cpp.

◆ setCurrentlyLoadingLibraryName()

void class_loader::impl::setCurrentlyLoadingLibraryName ( const std::string &  library_name)

When a library is being loaded, in order for factories to know which library they are being associated with, this function is called to set the name of the library currently being loaded.

Parameters
library_name- The name of library that is being loaded currently

Definition at line 100 of file class_loader_core.cpp.

◆ unloadLibrary()

void class_loader::impl::unloadLibrary ( const std::string &  library_path,
ClassLoader loader 
)

Unloads a library if it loaded in memory and cleans up its corresponding class factories. If it is not loaded, the function has no effect.

Parameters
library_path- The name of the library to open
loader- The pointer to the ClassLoader whose scope we are within

Definition at line 508 of file class_loader_core.cpp.



class_loader
Author(s): Mirza Shah, Steven! Ragnarök
autogenerated on Mon Feb 28 2022 22:02:03