ServiceLocator class
#include <nCine/ServiceLocator.h>
Central registry that provides engine services to requesting classes.
Holds the active audio device, thread pool and RHI 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 GetRhiCapabilities() -> const RHI::
IRhiCapabilities& - Returns reference to the current RHI capabilities instance.
-
void RegisterRhiCapabilities(std::
unique_ptr<RHI:: IRhiCapabilities> service) - Registers an RHI capabilities provider.
- void UnregisterRhiCapabilities()
- Unregisters the RHI 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.