NAP
BaseApp Class Reference

#include <app.h>

Public Member Functions

 BaseApp (nap::Core &core)
 
virtual ~BaseApp ()=default
 
 BaseApp (BaseApp &)=delete
 
BaseAppoperator= (const BaseApp &)=delete
 
 BaseApp (BaseApp &&)=delete
 
BaseAppoperator= (BaseApp &&)=delete
 
virtual bool init (utility::ErrorState &error)
 
virtual void update (double deltaTime)
 
virtual void render ()
 
virtual bool shutdownRequested ()
 
virtual int shutdown ()
 
void quit ()
 
const nap::CoregetCore () const
 
nap::CoregetCore ()
 
bool shouldQuit () const
 

Detailed Description

Acts as a blueprint for all NAP applications. This class does not receive any input events. Every application holds a reference to a Core object. The init, update, render and shutdown functions are called from within the main loop by the AppRunner.

Inheritance diagram for BaseApp:
[legend]

Constructor & Destructor Documentation

◆ BaseApp() [1/3]

BaseApp ( nap::Core core)

◆ ~BaseApp()

virtual ~BaseApp ( )
virtualdefault

◆ BaseApp() [2/3]

BaseApp ( BaseApp )
delete

Copy is not allowed

◆ BaseApp() [3/3]

BaseApp ( BaseApp &&  )
delete

Move is not allowed

Member Function Documentation

◆ getCore() [1/2]

const nap::Core& getCore ( ) const
Returns
nap Core const

◆ getCore() [2/2]

nap::Core& getCore ( )
Returns
nap Core

◆ init()

virtual bool init ( utility::ErrorState error)
virtual

Initialize your application. Occurs after all the modules have been loaded and services have been initialized. If this call is unsuccessful the application will not continue execution

Parameters
errorcontains the error when initialization fails
Returns
if initialization was successful

◆ operator=() [1/2]

BaseApp& operator= ( const BaseApp )
delete

◆ operator=() [2/2]

BaseApp& operator= ( BaseApp &&  )
delete

◆ quit()

void quit ( )

Call this from your app to terminate the application and exit the main loop.

◆ render()

virtual void render ( )
virtual

Render your application. This is called after update at the end of the loop

◆ shouldQuit()

bool shouldQuit ( ) const
Returns
if the application received a quit event

◆ shutdown()

virtual int shutdown ( )
virtual

Called when the app is shutting down after quit() has been called Use this to clear application specific data. This is called before all the services are closed and the app exits return the application exit code, 0 (success) by default

◆ shutdownRequested()

virtual bool shutdownRequested ( )
virtual

Called by the event handler when it receives an external event to quit the running application By default this calls quit() with the return value of this call, which causes the application to stop running You can override it to ignore the event or perform specific logic (such as saving a file) before the app is shutdown()

Returns
if the application should quit, true by default

◆ update()

virtual void update ( double  deltaTime)
virtual

Update your application. This is called after calling update for all registered services but before render

Parameters
deltaTimethe time in seconds between calls