Public Member Functions | Private Member Functions | Private Attributes | List of all members
class_loader::MultiLibraryClassLoader Class Reference

A ClassLoader that can bind more than one runtime library. More...

#include <multi_library_class_loader.hpp>

Public Member Functions

template<class Base >
boost::shared_ptr< BasecreateInstance (const std::string &class_name)
 Creates an instance of an object of given class name with ancestor class Base Same as createSharedInstance() except it returns a boost::shared_ptr. More...
 
template<class Base >
boost::shared_ptr< BasecreateInstance (const std::string &class_name, const std::string &library_path)
 Creates an instance of an object of given class name with ancestor class Base Same as createSharedInstance() except it returns a boost::shared_ptr. More...
 
template<class Base >
std::shared_ptr< BasecreateSharedInstance (const std::string &class_name)
 Creates an instance of an object of given class name with ancestor class Base This version does not look in a specific library for the factory, but rather the first open library that defines the classs. More...
 
template<class Base >
std::shared_ptr< BasecreateSharedInstance (const std::string &class_name, const std::string &library_path)
 Creates an instance of an object of given class name with ancestor class Base This version takes a specific library to make explicit the factory being used. More...
 
template<class Base >
ClassLoader::UniquePtr< BasecreateUniqueInstance (const std::string &class_name)
 Creates an instance of an object of given class name with ancestor class Base Same as createSharedInstance() except it returns a std::unique_ptr. More...
 
template<class Base >
ClassLoader::UniquePtr< BasecreateUniqueInstance (const std::string &class_name, const std::string &library_path)
 Creates an instance of an object of given class name with ancestor class Base Same as createSharedInstance() except it returns a std::unique_ptr. More...
 
template<class Base >
BasecreateUnmanagedInstance (const std::string &class_name)
 Creates an instance of an object of given class name with ancestor class Base This version does not look in a specific library for the factory, but rather the first open library that defines the classs This version should not be used as the plugin system cannot do automated safe loading/unloadings. More...
 
template<class Base >
BasecreateUnmanagedInstance (const std::string &class_name, const std::string &library_path)
 Creates an instance of an object of given class name with ancestor class Base This version takes a specific library to make explicit the factory being used This version should not be used as the plugin system cannot do automated safe loading/unloadings. More...
 
template<class Base >
std::vector< std::string > getAvailableClasses ()
 Gets a list of all classes that are loaded by the class loader. More...
 
template<class Base >
std::vector< std::string > getAvailableClassesForLibrary (const std::string &library_path)
 Gets a list of all classes loaded for a particular library. More...
 
std::vector< std::string > getRegisteredLibraries ()
 Gets a list of all libraries opened by this class loader . More...
 
template<class Base >
bool isClassAvailable (const std::string &class_name)
 Indicates if a class has been loaded and can be instantiated. More...
 
bool isLibraryAvailable (const std::string &library_path)
 Indicates if a library has been loaded into memory. More...
 
void loadLibrary (const std::string &library_path)
 Loads a library into memory for this class loader. More...
 
 MultiLibraryClassLoader (bool enable_ondemand_loadunload)
 Constructor for the class. More...
 
int unloadLibrary (const std::string &library_path)
 Unloads a library for this class loader. More...
 
virtual ~MultiLibraryClassLoader ()
 Virtual destructor for class. More...
 

Private Member Functions

ClassLoaderVector getAllAvailableClassLoaders ()
 Gets all class loaders loaded within scope. More...
 
template<typename Base >
ClassLoadergetClassLoaderForClass (const std::string &class_name)
 Gets a handle to the class loader corresponding to a specific class. More...
 
ClassLoadergetClassLoaderForLibrary (const std::string &library_path)
 Gets a handle to the class loader corresponding to a specific runtime library. More...
 
bool isOnDemandLoadUnloadEnabled ()
 Indicates if on-demand (lazy) load/unload is enabled so libraries are loaded/unloaded automatically as needed. More...
 
void shutdownAllClassLoaders ()
 Destroys all ClassLoaders. More...
 

Private Attributes

LibraryToClassLoaderMap active_class_loaders_
 
bool enable_ondemand_loadunload_
 
boost::mutex loader_mutex_
 

Detailed Description

A ClassLoader that can bind more than one runtime library.

Definition at line 56 of file multi_library_class_loader.hpp.

Constructor & Destructor Documentation

◆ MultiLibraryClassLoader()

class_loader::MultiLibraryClassLoader::MultiLibraryClassLoader ( bool  enable_ondemand_loadunload)
explicit

Constructor for the class.

