OpenLexocad
28.0
|
Service locator, nothing more. More...
#include <entt.hpp>
Public Types | |
using | service_type = Service |
Type of service offered. More... | |
Public Member Functions | |
service_locator ()=delete | |
Default constructor, deleted on purpose. More... | |
~service_locator ()=delete | |
Default destructor, deleted on purpose. More... | |
Static Public Member Functions | |
static bool | empty () ENTT_NOEXCEPT |
Tests if a valid service implementation is set. More... | |
static std::weak_ptr< Service > | get () ENTT_NOEXCEPT |
Returns a weak pointer to a service implementation, if any. More... | |
static Service & | ref () ENTT_NOEXCEPT |
Returns a weak reference to a service implementation, if any. More... | |
template<typename Impl = Service, typename... Args> | |
static void | set (Args &&... args) |
Sets or replaces a service. More... | |
static void | set (std::shared_ptr< Service > ptr) |
Sets or replaces a service. More... | |
static void | reset () |
Resets a service. More... | |
Service locator, nothing more.
A service locator can be 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 template based implementation tries to fill the gap and to get rid of the burden of defining a different specific locator for each application.
Service | Type of service managed by the locator. |
using entt::service_locator< Service >::service_type = Service |
Type of service offered.
|
delete |
Default constructor, deleted on purpose.
|
delete |
Default destructor, deleted on purpose.
|
inlinestatic |
Tests if a valid service implementation is set.
|
inlinestatic |
Returns a weak pointer to a service implementation, if any.
Clients of a service shouldn't retain references to it. The recommended way is to retrieve the service implementation currently set each and every time the need of using it arises. Otherwise users can incur in unexpected behaviors.
|
inlinestatic |
Returns a weak reference to a service implementation, if any.
Clients of a service shouldn't retain references to it. The recommended way is to retrieve the service implementation currently set each and every time the need of using it arises. Otherwise users can incur in unexpected behaviors.
|
inlinestatic |
Resets a service.
The service is no longer valid after a reset.
|
inlinestatic |
Sets or replaces a service.
Impl | Type of the new service to use. |
Args | Types of arguments to use to construct the service. |
args | Parameters to use to construct the service. |
|
inlinestatic |
Sets or replaces a service.
ptr | Service to use to replace the current one. |