Stores key object pairs.
More...
#include <ArmarXCore/core/util/Registrar.h>
|
| using | ContainerType = std::unordered_map<KeyType, RegisteredType> |
| |
|
| static const RegisteredType & | get (const KeyType &key) |
| | Returns the registered object for the given key.
|
| |
| static std::vector< KeyType > | getKeys () |
| | Retrieves the list of all registered elements.
|
| |
| static bool | has (const KeyType &key) |
| |
| static void | registerElement (const KeyType &key, RegisteredType element) |
| | Registers an element.
|
| |
template<class RegisteredType, class KeyType = std::string, class = void>
class armarx::Registrar< RegisteredType, KeyType, class >
Stores key object pairs.
The third template parameter offers the option to tag this registrar with a class.
If polymorphic objects are required use a base class and unique pointers. E.g.:
class Base{};
class DerivedA{};
class DerivedB{};
static void registerElement(const KeyType &key, RegisteredType element)
Registers an element.
Definition Registrar.h:108
If functions are stored use std::function (or function pointers).
To register elements on file inclusion use this code in the header (note the missing static).
Registers the object passed to the constructor.
Definition Registrar.h:72
Example for strings
◆ ContainerType
template<class RegisteredType, class KeyType = std::string, class = void>
| using ContainerType = std::unordered_map<KeyType, RegisteredType> |
◆ get()
template<class RegisteredType, class KeyType = std::string, class = void>
| static const RegisteredType & get |
( |
const KeyType & | key | ) |
|
|
inlinestatic |
Returns the registered object for the given key.
- Parameters
-
- Returns
- The registered object for the given key.
◆ getKeys()
template<class RegisteredType, class KeyType = std::string, class = void>
| static std::vector< KeyType > getKeys |
( |
| ) |
|
|
inlinestatic |
Retrieves the list of all registered elements.
- Returns
- The list of all registered elements.
◆ has()
template<class RegisteredType, class KeyType = std::string, class = void>
| static bool has |
( |
const KeyType & | key | ) |
|
|
inlinestatic |
◆ registerElement()
template<class RegisteredType, class KeyType = std::string, class = void>
| static void registerElement |
( |
const KeyType & | key, |
|
|
RegisteredType | element ) |
|
inlinestatic |
Registers an element.
- Parameters
-
| key | The element's key. |
| element | The element. |
The documentation for this class was generated from the following file: