RobWorkProject  23.9.11-
Public Member Functions | List of all members
DynamicLibraryLoader< T > Class Template Reference

Loader for dynamic/shared libraries. More...

#include <DynamicLibraryLoader.hpp>

Inherits DynamicLibraryLoaderBase.

Public Member Functions

 DynamicLibraryLoader (const std::string &filename, const std::string &funcname="factory0")
 Constructs loader and opens the library. More...
 
virtual ~DynamicLibraryLoader ()
 Closes the handle to the library. More...
 
T * get ()
 Returns object loaded from library. More...
 
- Public Member Functions inherited from DynamicLibraryLoaderBase
 DynamicLibraryLoaderBase (const std::string &filename)
 Open the library. More...
 
virtual ~DynamicLibraryLoaderBase ()
 Closes the handle to the library.
 
void * getObject (const std::string &funcname)
 Returns pointer to object loaded using the factory function funcname. More...
 
virtual std::string getFileExtension () const
 Returns file extension of dynamic libraries on the current platform. More...
 

Detailed Description

template<class T>
class rw::plugin::DynamicLibraryLoader< T >

Loader for dynamic/shared libraries.

The DynamicLibraryLoader provides a template based interface to the DynamicLibraryLoaderBase.

Notice that when using the dynamicLibraryLoader it is necessary to link with additional libraries. On Linux/Mac link with "dl". On Windows link with "kernel32".

Constructor & Destructor Documentation

◆ DynamicLibraryLoader()

DynamicLibraryLoader ( const std::string &  filename,
const std::string &  funcname = "factory0" 
)
inline

Constructs loader and opens the library.

When constructed the DynamicLibraryLoader open the library and throws an exception on failure. The search for the funcname entry is not done until trying to obtain the actual object.

Parameters
filename[in] Library file name (with extension)
funcname[in] Name of factory function in the library (default: factory0)

◆ ~DynamicLibraryLoader()

virtual ~DynamicLibraryLoader ( )
inlinevirtual

Closes the handle to the library.

Member Function Documentation

◆ get()

T* get ( )
inline

Returns object loaded from library.

Calls the factory method in library and returns the object. This method throws an exception if the factory method cannot be found.

Returns
The loaded object. This may be null

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