Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
ServiceLocator< ServiceType > Class Template Reference

Static Public Member Functions

static shared_ptr< ServiceType > get_service (const char *alias=nullptr)
 Get the service that has been registereed for this type.
 
static void register_service (shared_ptr< ServiceType > &service, const char *alias=nullptr)
 Register a service instance with the service locator.
 

Detailed Description

template<typename ServiceType>
class ServiceLocator< ServiceType >

Definition at line 126 of file ServiceLocator.hxx.

Member Function Documentation

◆ get_service()

template<typename ServiceType >
static shared_ptr< ServiceType > ServiceLocator< ServiceType >::get_service ( const char *  alias = nullptr)
inlinestatic

Get the service that has been registereed for this type.

Parameters
aliasallows you to retrieve an instance with a specific name
Returns
the service, or nullptr if no such service

Definition at line 134 of file ServiceLocator.hxx.

◆ register_service()

template<typename ServiceType >
static void ServiceLocator< ServiceType >::register_service ( shared_ptr< ServiceType > &  service,
const char *  alias = nullptr 
)
inlinestatic

Register a service instance with the service locator.

Because this is just registering the pointer, the creator still owns the lifetime.

Parameters
serviceinstance that you want to register
aliasallows you to register a mapping with a specific name

Definition at line 147 of file ServiceLocator.hxx.


The documentation for this class was generated from the following file: