NAP
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
 
void setFramerate (float fps)
 

Detailed 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 argumentshould 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.

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= ( const AppRunner< APP, HANDLER > &  )
delete

◆ operator=() [2/2]

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

◆ setFramerate()

void setFramerate ( float  fps)

Limits execution speed of the application. This causes the application to sleep in between calls when execution speed exceeds the set framerate. The final execution speed may vary from platform to platform, based on the accuracy of the timers, but will always be less than the given framerate. Not setting any framerate allows the app to run at full speed (default)

Parameters
fpsthe maximum allowed refresh rate in frames per second

◆ 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