Parameters
enable_ondemand_loadunload- Flag indicates if classes are to be loaded/unloaded automatically as class_loader are created and destroyed

Definition at line 39 of file multi_library_class_loader.cpp.

◆ ~MultiLibraryClassLoader()

class_loader::MultiLibraryClassLoader::~MultiLibraryClassLoader ( )
virtual

Virtual destructor for class.

Definition at line 44 of file multi_library_class_loader.cpp.

Member Function Documentation

◆ createInstance() [1/2]

template<class Base >
boost::shared_ptr<Base> class_loader::MultiLibraryClassLoader::createInstance ( const std::string &  class_name)
inline

Creates an instance of an object of given class name with ancestor class Base Same as createSharedInstance() except it returns a boost::shared_ptr.

Definition at line 123 of file multi_library_class_loader.hpp.

◆ createInstance() [2/2]

template<class Base >
boost::shared_ptr<Base> class_loader::MultiLibraryClassLoader::createInstance ( const std::string &  class_name,
const std::string &  library_path 
)
inline

Creates an instance of an object of given class name with ancestor class Base Same as createSharedInstance() except it returns a boost::shared_ptr.

Definition at line 147 of file multi_library_class_loader.hpp.

◆ createSharedInstance() [1/2]

template<class Base >
std::shared_ptr<Base> class_loader::MultiLibraryClassLoader::createSharedInstance ( const std::string &  class_name)
inline

Creates an instance of an object of given class name with ancestor class Base This version does not look in a specific library for the factory, but rather the first open library that defines the classs.

Parameters
Base- polymorphic type indicating base class
class_name- the name of the concrete plugin class we want to instantiate
Returns
A std::shared_ptr<Base> to newly created plugin

Definition at line 78 of file multi_library_class_loader.hpp.

◆ createSharedInstance() [2/2]

template<class Base >
std::shared_ptr<Base> class_loader::MultiLibraryClassLoader::createSharedInstance ( const std::string &  class_name,
const std::string &  library_path 
)
inline

Creates an instance of an object of given class name with ancestor class Base This version takes a specific library to make explicit the factory being used.

Parameters
Base- polymorphic type indicating base class
class_name- the name of the concrete plugin class we want to instantiate
library_path- the library from which we want to create the plugin
Returns
A std::shared_ptr<Base> to newly created plugin

Definition at line 106 of file multi_library_class_loader.hpp.

◆ createUniqueInstance() [1/2]

template<class Base >
ClassLoader::UniquePtr<Base> class_loader::MultiLibraryClassLoader::createUniqueInstance ( const std::string &  class_name)
inline

Creates an instance of an object of given class name with ancestor class Base Same as createSharedInstance() except it returns a std::unique_ptr.

Definition at line 164 of file multi_library_class_loader.hpp.

◆ createUniqueInstance() [2/2]

template<class Base >
ClassLoader::UniquePtr<Base> class_loader::MultiLibraryClassLoader::createUniqueInstance ( const std::string &  class_name,
const std::string &  library_path 
)
inline

Creates an instance of an object of given class name with ancestor class Base Same as createSharedInstance() except it returns a std::unique_ptr.

Definition at line 186 of file multi_library_class_loader.hpp.

◆ createUnmanagedInstance() [1/2]

template<class Base >
Base* class_loader::MultiLibraryClassLoader::createUnmanagedInstance ( const std::string &  class_name)
inline

Creates an instance of an object of given class name with ancestor class Base This version does not look in a specific library for the factory, but rather the first open library that defines the classs This version should not be used as the plugin system cannot do automated safe loading/unloadings.

Parameters
Base- polymorphic type indicating base class
class_name- the name of the concrete plugin class we want to instantiate
Returns
An unmanaged Base* to newly created plugin

Definition at line 207 of file multi_library_class_loader.hpp.

◆ createUnmanagedInstance() [2/2]

template<class Base >
Base* class_loader::MultiLibraryClassLoader::createUnmanagedInstance ( const std::string &  class_name,
const std::string &  library_path 
)
inline

Creates an instance of an object of given class name with ancestor class Base This version takes a specific library to make explicit the factory being used This version should not be used as the plugin system cannot do automated safe loading/unloadings.

Parameters
Base- polymorphic type indicating Base class
class_name- name of class for which we want to create instance
library_path- the fully qualified path to the runtime library

Definition at line 226 of file multi_library_class_loader.hpp.

◆ getAllAvailableClassLoaders()

ClassLoaderVector class_loader::MultiLibraryClassLoader::getAllAvailableClassLoaders ( )
private

Gets all class loaders loaded within scope.

Definition at line 68 of file multi_library_class_loader.cpp.

