pluginlib::ClassLoader< T > Class Template Reference

A class to help manage and load classes. More...

#include <class_loader.h>

List of all members.

Public Types

typedef std::map< std::string,
ClassDesc >::iterator 
ClassMapIterator

Public Member Functions

 ClassLoader (std::string package, std::string base_class, std::string attrib_name=std::string("plugin"))
 Constructor for a ClassLoader.
T * createClassInstance (const std::string &lookup_name, bool auto_load=true)
 Creates an instance of a desired class, optionally loading the associated library automatically if necessary.
std::string getBaseClassType () const
 Given the lookup name of a class, returns the type of the associated base class.
std::string getClassDescription (const std::string &lookup_name)
 Given the lookup name of a class, returns its description.
std::string getClassPackage (const std::string &lookup_name)
 Given the name of a class, returns name of the containing package.
std::string getClassType (const std::string &lookup_name)
 Given the lookup name of a class, returns the type of the derived class associated with it.
std::vector< std::string > getDeclaredClasses ()
 Returns a list of all available classes for this ClassLoader's base class type.
std::string getName (const std::string &lookup_name)
 Strips the package name off of a lookup name.
std::vector< std::string > getRegisteredLibraries ()
 Returns the libraries that are registered and can be loaded.
bool isClassAvailable (const std::string &lookup_name)
 Checks if the class associated with a plugin name is available to be loaded.
bool isClassLoaded (const std::string &lookup_name)
 Checks if a given class is currently loaded.
void loadLibraryForClass (const std::string &lookup_name)
 Attempts to load a class with a given name.
 ~ClassLoader ()
 Destructor for ClassLoader.

Private Types

typedef std::map< std::string,
unsigned int > 
LibraryCountMap

Private Member Functions

std::vector< std::string > getClassesInLibrary (const std::string &library_path)
 Returns the names of the classes that are available in a given library.
std::string getClassLibraryPath (const std::string &lookup_name)
 Given the name of a class, returns the path to its associated library.
std::vector< std::string > getLoadedLibraries ()
 Returns the libraries that are currently loaded.
bool loadClassLibrary (const std::string &library_path)
 Dynamicaly loads a library.
void loadClassLibraryInternal (const std::string &library_path, const std::string &list_name_arg=std::string(""))
 Helper function for loading a shared library.
bool unloadClassLibrary (const std::string &library_path)
 Unloads a previously dynamically loaded lobrary.

Private Attributes

std::string base_class_
std::map< std::string, ClassDescclasses_available_
LibraryCountMap loaded_libraries_
Poco::ClassLoader< T > poco_class_loader_

Detailed Description

template<class T>
class pluginlib::ClassLoader< T >

A class to help manage and load classes.

Definition at line 81 of file class_loader.h.


Member Typedef Documentation

template<class T>
typedef std::map<std::string, ClassDesc>::iterator pluginlib::ClassLoader< T >::ClassMapIterator

Definition at line 87 of file class_loader.h.

template<class T>
typedef std::map<std::string, unsigned int> pluginlib::ClassLoader< T >::LibraryCountMap [private]

Definition at line 84 of file class_loader.h.


Constructor & Destructor Documentation

template<class T >
pluginlib::ClassLoader< T >::ClassLoader ( std::string  package,
std::string  base_class,
std::string  attrib_name = std::string("plugin") 
) [inline]

Constructor for a ClassLoader.

Parameters:
package The package containing the base class
base_class The type of the base class for classes to be loaded
attrib_name The attribute to search for in manifext.xml files, defaults to "plugin"

Definition at line 47 of file class_loader_imp.h.

template<class T >
pluginlib::ClassLoader< T >::~ClassLoader (  )  [inline]

Destructor for ClassLoader.

Definition at line 179 of file class_loader_imp.h.


Member Function Documentation

template<class T >
T * pluginlib::ClassLoader< T >::createClassInstance ( const std::string &  lookup_name,
bool  auto_load = true 
) [inline]

Creates an instance of a desired class, optionally loading the associated library automatically if necessary.

Parameters:
lookup_name The name of the class to load
auto_load Specifies whether or not to automatically load the library containing the class, set to true by default
Exceptions:
pluginlib::LibraryLoadException Thrown when the library associated with the class cannot be loaded
pluginlib::CreateClassException Thrown when the class cannot be instantiated
Returns:
An instance of the class

Definition at line 271 of file class_loader_imp.h.

template<class T >
std::string pluginlib::ClassLoader< T >::getBaseClassType (  )  const [inline]

Given the lookup name of a class, returns the type of the associated base class.

Returns:
The type of the associated base class

Definition at line 247 of file class_loader_imp.h.

template<class T >
std::string pluginlib::ClassLoader< T >::getClassDescription ( const std::string &  lookup_name  )  [inline]

Given the lookup name of a class, returns its description.

Parameters:
lookup_name The lookup name of the class
Returns:
The description of the class

Definition at line 238 of file class_loader_imp.h.

template<class T >
std::vector< std::string > pluginlib::ClassLoader< T >::getClassesInLibrary ( const std::string &  library_path  )  [inline, private]

Returns the names of the classes that are available in a given library.

Parameters:
library_path The path to the library
Returns:
A vector of strings corresponding to the names of the classes in the library

Definition at line 334 of file class_loader_imp.h.

template<class T >
std::string pluginlib::ClassLoader< T >::getClassLibraryPath ( const std::string &  lookup_name  )  [inline, private]

Given the name of a class, returns the path to its associated library.

Parameters:
lookup_name The name of the class
Returns:
The path to the associated library

Definition at line 253 of file class_loader_imp.h.

template<class T >
std::string pluginlib::ClassLoader< T >::getClassPackage ( const std::string &  lookup_name  )  [inline]

Given the name of a class, returns name of the containing package.

Parameters:
lookup_name The name of the class
Returns:
The name of the containing package

Definition at line 262 of file class_loader_imp.h.

template<class T >
std::string pluginlib::ClassLoader< T >::getClassType ( const std::string &  lookup_name  )  [inline]

Given the lookup name of a class, returns the type of the derived class associated with it.

Parameters:
lookup_name The name of the class
Returns:
The name of the associated derived class

Definition at line 229 of file class_loader_imp.h.

template<class T >
std::vector< std::string > pluginlib::ClassLoader< T >::getDeclaredClasses (  )  [inline]

Returns a list of all available classes for this ClassLoader's base class type.

Returns:
A vector of strings corresponding to the names of all available classes

Definition at line 203 of file class_loader_imp.h.

template<class T >
std::vector< std::string > pluginlib::ClassLoader< T >::getLoadedLibraries (  )  [inline, private]

Returns the libraries that are currently loaded.

Returns:
A vector of strings corresponding to the names of loaded libraries

Definition at line 369 of file class_loader_imp.h.

template<class T >
std::string pluginlib::ClassLoader< T >::getName ( const std::string &  lookup_name  )  [inline]

Strips the package name off of a lookup name.

Parameters:
lookup_name The name of the plugin
Returns:
The name of the plugin stripped of the package name

Definition at line 214 of file class_loader_imp.h.

template<class T >
std::vector< std::string > pluginlib::ClassLoader< T >::getRegisteredLibraries (  )  [inline]

Returns the libraries that are registered and can be loaded.

Returns:
A vector of strings corresponding to the names of registered libraries

Definition at line 353 of file class_loader_imp.h.

template<class T >
bool pluginlib::ClassLoader< T >::isClassAvailable ( const std::string &  lookup_name  )  [inline]

Checks if the class associated with a plugin name is available to be loaded.

Parameters:
lookup_name The name of the plugin
Returns:
True if the plugin is available, false otherwise

Definition at line 223 of file class_loader_imp.h.

template<class T >
bool pluginlib::ClassLoader< T >::isClassLoaded ( const std::string &  lookup_name  )  [inline]

Checks if a given class is currently loaded.

Parameters:
lookup_name The lookup name of the class to query
Returns:
True if the class is loaded, false otherwise

Definition at line 190 of file class_loader_imp.h.

template<class T >
bool pluginlib::ClassLoader< T >::loadClassLibrary ( const std::string &  library_path  )  [inline, private]

Dynamicaly loads a library.

Parameters:
library_path The library to unload
Returns:
True if the library was successfully loaded, false otherwise

Definition at line 304 of file class_loader_imp.h.

template<class T >
void pluginlib::ClassLoader< T >::loadClassLibraryInternal ( const std::string &  library_path,
const std::string &  list_name_arg = std::string("") 
) [inline, private]

Helper function for loading a shared library.

Parameters:
library_path The path to the library to load
list_name The name of the class list to load

Definition at line 321 of file class_loader_imp.h.

template<class T >
void pluginlib::ClassLoader< T >::loadLibraryForClass ( const std::string &  lookup_name  )  [inline]

Attempts to load a class with a given name.

Parameters:
lookup_name The lookup name of the class to load
Exceptions:
pluginlib::LibraryLoadException Thrown if the library for the class cannot be loaded

Definition at line 138 of file class_loader_imp.h.

template<class T >
bool pluginlib::ClassLoader< T >::unloadClassLibrary ( const std::string &  library_path  )  [inline, private]

Unloads a previously dynamically loaded lobrary.

Parameters:
library_path The library to unload
Returns:
True if the library was successfully unloaded, false otherwise

Definition at line 286 of file class_loader_imp.h.


Member Data Documentation

template<class T>
std::string pluginlib::ClassLoader< T >::base_class_ [private]

Definition at line 228 of file class_loader.h.

template<class T>
std::map<std::string, ClassDesc> pluginlib::ClassLoader< T >::classes_available_ [private]

Definition at line 227 of file class_loader.h.

template<class T>
LibraryCountMap pluginlib::ClassLoader< T >::loaded_libraries_ [private]

Definition at line 223 of file class_loader.h.

template<class T>
Poco::ClassLoader<T> pluginlib::ClassLoader< T >::poco_class_loader_ [private]

Definition at line 230 of file class_loader.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines


pluginlib
Author(s): Tully Foote and Eitan Marder-Eppstein
autogenerated on Fri Jan 11 11:39:01 2013