Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
ServiceLocatorImpl Class Reference

Provides the shared storage for registrations. More...

#include <ServiceLocator.hxx>

Static Public Member Functions

static void clear ()
 Remove all of the registerations for all types.
 

Static Private Member Functions

static void register_service (string name, shared_ptr< void > &service)
 Register a pointer with a name.
 
static shared_ptr< void > get_service (string name)
 Retrieves a pointer to the registered service, by name.
 

Static Private Attributes

static std::map< string, shared_ptr< void > > services
 
static Atomic lock_
 

Friends

template<typename ServiceType >
class ServiceLocator
 

Detailed Description

Provides the shared storage for registrations.

Definition at line 76 of file ServiceLocator.hxx.

Member Function Documentation

◆ clear()

static void ServiceLocatorImpl::clear ( )
inlinestatic

Remove all of the registerations for all types.

This is mainly useful for tests.

Definition at line 83 of file ServiceLocator.hxx.

◆ get_service()

static shared_ptr< void > ServiceLocatorImpl::get_service ( string  name)
inlinestaticprivate

Retrieves a pointer to the registered service, by name.

Parameters
nameof the service to retrieve
Returns
the retrieved pointer, which is not guaranteed to be of the requested type

Definition at line 110 of file ServiceLocator.hxx.

◆ register_service()

static void ServiceLocatorImpl::register_service ( string  name,
shared_ptr< void > &  service 
)
inlinestaticprivate

Register a pointer with a name.

The creator of the class still owns the instance.

Parameters
nameof the service that you want to register
serviceis a pointer that you want to register

Definition at line 98 of file ServiceLocator.hxx.

Friends And Related Symbol Documentation

◆ ServiceLocator

template<typename ServiceType >
friend class ServiceLocator
friend

Definition at line 122 of file ServiceLocator.hxx.

Member Data Documentation

◆ lock_

Atomic ServiceLocatorImpl::lock_
staticprivate

Definition at line 90 of file ServiceLocator.hxx.

◆ services

std::map< string, shared_ptr< void > > ServiceLocatorImpl::services
staticprivate

Definition at line 89 of file ServiceLocator.hxx.


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