Leviathan  0.8.0.0
Leviathan game engine
Application.h
Go to the documentation of this file.
1 // Leviathan Game Engine
2 // Copyright (c) 2012-2017 Henri Hyyryläinen
3 #pragma once
4 // ------------------------------------ //
5 #include "Define.h"
6 // ------------------------------------ //
8 #include "Engine.h"
10 
11 namespace Leviathan {
12 
13 class NetworkInterface;
14 
17 public:
18  // creation and initialization //
20 
23 
25 
26  DLLEXPORT virtual bool Initialize(AppDef* configuration);
27 
30  DLLEXPORT void ForceRelease();
31 
34  DLLEXPORT virtual void StartRelease();
35 
39  DLLEXPORT void MarkAsClosing();
40 
41  // perform actions //
42  DLLEXPORT virtual int RunMessageLoop();
45  DLLEXPORT virtual float RunSingleUpdate();
46  DLLEXPORT virtual bool PassCommandLine(int argcount, char* args[]);
47 
48  DLLEXPORT virtual void Tick(float elapsed);
49  DLLEXPORT virtual void PreFirstTick();
50 
51  // getting data from the class //
53  {
54  return Quit;
55  }
56 
58  {
59  return _Engine;
60  }
61 
63  {
65  }
66 
67 
71  DLLEXPORT void ClearTimers();
72 
73  // callback functions called during engine initialization at appropriate times //
74  DLLEXPORT virtual bool InitLoadCustomScriptTypes(asIScriptEngine* engine);
75 
76  DLLEXPORT virtual void CustomizeEnginePostLoad();
77  DLLEXPORT virtual void EnginePreShutdown();
78 
82  DLLEXPORT virtual std::shared_ptr<GameWorld> GetGameWorld(int id);
83 
84  DLLEXPORT virtual NETWORKED_TYPE GetProgramNetType() const = 0;
85 
86  // static access method for getting instance of this class //
88 
89  // Some dummy functions for ease of use //
91  DLLEXPORT static void DummyGameKeyConfigVariables(KeyConfiguration* keyconfigobj);
92 
93  // Utility functions //
94  DLLEXPORT static void StartServerProcess(
95  const std::string& processname, const std::string& commandline);
96 
98  DLLEXPORT static std::vector<std::string> CommandLineStringSplitter(
99  const char* str, std::vector<char*>& argcharstrings, bool addprogramname = true);
100 
101 protected:
104  DLLEXPORT virtual void Release();
105 
108  DLLEXPORT virtual void _InternalInit();
109 
110 
113 
116  virtual void _ShutdownApplicationPacketHandler() = 0;
117 
118 protected:
119  // ------------------------------------ //
120 
121  bool Quit = false;
122  bool ShouldQuit = false;
123 
125  bool QuitSometime = false;
126 
132 
136 
137  // static part //
139 };
140 
141 
142 } // namespace Leviathan
143 
144 #ifdef LEAK_INTO_GLOBAL
146 #endif
virtual DLLEXPORT void EnginePreShutdown()
Allows the inherited object to be locked.
Definition: ThreadSafe.h:137
Holds key configuration for an application.
static DLLEXPORT void DummyGameConfigurationVariables(GameConfiguration *configobj)
static LeviathanApplication * Curapp
Definition: Application.h:138
virtual NetworkInterface * _GetApplicationPacketHandler()=0
Called in Initialize to get the derived packet handler type.
virtual DLLEXPORT int RunMessageLoop()
virtual DLLEXPORT NETWORKED_TYPE GetProgramNetType() const =0
virtual DLLEXPORT void _InternalInit()
The main class of the Leviathan Game Engine.
Definition: Engine.h:37
virtual DLLEXPORT std::shared_ptr< GameWorld > GetGameWorld(int id)
Used to query a world for specific id.
DLLEXPORT void ForceRelease()
Used to immediately terminate the program.
Definition: Application.cpp:92
static DLLEXPORT std::vector< std::string > CommandLineStringSplitter(const char *str, std::vector< char * > &argcharstrings, bool addprogramname=true)
Splits a single string command line into arguments.
virtual DLLEXPORT void PreFirstTick()
virtual DLLEXPORT bool Initialize(AppDef *configuration)
Definition: Application.cpp:39
DLLEXPORT AppDef * GetDefinition()
Definition: Application.h:62
virtual DLLEXPORT ~LeviathanApplication()
Definition: Application.cpp:23
virtual DLLEXPORT void Tick(float elapsed)
DLLEXPORT void MarkAsClosing()
Thread safely marks the game to close sometime.
virtual DLLEXPORT bool PassCommandLine(int argcount, char *args[])
virtual DLLEXPORT void Release()
Performs the final steps in the release process.
Definition: Application.cpp:55
NETWORKED_TYPE
Type of networked application.
Definition: CommonNetwork.h:22
virtual DLLEXPORT bool InitLoadCustomScriptTypes(asIScriptEngine *engine)
DLLEXPORT void ClearTimers()
Resets all time sensitive timers.
static DLLEXPORT void DummyGameKeyConfigVariables(KeyConfiguration *keyconfigobj)
virtual DLLEXPORT void StartRelease()
Safely releases the Application //.
Definition: Application.cpp:83
virtual DLLEXPORT float RunSingleUpdate()
Runs a single engine update cycle (tick + render)
static DLLEXPORT void StartServerProcess(const std::string &processname, const std::string &commandline)
static DLLEXPORT LeviathanApplication * Get()
Definition: Application.cpp:32
DLLEXPORT Engine * GetEngine()
Definition: Application.h:57
virtual void _ShutdownApplicationPacketHandler()=0
#define DLLEXPORT
Definition: Include.h:84
Base class for all leviathan programs.
Definition: Application.h:16
virtual DLLEXPORT void CustomizeEnginePostLoad()
The access mask controls which registered functions and classes a script sees.
Definition: GameModule.h:12
Class that encapsulates common networking functionality that is required by all networked programs.
bool QuitSometime
This can be quickly set anywhere to quit sometime in the future.
Definition: Application.h:125