NAP
Public Member Functions | List of all members
AppRunner< APP, HANDLER > Class Template Reference

#include <apprunner.h>

Public Member Functions

 AppRunner (nap::Core &core)
 
virtual ~AppRunner ()
 
 AppRunner (AppRunner &)=delete
 
AppRunneroperator= (const AppRunner &)=delete
 
 AppRunner (AppRunner &&)=delete
 
AppRunneroperator= (AppRunner &&)=delete
 
bool start (utility::ErrorState &error)
 
void stop ()
 
APP & getApp ()
 
HANDLER & getHandler ()
 
int exitCode () const
 

Description

template<typename APP, typename HANDLER>
class nap::AppRunner< APP, HANDLER >

Utility class that runs a nap::BaseApp until BaseApp::quit() is called or AppRunner::stop(). The APP template argument should be derived from nap::BaseApp, HANDLER should be of type nap::BaseAppEventHandler()

When creating an AppRunner 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 the AppRunner owns the app and handler.

On start() the runner initializes nap::Core, together with all available services and loads the application data. If everything succeeds the app loop is started.

Constructor & Destructor Documentation

◆ AppRunner() [1/3]

AppRunner ( nap::Core core)

Constructor

Parameters
corethe nap core this runner uses in conjunction with the app and handler

◆ ~AppRunner()

~AppRunner
virtual

Destructor

◆ AppRunner() [2/3]

AppRunner ( AppRunner< APP, HANDLER > &  )
delete

Copy is not allowed

◆ AppRunner() [3/3]

AppRunner ( AppRunner< APP, HANDLER > &&  )
delete

Move is not allowed

Member Function Documentation

◆ exitCode()

int exitCode ( ) const
Returns
the application exit code

◆ getApp()

APP & getApp
Returns
the app

◆ getHandler()

HANDLER & getHandler
Returns
the app handler

◆ operator=() [1/2]

AppRunner& operator= ( AppRunner< APP, HANDLER > &&  )
delete

◆ operator=() [2/2]

AppRunner& operator= ( const AppRunner< APP, HANDLER > &  )
delete

◆ start()

bool start ( utility::ErrorState error)

Starts the app loop, if the loop could not start for some reason the error contains the reason. This call will initialize core and the application and run the application loop until AppRunner::stop() or BaseApp::quit() is invoked.

Parameters
errorthe error message if the loop couldn't be started
Returns
if the app loop has successfully started

◆ stop()

void stop

Stops the loop and exits the application