mainLoop.h

Engine/source/app/mainLoop.h

More...

Classes:

class

Support class to simplify the process of writing a main loop for Torque apps.

Detailed Description

 1
 2//-----------------------------------------------------------------------------
 3// Copyright (c) 2012 GarageGames, LLC
 4//
 5// Permission is hereby granted, free of charge, to any person obtaining a copy
 6// of this software and associated documentation files (the "Software"), to
 7// deal in the Software without restriction, including without limitation the
 8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 9// sell copies of the Software, and to permit persons to whom the Software is
10// furnished to do so, subject to the following conditions:
11//
12// The above copyright notice and this permission notice shall be included in
13// all copies or substantial portions of the Software.
14//
15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21// IN THE SOFTWARE.
22//-----------------------------------------------------------------------------
23
24#ifndef _APP_MAINLOOP_H_
25#define _APP_MAINLOOP_H_
26
27#include "platform/platform.h"
28
29/// Support class to simplify the process of writing a main loop for Torque apps.
30class StandardMainLoop
31{
32public:
33   /// Initialize core libraries and call registered init functions
34   static void init();
35
36   /// Pass command line arguments to registered functions and main.tscript
37   static bool handleCommandLine(S32 argc, const char **argv);
38
39   /// A standard mainloop implementation.
40   static bool doMainLoop();
41
42   /// Shut down the core libraries and call registered shutdown fucntions.
43   static void shutdown();
44
45   /// Gets the return status code of the current process.
46   static S32 getReturnStatus();
47
48   static void setRestart( bool restart );
49   static bool requiresRestart();
50
51private:
52   /// Handle "pre shutdown" tasks like notifying scripts BEFORE we delete
53   /// stuff from under them.
54   static void preShutdown();
55};
56
57#endif
58