ServiceLocator class
#include <nCine/ServiceLocator.h>
Central registry that provides engine services to requesting classes.
Holds the active audio device, thread pool and graphics capabilities providers. Null implementations are used until a real provider is registered, so callers can always obtain a valid reference.
Public functions
- auto GetAudioDevice() -> IAudioDevice&
- Returns reference to the current audio device instance.
-
void RegisterAudioDevice(std::
unique_ptr<IAudioDevice> service) - Registers an audio device provider.
- void UnregisterAudioDevice()
- Unregisters the audio device provider and reinstates the null one.
- auto GetThreadPool() -> IThreadPool&
- Returns reference to the current thread pool instance.
-
void RegisterThreadPool(std::
unique_ptr<IThreadPool> service) - Registers a thread pool provider.
- void UnregisterThreadPool()
- Unregisters the thread pool provider and reinstates the null one.
- auto GetGfxCapabilities() -> const IGfxCapabilities&
- Returns reference to the current graphics capabilities instance.
-
void RegisterGfxCapabilities(std::
unique_ptr<IGfxCapabilities> service) - Registers a graphics capabilities provider.
- void UnregisterGfxCapabilities()
- Unregisters the graphics capabilities provider and reinstates the null one.
- void UnregisterAll()
- Unregisters every registered service and reinstates null ones.
Friends
- auto theServiceLocator() -> ServiceLocator&
- Returns the singleton service locator instance.