ezEngine  Milestone 9
Application.h
Go to the documentation of this file.
1 #pragma once
2 
4 
5 #include <Core/Application/Implementation/ApplicationEntryPoint.h>
6 #include <Core/CoreDLL.h>
7 #include <Foundation/Utilities/CommandLineUtils.h>
8 
9 class ezApplication;
10 
16 EZ_CORE_DLL void ezRun(ezApplication* pApplicationInstance);
17 
19 EZ_CORE_DLL void ezRun_Startup(ezApplication* pApplicationInstance);
21 EZ_CORE_DLL void ezRun_MainLoop(ezApplication* pApplicationInstance);
23 EZ_CORE_DLL void ezRun_Shutdown(ezApplication* pApplicationInstance);
24 
62 class EZ_CORE_DLL ezApplication
63 {
64  EZ_DISALLOW_COPY_AND_ASSIGN(ezApplication);
65 
66 public:
69  {
71  Quit,
72  };
73 
75  ezApplication(const char* szAppName);
76 
78  virtual ~ezApplication();
79 
81  void SetApplicationName(const char* szAppName);
82 
84  const ezString& GetApplicationName() const { return m_sAppName; }
85 
91  virtual void BeforeCoreSystemsStartup();
92 
98  virtual void AfterCoreSystemsStartup() {}
99 
108 
111 
117  virtual void BeforeCoreSystemsShutdown() {}
118 
122  virtual void AfterCoreSystemsShutdown() {}
123 
130  virtual void BeforeEnterBackground() {}
131 
137  virtual void BeforeEnterForeground() {}
138 
142  virtual ApplicationExecution Run() = 0;
143 
147  inline void SetReturnCode(ezInt32 iReturnCode) { m_iReturnCode = iReturnCode; }
148 
150  inline ezInt32 GetReturnCode() const { return m_iReturnCode; }
151 
153  virtual const char* TranslateReturnCode() const { return ""; }
154 
157  void SetCommandLineArguments(ezUInt32 uiArgumentCount, const char** ppArguments);
158 
160  static ezApplication* GetApplicationInstance() { return s_pApplicationInstance; }
161 
165  ezUInt32 GetArgumentCount() const { return m_uiArgumentCount; }
166 
168  const char* GetArgument(ezUInt32 uiArgument) const;
169 
171  const char** GetArgumentsArray() const { return m_ppArguments; }
172 
173  void EnableMemoryLeakReporting(bool bEnable) { m_bReportMemoryLeaks = bEnable; }
174 
175  bool IsMemoryLeakReportingEnabled() const { return m_bReportMemoryLeaks; }
176 
177 private:
178  ezInt32 m_iReturnCode;
179 
180  ezUInt32 m_uiArgumentCount;
181 
182  const char** m_ppArguments;
183 
184  bool m_bReportMemoryLeaks;
185 
186  ezString m_sAppName;
187 
188  static ezApplication* s_pApplicationInstance;
189 
190  friend EZ_CORE_DLL void ezRun(ezApplication* pApplicationInstance);
191  friend EZ_CORE_DLL void ezRun_Startup(ezApplication* pApplicationInstance);
192  friend EZ_CORE_DLL void ezRun_MainLoop(ezApplication* pApplicationInstance);
193  friend EZ_CORE_DLL void ezRun_Shutdown(ezApplication* pApplicationInstance);
194 };
195 
ezInt32 GetReturnCode() const
Returns the currently set value that the application will return to the OS.
Definition: Application.h:150
The &#39;Run&#39; function should return this to keep the application running.
Definition: Application.h:70
virtual void BeforeHighLevelSystemsShutdown()
This function is called after the application main loop has run for the last time, before engine deinitialization.
Definition: Application.h:107
EZ_CORE_DLL void ezRun_Shutdown(ezApplication *pApplicationInstance)
[internal] Called by ezRun()
Definition: MainLoop.cpp:31
virtual void BeforeEnterForeground()
This function is called whenever an application is resumed from background mode.
Definition: Application.h:137
static ezApplication * GetApplicationInstance()
Returns the one instance of ezApplication that is available.
Definition: Application.h:160
virtual void AfterCoreSystemsShutdown()
This function is called after ezStartup::ShutdownCoreSystems() has been called.
Definition: Application.h:122
virtual void AfterHighLevelSystemsShutdown()
Called after ezStartup::ShutdownHighLevelSystems() has been executed.
Definition: Application.h:110
virtual void BeforeEnterBackground()
This function is called when an application is moved to the background.
Definition: Application.h:130
ApplicationExecution
Defines the possible return values for the ezApplication::Run() function.
Definition: Application.h:68
virtual const char * TranslateReturnCode() const
If the return code is not zero, this function might be called to get a string to print the error code...
Definition: Application.h:153
The &#39;Run&#39; function should return this to quit the application.
Definition: Application.h:71
const char ** GetArgumentsArray() const
Returns the complete array of command line arguments that were passed to the application.
Definition: Application.h:171
virtual void AfterCoreSystemsStartup()
This function is called after basic engine initialization has been done.
Definition: Application.h:98
EZ_CORE_DLL void ezRun_MainLoop(ezApplication *pApplicationInstance)
[internal] Called by ezRun()
Definition: MainLoop.cpp:24
Base class to be used by applications based on ezEngine.
Definition: Application.h:62
void SetReturnCode(ezInt32 iReturnCode)
Sets the value that the application will return to the OS. You can call this function at any point du...
Definition: Application.h:147
virtual void BeforeCoreSystemsShutdown()
This function is called after the application main loop has run for the last time, before engine deinitialization.
Definition: Application.h:117
ezUInt32 GetArgumentCount() const
Returns the number of command lien arguments that were passed to the application. ...
Definition: Application.h:165
EZ_CORE_DLL void ezRun(ezApplication *pApplicationInstance)
Platform independent run function for main loop based systems (e.g. Win32, ..)
Definition: MainLoop.cpp:60
EZ_CORE_DLL void ezRun_Startup(ezApplication *pApplicationInstance)
[internal] Called by ezRun()
Definition: MainLoop.cpp:6
const ezString & GetApplicationName() const
Returns the application name.
Definition: Application.h:84