ltdl wrapper for factory-like classes
More...
#include <mc_rtc/loader.h>
|
template<typename... Args> |
T * | create (const std::string &name, Args... args) |
|
template<typename... Args> |
T * | create_from_handles (const std::string &name, Args... args) |
|
template<typename... Args> |
T * | create_from_callbacks (const std::string &name, Args... args) |
|
ltdl wrapper for factory-like classes
◆ unique_ptr
◆ ObjectLoader()
Create ObjectLoader instance
- Parameters
-
class_name | Symbol used to distinguish the relevant libraries |
paths | directories searched for libraries |
verbose | If true, output some warning information |
cb | Function called when a new object is loaded |
◆ ~ObjectLoader()
mc_rtc::ObjectLoader::~ObjectLoader |
( |
| ) |
|
◆ clear()
void mc_rtc::ObjectLoader::clear |
( |
| ) |
|
Remove all loaded libraries
◆ create()
template<typename... Args>
T* mc_rtc::ObjectLoader::create |
( |
const std::string & |
name, |
|
|
Args... |
args |
|
) |
| |
|
protected |
Internal function to create a raw pointer
◆ create_from_callbacks()
template<typename... Args>
T* mc_rtc::ObjectLoader::create_from_callbacks |
( |
const std::string & |
name, |
|
|
Args... |
args |
|
) |
| |
|
protected |
Internal function to create a raw pointer from a registered callback
◆ create_from_handles()
template<typename... Args>
T* mc_rtc::ObjectLoader::create_from_handles |
( |
const std::string & |
name, |
|
|
Args... |
args |
|
) |
| |
|
protected |
Internal function to create a raw pointer from an handle
◆ create_object()
template<typename... Args>
std::shared_ptr<T> mc_rtc::ObjectLoader::create_object |
( |
const std::string & |
name, |
|
|
Args... |
args |
|
) |
| |
Create a new object of type name
- Parameters
-
name | the object's name |
Args | argument required by the constructor |
- Returns
- a shared pointer properly equipped to destroy the pointer
- Exceptions
-
LoaderException | throw if the name does not exist or if symbol resolution fails |
◆ create_unique_object()
template<typename... Args>
unique_ptr mc_rtc::ObjectLoader::create_unique_object |
( |
const std::string & |
name, |
|
|
Args... |
args |
|
) |
| |
Create a new object of type name
- Parameters
-
name | the object's name |
Args | arguments required by the constructor |
- Returns
- a unique pointer with a destructor provided by the library
- Exceptions
-
◆ get_object_runtime_directory()
std::string mc_rtc::ObjectLoader::get_object_runtime_directory |
( |
const std::string & |
name | ) |
const |
|
noexcept |
Returns the runtime directory of an object
Returns an empty string when the object is registered via a callback or if the object is unknown
- Parameters
-
◆ has_object()
bool mc_rtc::ObjectLoader::has_object |
( |
const std::string & |
name | ) |
const |
Returns true if the loader has the name object
- Parameters
-
◆ load_libraries()
Load libraries from the paths provided
- Parameters
-
paths | directories searched for libraries |
verbose | If true, output some warning information |
◆ objects()
std::vector<std::string> mc_rtc::ObjectLoader::objects |
( |
| ) |
const |
Returns the list of available objects
- Returns
- A list of available objects
◆ register_object()
template<typename RetT , typename... Args>
void mc_rtc::ObjectLoader::register_object |
( |
const std::string & |
name, |
|
|
std::function< RetT *(const Args &...)> |
callback |
|
) |
| |
Register a new loading function
- Parameters
-
name | Name that will be used to create new instance |
callback | Callback that will be used to create the object |
- Template Parameters
-
RetT | Must be derived from T |
- Exceptions
-
◆ set_verbosity()
void mc_rtc::ObjectLoader::set_verbosity |
( |
bool |
verbose | ) |
|
Set the verbosity
- Parameters
-
verbose | If true, loader will be more verbose |
◆ callbacks_
◆ class_name
std::string mc_rtc::ObjectLoader::class_name |
|
protected |
◆ deleters_
std::unordered_map<std::string, ObjectDeleter> mc_rtc::ObjectLoader::deleters_ |
|
protected |
◆ handles_
◆ verbose
bool mc_rtc::ObjectLoader::verbose |
|
protected |
The documentation for this class was generated from the following file: