#include <nap/service.h>
Public Member Functions | |
Service (ServiceConfiguration *configuration) | |
virtual | ~Service () |
Core & | getCore () |
const Core & | getCore () const |
std::string | getTypeName () const |
const Module & | getModule () const |
Service (Service &)=delete | |
Service & | operator= (const Service &)=delete |
Service (Service &&)=delete | |
Service & | operator= (Service &&)=delete |
Protected Member Functions | |
virtual void | registerObjectCreators (rtti::Factory &factory) |
virtual void | getDependentServices (std::vector< rtti::TypeInfo > &dependencies) |
virtual void | created () |
virtual bool | init (utility::ErrorState &error) |
virtual void | preUpdate (double deltaTime) |
virtual void | update (double deltaTime) |
virtual void | postUpdate (double deltaTime) |
virtual void | preShutdown () |
virtual void | shutdown () |
virtual void | preResourcesLoaded () |
virtual void | postResourcesLoaded () |
template<typename SERVICE_CONFIG > | |
SERVICE_CONFIG * | getConfiguration () |
template<typename SERVICE_CONFIG > | |
const SERVICE_CONFIG * | getConfiguration () const |
std::string | getIniFilePath () const |
std::string | getIniFilePath (const std::string &appendix) const |
A Service is a process within core that cooperates with certain components in the system, this is the base class for all services. Often services are used to load a driver, set up a connection or manage global module specific state. All services are automatically loaded and managed by Core. This ensures the right service order of initialization, runtime state and closing. When designing a module using a service make sure to export the service using the 'NAP_SERVICE_MODULE' #define in a source file exactly once, for example:
This code snippet ensures that core automatically loads, creates and initializes the service when loading the modules.
Service | ( | ServiceConfiguration * | configuration | ) |
|
virtual |
|
protectedvirtual |
Invoked when the service has been constructed and Core is available. This occurs before service initialization
Reimplemented in PortalService, and APIWebSocketService.
|
protected |
Retrieve the ServiceConfiguration for this service. Will be null if this service does not support configuration
|
protected |
Retrieve the ServiceConfiguration for this service. Will be null if this service does not support configuration
Core& getCore | ( | ) |
const Core& getCore | ( | ) | const |
|
protectedvirtual |
Override this function to register service dependencies A service that depends on another service is initialized after all it's associated dependencies This will ensure correct order of initialization, update calls and shutdown of all services
dependencies | rtti information of the services this service depends on |
Reimplemented in RenderService, IMGuiService, ParameterGUIService, SequenceServiceAudio, SDLInputService, APIWebSocketService, PortalService, EtherDreamService, VideoService, SequenceGUIService, and SequenceAudioGUIService.
|
protected |
Returns the (absolute) path to the .ini file associated with this service. Note that this call does not create the .ini directory if it does not exist. The .ini file is used to (re)-store settings in between sessions
|
protected |
Returns the (absolute) path to the .ini file associated with this service. Note that this call does not create the .ini directory if it does not exist. The .ini file is used to (re)-store settings in between sessions
appendix | additional name, attached to the end of the file-name |
const Module& getModule | ( | ) | const |
std::string getTypeName | ( | ) | const |
|
protectedvirtual |
Invoked by core after initializing the core engine. When called all modules this service depends on have been initialized Override this method to initialize your service.
error | should contain the error message when initialization fails |
Reimplemented in IMGuiService, APIService, LicenseService, SDLInputService, UDPService, FontService, SOEMService, SerialService, RenderService, SequenceGUIService, SequenceService, AudioService, ParameterGUIService, CVService, SequenceAudioGUIService, TweenService, EtherDreamService, OSCService, SequenceServiceAudio, GpioService, MidiService, VideoService, WebSocketService, and APIWebSocketService.
|
protectedvirtual |
Invoked after the resource manager successfully loaded resources
Reimplemented in RenderService, and ParameterService.
|
protectedvirtual |
Invoked by core in the app loop. Update order depends on service dependency This call is invoked after the application update call
deltaTime | the time in seconds between calls |
Reimplemented in IMGuiService, SceneService, and InputService.
|
protectedvirtual |
Invoked when the resource manager is about to load resources
Reimplemented in RenderService.
|
protectedvirtual |
Invoked when exiting the main loop, after app shutdown is called This is called before shutdown() and before the resources are destroyed. Use this function if your service needs to reset its state before resources are destroyed When service B depends on A, Service B is shutdown before A
Reimplemented in RenderService, and IMGuiService.
|
protectedvirtual |
Invoked by core in the app loop. Update order depends on service dependency. This call is invoked before the resource manager checks for file changes and the app update call If service B depends on A, A::update() is called before B::update()
deltaTime | the time in seconds between calls |
|
protectedvirtual |
Override this function to register specific object creators for classes associated with this module
factory | the factory used by the resource manager to instantiate objects |
Reimplemented in MidiService, GpioService, IMGuiService, SequenceGUIService, SequenceService, AudioService, CVService, SequenceAudioGUIService, ArtNetService, TweenService, APIWebSocketService, PortalService, FontService, VideoService, OSCService, EtherDreamService, SequenceServiceAudio, WebSocketService, SceneService, UDPService, and PythonScriptService.
|
protectedvirtual |
Invoked when exiting the main loop, after app shutdown is called Use this function to close service specific handles, drivers or devices When service B depends on A, Service B is shutdown before A
Reimplemented in RenderService, IMGuiService, APIService, AudioService, GpioService, TweenService, SDLInputService, EtherDreamService, UDPService, FontService, SerialService, and YoctoService.
|
protectedvirtual |
Invoked by core in the app loop. Update order depends on service dependency This call is invoked after the resource manager has loaded any file changes but before the app update call. If service B depends on A, A:s:update() is called before B::update()
deltaTime | the time in seconds between calls |
Reimplemented in RenderService, IMGuiService, APIService, SequenceService, MidiService, CVService, TweenService, PortalService, ArtNetService, OSCService, SequenceServiceAudio, UDPService, WebSocketService, SceneService, and VideoService.