#include <servicerunner.h>
Public Member Functions | |
ServiceRunner (nap::Core &core) | |
virtual | ~ServiceRunner () |
ServiceRunner (ServiceRunner &)=delete | |
ServiceRunner & | operator= (const ServiceRunner &)=delete |
ServiceRunner (ServiceRunner &&)=delete | |
ServiceRunner & | operator= (ServiceRunner &&)=delete |
bool | init (utility::ErrorState &error) |
void | update () |
int | shutdown () |
int | exitCode () const |
APP & | getApp () |
Core & | getCore () |
const Core & | getCore () const |
HANDLER & | getHandler () |
Utility class that runs a nap::BaseApp as a service. This is useful when a different environment embeds a NAP application as a service that is run in the background. When running an app as a service the app is initialized, updated and stopped from that external environment. Call init() to initialize core, all the services and the app. Call update() to update all services and the app. Call shutdown() on exit to make sure all processes are stopped correctly.
The APP template argument should be derived from nap::BaseApp. The HANDLER template argument should be of type nap::AppEventHandler()
When creating a ServiceRunner with those two template arguments the app is created and invoked at the right time based on core and it's associated services. Note that this object owns the app and handler.
ServiceRunner | ( | nap::Core & | core | ) |
Constructor
core | the nap core this runner uses in conjunction with the app and handler |
|
virtual |
Destructor
|
delete |
Copy is not allowed
|
delete |
Move is not allowed
int exitCode | ( | ) | const |
Returns the application exit code, available after shutdown().
APP & getApp |
Core& getCore | ( | ) |
const Core& getCore | ( | ) | const |
HANDLER & getHandler |
bool init | ( | utility::ErrorState & | error | ) |
This call will initialize core and the application
error | the error message if the initialization failed |
|
delete |
|
delete |
int shutdown |
Call this before exiting your application. Ensures the app is exited and running services are stopped appropiately.
void update |
Call this from an external environment. On update all events are processed, after that update on core is called.