cisst-saw
|
Dynamically load a shared library file and find the factory methods in the file. More...
#include <osaDynamicLoaderAndFactory.h>
Public Member Functions | |
osaDynamicLoaderAndFactory () | |
virtual | ~osaDynamicLoaderAndFactory () |
bool | Init (const char *name, const char *file, const char *path=0) |
bool | Init (const char *name) |
void | Reset () |
BaseClass * | CreateObject () const |
void | DestroyObject (BaseClass *obj) const |
![]() | |
virtual | ~osaDynamicLoaderAndFactoryBase () |
void | Reset () |
![]() | |
osaDynamicLoader () | |
virtual | ~osaDynamicLoader () |
bool | Load (const char *file, const char *path=0) |
void | UnLoad () |
Additional Inherited Members | |
![]() | |
osaDynamicLoaderAndFactoryBase () | |
bool | Init (const char *name, const char *file, const char *path, const std::type_info &tinfo, int version) |
![]() | |
void * | create |
void * | destroy |
![]() | |
void * | handle |
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.
|
inline |
Default constructor. Calls Reset() method.
|
inlinevirtual |
Destructor. Does not unload library in case any objects created from within the library still exist. To close library, call Reset().
|
inline |
Create a new instance of the derived class (from the dynamically loaded library).
|
inline |
Delete an instance of the derived class.
obj | Pointer to object to be destroyed. |
|
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.
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) |
|
inline |
Load the derived class from a file that has the same name as the derived class (no extension).
name | Name of derived class |
|
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.