|
EnTT 3.13.2
|
Service locator, nothing more. More...
#include <locator.hpp>
Public Types | |
| using | type = Service |
| Service type. | |
| using | node_type = service_handle |
| Service node type. | |
Public Member Functions | |
| locator ()=delete | |
| Default constructor, deleted on purpose. | |
| ~locator ()=delete | |
| Default destructor, deleted on purpose. | |
Static Public Member Functions | |
| static bool | has_value () noexcept |
| Checks whether a service locator contains a value. | |
| static Service & | value () noexcept |
| Returns a reference to a valid service, if any. | |
| template<typename Type = Service, typename... Args> | |
| static Service & | value_or (Args &&...args) |
| Returns a service if available or sets it from a fallback type. | |
| template<typename Type = Service, typename... Args> | |
| static Service & | emplace (Args &&...args) |
| Sets or replaces a service. | |
| template<typename Type = Service, typename Allocator , typename... Args> | |
| static Service & | emplace (std::allocator_arg_t, Allocator alloc, Args &&...args) |
| Sets or replaces a service using a given allocator. | |
| static node_type | handle () noexcept |
| Returns a handle to the underlying service. | |
| static void | reset (const node_type &other={}) noexcept |
| Resets or replaces a service. | |
| template<typename Type , typename Deleter = std::default_delete<Type>> | |
| static void | reset (Type *elem, Deleter deleter={}) |
| Resets or replaces a service. | |
Service locator, nothing more.
A service locator is used to do what it promises: locate services.
Usually service locators are tightly bound to the services they expose and thus it's hard to define a general purpose class to do that. This tiny class tries to fill the gap and to get rid of the burden of defining a different specific locator for each application.
| Service | Service type. |
Definition at line 27 of file locator.hpp.
| using entt::locator< Service >::node_type = service_handle |
Service node type.
Definition at line 37 of file locator.hpp.
Service type.
Definition at line 35 of file locator.hpp.
|
inlinestatic |
Sets or replaces a service.
| Type | Service type. |
| Args | Types of arguments to use to construct the service. |
| args | Parameters to use to construct the service. |
Definition at line 90 of file locator.hpp.
|
inlinestatic |
Sets or replaces a service using a given allocator.
| Type | Service type. |
| Allocator | Type of allocator used to manage memory and elements. |
| Args | Types of arguments to use to construct the service. |
| alloc | The allocator to use. |
| args | Parameters to use to construct the service. |
Definition at line 105 of file locator.hpp.
|
inlinestaticnoexcept |
Returns a handle to the underlying service.
Definition at line 114 of file locator.hpp.
|
inlinestaticnoexcept |
Checks whether a service locator contains a value.
Definition at line 48 of file locator.hpp.
Resets or replaces a service.
| other | Optional handle with which to replace the service. |
Definition at line 124 of file locator.hpp.
|
inlinestatic |
Resets or replaces a service.
| Type | Service type. |
| Deleter | Deleter type. |
| elem | A pointer to a service to manage. |
| deleter | A deleter to use to destroy the service. |
Definition at line 136 of file locator.hpp.
|
inlinestaticnoexcept |
Returns a reference to a valid service, if any.
Definition at line 61 of file locator.hpp.
|
inlinestatic |
Returns a service if available or sets it from a fallback type.
Arguments are used only if a service doesn't already exist. In all other cases, they are discarded.
| Args | Types of arguments to use to construct the fallback service. |
| Type | Fallback service type. |
| args | Parameters to use to construct the fallback service. |
Definition at line 78 of file locator.hpp.