Poco::ClassLoader< Base > Class Template Reference

#include <ClassLoader.h>

List of all members.

Classes

class  Iterator
 The ClassLoader's very own iterator class. More...
struct  LibraryInfo

Public Types

typedef bool(* BuildManifestFunc )(ManifestBase *)
typedef void(* InitializeLibraryFunc )()
typedef std::map< std::string,
LibraryInfo
LibraryMap
typedef Manifest< Base > Manif
typedef std::pair< const Manif
*, std::string > 
manifest_pair
typedef AbstractMetaObject< Base > Meta
typedef void(* UninitializeLibraryFunc )()

Public Member Functions

Iterator begin () const
bool canCreate (const std::string &className) const
const MetaclassFor (const std::string &className) const
 ClassLoader ()
 Creates the ClassLoader.
Base * create (const std::string &className) const
void destroy (const std::string &className, Base *pObject) const
Iterator end () const
const MetafindClass (const std::string &className) const
std::vector< manifest_pairfindManifest (const std::string &path) const
Base & instance (const std::string &className) const
bool isAutoDelete (const std::string &className, Base *pObject) const
bool isLibraryLoaded (const std::string &path) const
void loadLibrary (const std::string &path)
void loadLibrary (const std::string &path, const std::string &manifest)
const ManifmanifestFor (const std::string &path) const
void unloadLibrary (const std::string &path)
virtual ~ClassLoader ()
 Destroys the ClassLoader.

Private Attributes

LibraryMap _map
FastMutex _mutex

Detailed Description

template<class Base>
class Poco::ClassLoader< Base >

The ClassLoader loads C++ classes from shared libraries at runtime. It must be instantiated with a root class of the loadable classes. For a class to be loadable from a library, the library must provide a Manifest of all the classes it contains. The Manifest for a shared library can be easily built with the help of the macros in the header file "Foundation/ClassLibrary.h".

Starting with POCO release 1.3, a class library can export multiple manifests. In addition to the default (unnamed) manifest, multiple named manifests can be exported, each having a different base class.

There is one important restriction: one instance of ClassLoader can only load one manifest from a class library.

Definition at line 56 of file ClassLoader.h.


Member Typedef Documentation

template<class Base>
typedef bool(* Poco::ClassLoader< Base >::BuildManifestFunc)(ManifestBase *)

Definition at line 80 of file ClassLoader.h.

template<class Base>
typedef void(* Poco::ClassLoader< Base >::InitializeLibraryFunc)()

Definition at line 78 of file ClassLoader.h.

template<class Base>
typedef std::map<std::string, LibraryInfo> Poco::ClassLoader< Base >::LibraryMap

Definition at line 90 of file ClassLoader.h.

template<class Base>
typedef Manifest<Base> Poco::ClassLoader< Base >::Manif

Definition at line 77 of file ClassLoader.h.

template<class Base>
typedef std::pair<const Manif*, std::string> Poco::ClassLoader< Base >::manifest_pair

Definition at line 82 of file ClassLoader.h.

template<class Base>
typedef AbstractMetaObject<Base> Poco::ClassLoader< Base >::Meta

Definition at line 76 of file ClassLoader.h.

template<class Base>
typedef void(* Poco::ClassLoader< Base >::UninitializeLibraryFunc)()

Definition at line 79 of file ClassLoader.h.


Constructor & Destructor Documentation

template<class Base>
Poco::ClassLoader< Base >::ClassLoader (  )  [inline]

Creates the ClassLoader.

Definition at line 151 of file ClassLoader.h.

template<class Base>
virtual Poco::ClassLoader< Base >::~ClassLoader (  )  [inline, virtual]

Destroys the ClassLoader.

Definition at line 156 of file ClassLoader.h.


Member Function Documentation

template<class Base>
Iterator Poco::ClassLoader< Base >::begin (  )  const [inline]

Definition at line 425 of file ClassLoader.h.

template<class Base>
bool Poco::ClassLoader< Base >::canCreate ( const std::string &  className  )  const [inline]

Returns true if create() can create new instances of the class.

Definition at line 373 of file ClassLoader.h.

template<class Base>
const Meta& Poco::ClassLoader< Base >::classFor ( const std::string &  className  )  const [inline]

Returns a reference to the MetaObject for the given class. Throws a NotFoundException if the class is not known.

Definition at line 343 of file ClassLoader.h.

template<class Base>
Base* Poco::ClassLoader< Base >::create ( const std::string &  className  )  const [inline]

Creates an instance of the given class. Throws a NotFoundException if the class is not known.

Definition at line 355 of file ClassLoader.h.

template<class Base>
void Poco::ClassLoader< Base >::destroy ( const std::string &  className,
Base *  pObject 
) const [inline]

Destroys the object pObject points to. Does nothing if object is not found.

Definition at line 380 of file ClassLoader.h.

template<class Base>
Iterator Poco::ClassLoader< Base >::end (  )  const [inline]

Definition at line 432 of file ClassLoader.h.

template<class Base>
const Meta* Poco::ClassLoader< Base >::findClass ( const std::string &  className  )  const [inline]

Returns a pointer to the MetaObject for the given class, or a null pointer if the class is not known.

Definition at line 323 of file ClassLoader.h.

template<class Base>
std::vector<manifest_pair> Poco::ClassLoader< Base >::findManifest ( const std::string &  path  )  const [inline]

Returns a pointer to the Manifest for the given library, or a null pointer if the library has not been loaded.

Definition at line 394 of file ClassLoader.h.

template<class Base>
Base& Poco::ClassLoader< Base >::instance ( const std::string &  className  )  const [inline]

Returns a reference to the sole instance of the given class. The class must be a singleton, otherwise an InvalidAccessException will be thrown. Throws a NotFoundException if the class is not known.

Definition at line 363 of file ClassLoader.h.

template<class Base>
bool Poco::ClassLoader< Base >::isAutoDelete ( const std::string &  className,
Base *  pObject 
) const [inline]

Returns true if the object is automatically deleted by its meta object.

Definition at line 387 of file ClassLoader.h.

template<class Base>
bool Poco::ClassLoader< Base >::isLibraryLoaded ( const std::string &  path  )  const [inline]

Returns true if the library with the given name has already been loaded.

Definition at line 418 of file ClassLoader.h.

template<class Base>
void Poco::ClassLoader< Base >::loadLibrary ( const std::string &  path  )  [inline]

Loads a library from the given path. Does nothing if the library is already loaded. Throws a LibraryLoadException if the library cannot be loaded or does not have a Manifest. If the library exports a function named "pocoInitializeLibrary", this function is executed. If called multiple times for the same library, the number of calls to unloadLibrary() must be the same for the library to become unloaded.

Equivalent to loadLibrary(path, "").

Definition at line 269 of file ClassLoader.h.

template<class Base>
void Poco::ClassLoader< Base >::loadLibrary ( const std::string &  path,
const std::string &  manifest 
) [inline]

Loads a library from the given path, using the given manifest. Does nothing if the library is already loaded. Throws a LibraryLoadException if the library cannot be loaded or does not have a Manifest. If the library exports a function named "pocoInitializeLibrary", this function is executed. If called multiple times for the same library, the number of calls to unloadLibrary() must be the same for the library to become unloaded.

Definition at line 169 of file ClassLoader.h.

template<class Base>
const Manif& Poco::ClassLoader< Base >::manifestFor ( const std::string &  path  )  const [inline]

Returns a reference to the Manifest for the given library Throws a NotFoundException if the library has not been loaded.

Definition at line 407 of file ClassLoader.h.

template<class Base>
void Poco::ClassLoader< Base >::unloadLibrary ( const std::string &  path  )  [inline]

Unloads the given library. Be extremely cautious when unloading shared libraries. If objects from the library are still referenced somewhere, a total crash is very likely. If the library exports a function named "pocoUninitializeLibrary", this function is executed before it is unloaded. If loadLibrary() has been called multiple times for the same library, the number of calls to unloadLibrary() must be the same for the library to become unloaded.

Definition at line 285 of file ClassLoader.h.


Member Data Documentation

template<class Base>
LibraryMap Poco::ClassLoader< Base >::_map [private]

Definition at line 440 of file ClassLoader.h.

template<class Base>
FastMutex Poco::ClassLoader< Base >::_mutex [mutable, private]

Definition at line 441 of file ClassLoader.h.


The documentation for this class was generated from the following file:
 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