i6engine  1.0
EngineController.h
Go to the documentation of this file.
1 /*
2  * i6engine
3  * Copyright (2016) Daniel Bonrath, Michael Baer, All rights reserved.
4  *
5  * This file is part of i6engine; i6engine is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
25 #ifndef __I6ENGINE_API_ENGINECONTROLLER_H__
26 #define __I6ENGINE_API_ENGINECONTROLLER_H__
27 
28 #include <map>
29 #include <set>
30 #include <thread>
31 
33 
34 #if ISIXE_MPLATFORM == ISIXE_MPLATFORM_WIN32
35  #include <tchar.h>
36  #include <Windows.h>
37 #endif
38 
40 #include "i6engine/utils/Logger.h"
41 
43 
44 #include "boost/function.hpp"
45 
46 #include "clockUtils/iniParser/iniParser.h"
47 
48 namespace i6e {
49 namespace core {
50  class EngineCoreController;
51  class MessagingController;
52  class ModuleController;
53  class SubSystemController;
54  enum class Subsystem;
55 } /* namespace core */
56 namespace api {
57 
58  class Application;
59  class AudioFacade;
60  class GraphicsFacade;
61  class GUIFacade;
62  class IDManager;
63  class InputFacade;
64  class LanguageManager;
65  class MessagingFacade;
66  class NetworkFacade;
67  class ObjectFacade;
68  class PhysicsFacade;
69  class ScriptingFacade;
70  class TextManager;
71  class WaynetManager;
72 
73  enum class GameType {
75  CLIENT,
76  SERVER
77  };
78 
84 #ifdef ISIXE_WITH_LOGGING
85  class ISIXE_MODULES_API EngineController : public utils::Singleton<EngineController, utils::Logger, utils::exceptions::ExceptionQueue> {
86  friend class utils::Singleton<EngineController, utils::Logger, utils::exceptions::ExceptionQueue>;
87 #else
88  class ISIXE_MODULES_API EngineController : public utils::Singleton<EngineController, utils::exceptions::ExceptionQueue> {
89  friend class utils::Singleton<EngineController, utils::exceptions::ExceptionQueue>;
90 #endif
91 
92  public:
97 
109  void registerSubSystem(const std::string & name, core::ModuleController * module, uint32_t frameTime);
110  void registerSubSystem(const std::string & name, core::ModuleController * module, const std::set<core::Subsystem> & waitingFor);
111 
112  inline AudioFacade * getAudioFacade() const {
113  return _audioFacade;
114  }
115 
117  return _graphicsFacade;
118  }
119 
120  inline GUIFacade * getGUIFacade() const {
121  return _guiFacade;
122  }
123 
124  inline InputFacade * getInputFacade() const {
125  return _inputFacade;
126  }
127 
129  return _messagingFacade;
130  }
131 
132  inline NetworkFacade * getNetworkFacade() const {
133  return _networkFacade;
134  }
135 
136  inline ObjectFacade * getObjectFacade() const {
137  return _objectFacade;
138  }
139 
140  inline PhysicsFacade * getPhysicsFacade() const {
141  return _physicsFacade;
142  }
143 
145  return _scriptingFacade;
146  }
147 
149  return _idManager;
150  }
151 
153  return _languageManager;
154  }
155 
157  return _textManager;
158  }
159 
161  return _waynetManager;
162  }
163 
168  void registerApplication(Application & app);
169 
173  void start();
174 
175  inline void setType(GameType type) {
176  _type = type;
177  }
178 
182  inline void setDebugdrawer(const uint8_t dd) {
183  _debugdrawer = dd;
184  }
185 
189  inline uint8_t getDebugdrawer() const {
190  return _debugdrawer;
191  }
192 
196  inline Application * getAppl() const { return _appl; }
197 
201  void registerDefault(const bool ds) {
202  registerDefault(ds, nullptr);
203  }
204 
208  void registerDefault(const bool ds, HWND hWnd);
209 
213  void stop();
214 
218  void reset();
219 
221  return _coreController;
222  }
223 
231  uint64_t registerTimer(uint64_t time, const boost::function<bool(void)> & func, bool looping, core::JobPriorities priority);
232 
236  void removeTimer(core::JobPriorities priority);
237 
241  bool removeTimerID(uint64_t id);
242 
246  uint64_t getTimeLeft(uint64_t id) const;
247 
251  uint64_t getCurrentTime() const;
252 
256  void setCurrentTime(uint64_t time);
257 
261  inline uint64_t getUUID() const {
262  return _uuid;
263  }
264 
268  uint64_t getNewUUID() const;
269 
273  inline clockUtils::iniParser::IniParser & getIniParser() {
274  return _iParser;
275  }
276 
280  GameType getType() const {
281  return _type;
282  }
283 
284 #if ISIXE_MPLATFORM == ISIXE_MPLATFORM_WIN32
285 
288  HWND createWindow(HINSTANCE hInstance);
289 #endif
290 
294  void enableCommandLineReader();
295 
296  private:
297  std::map<std::string, std::pair<core::ModuleController *, uint32_t>> _queuedModules;
298  std::map<std::string, std::pair<core::ModuleController *, std::set<core::Subsystem>>> _queuedModulesWaiting;
299  core::SubSystemController * _subsystemController;
300  core::EngineCoreController * _coreController;
301  IDManager * _idManager;
302  LanguageManager * _languageManager;
303  TextManager * _textManager;
304  WaynetManager * _waynetManager;
305  Application * _appl;
306  uint8_t _debugdrawer;
307 
308  AudioFacade * _audioFacade;
309  GraphicsFacade * _graphicsFacade;
310  GUIFacade * _guiFacade;
311  InputFacade * _inputFacade;
312  MessagingFacade * _messagingFacade;
313  NetworkFacade * _networkFacade;
314  ObjectFacade * _objectFacade;
315  PhysicsFacade * _physicsFacade;
316  ScriptingFacade * _scriptingFacade;
317 
318  core::MessagingController * _messagingController;
319 
320  uint64_t _uuid;
321 
325  clockUtils::iniParser::IniParser _iParser;
326 
327  GameType _type;
328 
329  bool _running;
330  std::thread _commandLineReadThread;
331 
336 
342  void runEngine();
343 
347  void ShutDown();
348 
352  EngineController(const EngineController &) = delete;
353 
357  EngineController & operator=(const EngineController &) = delete;
358  };
359 
360 } /* namespace api */
361 } /* namespace i6e */
362 
363 #define i6eEngineController i6e::api::EngineController::GetSingletonPtr()
364 #define i6eAppl i6e::api::EngineController::GetSingletonPtr()->getAppl()
365 #define i6eAudioFacade i6e::api::EngineController::GetSingletonPtr()->getAudioFacade()
366 #define i6eGraphicsFacade i6e::api::EngineController::GetSingletonPtr()->getGraphicsFacade()
367 #define i6eGUIFacade i6e::api::EngineController::GetSingletonPtr()->getGUIFacade()
368 #define i6eInputFacade i6e::api::EngineController::GetSingletonPtr()->getInputFacade()
369 #define i6eMessagingFacade i6e::api::EngineController::GetSingletonPtr()->getMessagingFacade()
370 #define i6eNetworkFacade i6e::api::EngineController::GetSingletonPtr()->getNetworkFacade()
371 #define i6eObjectFacade i6e::api::EngineController::GetSingletonPtr()->getObjectFacade()
372 #define i6ePhysicsFacade i6e::api::EngineController::GetSingletonPtr()->getPhysicsFacade()
373 #define i6eScriptingFacade i6e::api::EngineController::GetSingletonPtr()->getScriptingFacade()
374 
375 #endif /* __I6ENGINE_API_ENGINECONTROLLER_H__ */
376 
Derive from this templated class to make a class a singleton. Refer to the Singleton Design Pattern i...
Definition: Singleton.h:44
This class is used as the Controller for the whole engine Create an instance of this class and use th...
GUIFacade * getGUIFacade() const
LanguageManager * getLanguageManager() const
void setDebugdrawer(const uint8_t dd)
sets level of the debug drawer
Application * getAppl() const
returns the registered Application
#define ISIXE_MODULES_API
WaynetManager * getWaynetManager() const
handles Texts for the Game
Definition: TextManager.h:41
This class manages the GUIWindows and provides some general API methods that aren't related to a spec...
Definition: GUIFacade.h:49
IDManager * getIDManager() const
Physics specific functions for the game which targets the whole world - not a single object...
Definition: PhysicsFacade.h:42
TextManager * getTextManager() const
Central controller for messaging between subsystems and subsystems of different clients.
void setType(GameType type)
Implements a queue that supports multiple producers but only one consumer.
this class is used as an abstraction layer
Interface for the game developer.
Definition: Application.h:50
uint64_t getUUID() const
returns the uuid of this node
uint8_t getDebugdrawer() const
gets level of the debug drawer
handles IDs for GameObjects
Definition: IDManager.h:38
core::EngineCoreController * getController() const
GraphicsFacade * getGraphicsFacade() const
handles the current Waynet
Definition: WaynetManager.h:45
void * HWND
MessagingFacade * getMessagingFacade() const
InputFacade * getInputFacade() const
void registerDefault(const bool ds)
registers a basic default configuration
ScriptingFacade * getScriptingFacade() const
clockUtils::iniParser::IniParser & getIniParser()
returns the iniParser that parsed the i6engine config file
ObjectFacade * getObjectFacade() const
NetworkFacade * getNetworkFacade() const
PhysicsFacade * getPhysicsFacade() const
handles the current language of the Game a change of the language notifies all registered callbacks ...
GameType getType() const
returns the type of this node
This class is used as an abstraction layer.