class_loader  master
The class_loader package is a ROS-independent package for loading plugins during runtime.
Public Member Functions | 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

 MultiLibraryClassLoader (bool enable_ondemand_loadunload)
 Constructor for the class. More...
 
virtual ~MultiLibraryClassLoader ()
 Virtual destructor for class. More...
 
template<class Base >
std::shared_ptr< Base > createInstance (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< Base > createInstance (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< Base > createUniqueInstance (const std::string &class_name)
 Creates an instance of an object of given class name with ancestor class Base. More...
 
template<class Base >
ClassLoader::UniquePtr< Base > createUniqueInstance (const std::string &class_name, const std::string &library_path)
 Creates an instance of an object of given class name with ancestor class Base. More...
 
template<class Base >
Base * createUnmanagedInstance (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 class This version should not be used as the plugin system cannot do automated safe loading/unloadings. More...
 
template<class Base >
Base * createUnmanagedInstance (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 >
bool isClassAvailable (const std::string &class_name) const
 Indicates if a class has been loaded and can be instantiated. More...
 
bool isLibraryAvailable (const std::string &library_path) const
 Indicates if a library has been loaded into memory. More...
 
template<class Base >
std::vector< std::stringgetAvailableClasses () const
 Gets a list of all classes that are loaded by the class loader. More...
 
template<class Base >
std::vector< std::stringgetAvailableClassesForLibrary (const std::string &library_path)
 Gets a list of all classes loaded for a particular library. More...
 
std::vector< std::stringgetRegisteredLibraries () const
 Gets a list of all libraries opened by this class loader. More...
 
void loadLibrary (const std::string &library_path)
 Loads a library into memory for this class loader. More...
 
int unloadLibrary (const std::string &library_path)
 Unloads a library for this class loader. More...
 

Detailed Description

A ClassLoader that can bind more than one runtime library.

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

◆ ~MultiLibraryClassLoader()

virtual class_loader::MultiLibraryClassLoader::~MultiLibraryClassLoader ( )
virtual

Virtual destructor for class.

Member Function Documentation

◆ createInstance() [1/2]

template<class Base >
std::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 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

◆ createInstance() [2/2]

template<class Base >
std::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 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

◆ 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.

This version does not look in a specific library for the factory, but rather the first open library that defines the class

Parameters
Base- polymorphic type indicating base class
class_name- the name of the concrete plugin class we want to instantiate
Returns
A unique pointer to newly created plugin

◆ 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.

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 unique pointer to newly created plugin

◆ 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 class 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

◆ 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

◆ isClassAvailable()

template<class Base >
bool class_loader::MultiLibraryClassLoader::isClassAvailable ( const std::string class_name) const
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

◆ isLibraryAvailable()

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

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

◆ getAvailableClasses()

template<class Base >
std::vector<std::string> class_loader::MultiLibraryClassLoader::getAvailableClasses ( ) const
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

◆ 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

◆ getRegisteredLibraries()

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

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

Returns
A list of libraries opened by this class loader

◆ 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

◆ 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
Returns
The number of times more unloadLibrary() has to be called for it to be unbound from this MultiLibraryClassLoader

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