◆ getAvailableClasses()

template<class Base >
std::vector<std::string> class_loader::MultiLibraryClassLoader::getAvailableClasses ( )
inline

Gets a list of all classes that are loaded by the class loader.

Parameters
Base- polymorphic type indicating Base class
Returns
A vector<string> of the available classes

Definition at line 265 of file multi_library_class_loader.hpp.

◆ getAvailableClassesForLibrary()

template<class Base >
std::vector<std::string> class_loader::MultiLibraryClassLoader::getAvailableClassesForLibrary ( const std::string &  library_path)
inline

Gets a list of all classes loaded for a particular library.

Parameters
Base- polymorphic type indicating Base class
Returns
A vector<string> of the available classes in the passed library

Definition at line 282 of file multi_library_class_loader.hpp.

◆ getClassLoaderForClass()

template<typename Base >
ClassLoader* class_loader::MultiLibraryClassLoader::getClassLoaderForClass ( const std::string &  class_name)
inlineprivate

Gets a handle to the class loader corresponding to a specific class.

Parameters
class_name- name of class for which we want to create instance
Returns
A pointer to the ClassLoader*, == nullptr if not found

Definition at line 331 of file multi_library_class_loader.hpp.

◆ getClassLoaderForLibrary()

ClassLoader * class_loader::MultiLibraryClassLoader::getClassLoaderForLibrary ( const std::string &  library_path)
private

Gets a handle to the class loader corresponding to a specific runtime library.

Parameters
library_path- the library from which we want to create the plugin
Returns
A pointer to the ClassLoader*, == nullptr if not found

Definition at line 60 of file multi_library_class_loader.cpp.

◆ getRegisteredLibraries()

std::vector< std::string > class_loader::MultiLibraryClassLoader::getRegisteredLibraries ( )

Gets a list of all libraries opened by this class loader .

Returns
A list of libraries opened by this class loader

Definition at line 49 of file multi_library_class_loader.cpp.

◆ isClassAvailable()

template<class Base >
bool class_loader::MultiLibraryClassLoader::isClassAvailable ( const std::string &  class_name)
inline

Indicates if a class has been loaded and can be instantiated.

Parameters
Base- polymorphic type indicating Base class
class_name- name of class that is be inquired about
Returns
true if loaded, false otherwise

Definition at line 245 of file multi_library_class_loader.hpp.

◆ isLibraryAvailable()

bool class_loader::MultiLibraryClassLoader::isLibraryAvailable ( const std::string &  library_path)

Indicates if a library has been loaded into memory.

Parameters
library_path- The full qualified path to the runtime library
Returns
true if library is loaded, false otherwise

Definition at line 77 of file multi_library_class_loader.cpp.

◆ isOnDemandLoadUnloadEnabled()

bool class_loader::MultiLibraryClassLoader::isOnDemandLoadUnloadEnabled ( )
inlineprivate

Indicates if on-demand (lazy) load/unload is enabled so libraries are loaded/unloaded automatically as needed.

Definition at line 316 of file multi_library_class_loader.hpp.

◆ loadLibrary()

void class_loader::MultiLibraryClassLoader::loadLibrary ( const std::string &  library_path)

Loads a library into memory for this class loader.

Parameters
library_path- the fully qualified path to the runtime library

Definition at line 82 of file multi_library_class_loader.cpp.

◆ shutdownAllClassLoaders()

void class_loader::MultiLibraryClassLoader::shutdownAllClassLoaders ( )
private

Destroys all ClassLoaders.

Definition at line 90 of file multi_library_class_loader.cpp.

◆ unloadLibrary()

int class_loader::MultiLibraryClassLoader::unloadLibrary ( const std::string &  library_path)

Unloads a library for this class loader.

Parameters
library_path- the fully qualified path to the runtime library

Definition at line 99 of file multi_library_class_loader.cpp.

Member Data Documentation

◆ active_class_loaders_

LibraryToClassLoaderMap class_loader::MultiLibraryClassLoader::active_class_loaders_
private

Definition at line 357 of file multi_library_class_loader.hpp.

◆ enable_ondemand_loadunload_

bool class_loader::MultiLibraryClassLoader::enable_ondemand_loadunload_
private

Definition at line 356 of file multi_library_class_loader.hpp.

◆ loader_mutex_

boost::mutex class_loader::MultiLibraryClassLoader::loader_mutex_
private

Definition at line 358 of file multi_library_class_loader.hpp.


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


class_loader
Author(s): Mirza Shah, Steven! Ragnarök
autogenerated on Fri Jan 12 2024 04:01:32