|
mc_rtc
2.14.0
|
ltdl wrapper for factory-like classes More...
#include <mc_rtc/loader.h>


Classes | |
| struct | ObjectDeleter |
Public Types | |
| using | unique_ptr = std::unique_ptr< T, ObjectDeleter > |
Public Member Functions | |
| ObjectLoader (const std::string &class_name, const std::vector< std::string > &paths, bool verbose, Loader::callback_t cb=Loader::default_cb) | |
| ~ObjectLoader () | |
| bool | has_object (const std::string &name) const |
| std::vector< std::string > | objects () const |
| void | load_libraries (const std::vector< std::string > &paths, Loader::callback_t cb=Loader::default_cb) |
| void | clear () |
| void | set_verbosity (bool verbose) |
| template<typename RetT , typename... Args> | |
| void | register_object (const std::string &name, std::function< RetT *(const Args &...)> callback) |
| template<typename... Args> | |
| std::shared_ptr< T > | create_object (const std::string &name, Args... args) |
| std::string | get_object_runtime_directory (const std::string &name) const noexcept |
| template<typename... Args> | |
| unique_ptr | create_unique_object (const std::string &name, Args... args) |
Protected Member Functions | |
| 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) |
Protected Attributes | |
| std::string | class_name |
| bool | verbose |
| Loader::handle_map_t | handles_ |
| mc_rtc::DataStore | callbacks_ |
| std::unordered_map< std::string, ObjectDeleter > | deleters_ |
ltdl wrapper for factory-like classes
| using mc_rtc::ObjectLoader< T >::unique_ptr = std::unique_ptr<T, ObjectDeleter> |
| mc_rtc::ObjectLoader< T >::ObjectLoader | ( | const std::string & | class_name, |
| const std::vector< std::string > & | paths, | ||
| bool | verbose, | ||
| Loader::callback_t | cb = Loader::default_cb |
||
| ) |
Create ObjectLoader instance
| 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 |
| mc_rtc::ObjectLoader< T >::~ObjectLoader | ( | ) |
Destructor
| void mc_rtc::ObjectLoader< T >::clear | ( | ) |
Remove all loaded libraries
|
protected |
Internal function to create a raw pointer
|
protected |
Internal function to create a raw pointer from a registered callback
|
protected |
Internal function to create a raw pointer from an handle
| std::shared_ptr<T> mc_rtc::ObjectLoader< T >::create_object | ( | const std::string & | name, |
| Args... | args | ||
| ) |
Create a new object of type name
| name | the object's name |
| Args | argument required by the constructor |
| LoaderException | throw if the name does not exist or if symbol resolution fails |
| unique_ptr mc_rtc::ObjectLoader< T >::create_unique_object | ( | const std::string & | name, |
| Args... | args | ||
| ) |
Create a new object of type name
| name | the object's name |
| Args | arguments required by the constructor |
| LoaderException | if the name does not exist or if symbol resolution fails |
|
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
| name | Name of the object |
| bool mc_rtc::ObjectLoader< T >::has_object | ( | const std::string & | name | ) | const |
Returns true if the loader has the name object
| name | Name to be tested |
| void mc_rtc::ObjectLoader< T >::load_libraries | ( | const std::vector< std::string > & | paths, |
| Loader::callback_t | cb = Loader::default_cb |
||
| ) |
Load libraries from the paths provided
| paths | directories searched for libraries |
| verbose | If true, output some warning information |
| std::vector<std::string> mc_rtc::ObjectLoader< T >::objects | ( | ) | const |
Returns the list of available objects
| void mc_rtc::ObjectLoader< T >::register_object | ( | const std::string & | name, |
| std::function< RetT *(const Args &...)> | callback | ||
| ) |
Register a new loading function
| name | Name that will be used to create new instance |
| callback | Callback that will be used to create the object |
| RetT | Must be derived from T |
| LoaderException | if the object is already registered |
| void mc_rtc::ObjectLoader< T >::set_verbosity | ( | bool | verbose | ) |
Set the verbosity
| verbose | If true, loader will be more verbose |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |