ERC CISST - cisst software

osaDynamicLoaderAndFactory< BaseClass > Class Template Reference
[OS Abstraction]

#include <osaDynamicLoaderAndFactory.h>

Inheritance diagram for osaDynamicLoaderAndFactory< BaseClass >:

Inheritance graph
[legend]
Collaboration diagram for osaDynamicLoaderAndFactory< BaseClass >:

Collaboration graph
[legend]
List of all members.

Detailed Description

template<class BaseClass>
class osaDynamicLoaderAndFactory< BaseClass >

Dynamically load a shared library file and find the factory methods in the file.

This is a templated class that is used to dynamically load "plugin" modules that are implemented as derived classes of the specified base class (template parameter). The advantage of this class over osaDynamicLoader is that any class can serve as the base class. It is not necessary for the base or derived class to inherit from cmnGenericObject. The only requirement is that it contain a public VERSION enum that specifies the "interface version" of the base class. The VERSION should be changed for any base class changes that could affect the derived classes (e.g., adding member data, changing public methods, etc.).

If the base class is cmnGenericObject (or derived from it), the osaDynamicLoader class should be used instead.

See also:
osaDynamicLoader

Definition at line 76 of file osaDynamicLoaderAndFactory.h.

Public Member Functions


Constructor & Destructor Documentation

template<class BaseClass>
osaDynamicLoaderAndFactory< BaseClass >::osaDynamicLoaderAndFactory (  )  [inline]

Default constructor. Calls Reset() method.

Definition at line 83 of file osaDynamicLoaderAndFactory.h.

template<class BaseClass>
virtual osaDynamicLoaderAndFactory< BaseClass >::~osaDynamicLoaderAndFactory (  )  [inline, virtual]

Destructor. Does not unload library in case any objects created from within the library still exist. To close library, call Reset().

Definition at line 86 of file osaDynamicLoaderAndFactory.h.


Member Function Documentation

template<class BaseClass>
bool osaDynamicLoaderAndFactory< BaseClass >::Init ( const char *  name,
const char *  file,
const char *  path = 0 
) [inline]

Load the derived class from the specified file. Note that a file may contain more than one derived class, but each derived class must be accessed via a new dynamic loader object. The operating system ensures that a library is only loaded once.

Parameters:
name Name of derived class
file File name for derived class (do not include extension)
path Path to file (0 -> use default library load paths)
Returns:
true if sucessful; false otherwise

Definition at line 97 of file osaDynamicLoaderAndFactory.h.

template<class BaseClass>
bool osaDynamicLoaderAndFactory< BaseClass >::Init ( const char *  name  )  [inline]

Load the derived class from a file that has the same name as the derived class (no extension).

Parameters:
name Name of derived class
Returns:
true if sucessful; false otherwise

Definition at line 105 of file osaDynamicLoaderAndFactory.h.

template<class BaseClass>
void osaDynamicLoaderAndFactory< BaseClass >::Reset (  )  [inline]

Unload the library file and clear the factory functions. Do not call this method unless you are sure that all instances of the derived class have already been destroyed.

Reimplemented from osaDynamicLoaderAndFactoryBase.

Definition at line 111 of file osaDynamicLoaderAndFactory.h.

template<class BaseClass>
BaseClass* osaDynamicLoaderAndFactory< BaseClass >::CreateObject (  )  const [inline]

Create a new instance of the derived class (from the dynamically loaded library).

Returns:
a pointer to the new instance (0 if class not initialized)

Definition at line 116 of file osaDynamicLoaderAndFactory.h.

References osaDynamicLoaderAndFactoryBase::create.

template<class BaseClass>
void osaDynamicLoaderAndFactory< BaseClass >::DestroyObject ( BaseClass *  obj  )  const [inline]

Delete an instance of the derived class.

Parameters:
obj Pointer to object to be destroyed.

Definition at line 122 of file osaDynamicLoaderAndFactory.h.

References osaDynamicLoaderAndFactoryBase::destroy.


The documentation for this class was generated from the following file:
erc-cisst-devel<at>lists.johnshopkins.edu