cisst-saw
Loading...
Searching...
No Matches
osaDynamicLoader Class Reference

Dynamically load a shared library file. More...

#include <osaDynamicLoader.h>

Inheritance diagram for osaDynamicLoader:
osaDynamicLoaderAndFactoryBase osaDynamicLoaderAndFactory< BaseClass >

Public Member Functions

 osaDynamicLoader ()
virtual ~osaDynamicLoader ()
bool Load (const char *file, const char *path=0)
bool Load (const std::string &file, const std::string &path="")
void UnLoad (void)

Protected Attributes

void * handle

Detailed Description

Dynamically load a shared library file.

This class is used to dynamically load a shared library file. If a path is specified, the library file must exist on that path; otherwise, the "standard" library paths are used.

This class should be used to dynamically load a library file if it contains classes that are derived from cmnGenericObject, assuming that they are set up for dynamic creation (e.g., CMN_DYNAMIC_CREATION flag used with CMN_DECLARE_SERVICES). For example, if the class "derivedClass" exists in a library file with the same name, the file can be dynamically loaded and a new instance created as follows:

dload.Load("derivedClass");
cmnGenericObject *obj = cmnObjectRegister::Instance()->Create("derivedClass");
Base class for high level objects.
Definition cmnGenericObject.h:53
static cmnObjectRegister * Instance(void)
bool Load(const char *file, const char *path=0)
osaDynamicLoader()
Definition osaDynamicLoader.h:60

Note that dynamic_cast can be used to cast obj up the hierarchy.

Constructor & Destructor Documentation

◆ osaDynamicLoader()

osaDynamicLoader::osaDynamicLoader ( )
inline

Default constructor. Does nothing.

◆ ~osaDynamicLoader()

virtual osaDynamicLoader::~osaDynamicLoader ( )
inlinevirtual

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

Member Function Documentation

◆ Load() [1/2]

bool osaDynamicLoader::Load ( const char * file,
const char * path = 0 )

Dynamically load the specified shared library.

Parameters
fileName of shared library file to load (do not include extension)
pathPath to file (0 -> use default library load paths)
Returns
true if file successfully loaded; false otherwise

◆ Load() [2/2]

bool osaDynamicLoader::Load ( const std::string & file,
const std::string & path = "" )
inline

◆ UnLoad()

void osaDynamicLoader::UnLoad ( void )

Unload the shared library file (if supported by operating system).

Member Data Documentation

◆ handle

void* osaDynamicLoader::handle
protected

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