NAP
appeventhandler.h
1 #pragma once
2 
3 // Local Includes
4 #include "app.h"
5 
6 // External Includes
7 #include <rtti/typeinfo.h>
8 
9 namespace nap
10 {
15  class NAPAPI AppEventHandler
16  {
17  RTTI_ENABLE()
18  public:
24 
25  // Default Destructor
26  virtual ~AppEventHandler() = default;
27 
32  AppEventHandler& operator=(const AppEventHandler&) = delete;
33 
37  AppEventHandler(AppEventHandler&&) = delete;
38  AppEventHandler& operator=(AppEventHandler&&) = delete;
39 
44  virtual void start() { }
45 
52  virtual void process() { }
53 
57  virtual void shutdown() { }
58 
62  template<typename T>
63  T& getApp();
64 
65  protected:
66  BaseApp& mApp; // The app associated with this app event handler
67  };
68 
69 
71  // Template definitions
73 
74  template<typename T>
76  {
77  assert(mApp.get_type().is_derived_from(RTTI_OF(T)));
78  return static_cast<T&>(mApp);
79  }
80 }
virtual void start()
Definition: appeventhandler.h:44
T & getApp()
Definition: appeventhandler.h:75
Definition: core.h:24
Definition: appeventhandler.h:15
virtual void process()
Definition: appeventhandler.h:52
virtual void shutdown()
Definition: appeventhandler.h:57
BaseApp & mApp
Definition: appeventhandler.h:66
Definition: app.h:17