Ocular Engine
OcularEngine.hpp
1 
17 #ifndef __H__OCULAR_ENGINE__H__
18 #define __H__OCULAR_ENGINE__H__
19 
20 #include "Common.hpp"
21 
22 #include "Logger/Logger.hpp"
23 #include "Time/Clock.hpp"
24 #include "Events/EventManager.hpp"
25 #include "Input/InputHandler.hpp"
26 #include "Renderer/Window/WindowManager.hpp"
27 #include "Utilities/HashGenerator.hpp"
28 #include "Utilities/StringUtils.hpp"
29 #include "Utilities/Config.hpp"
30 #include "Resources/ResourceManager.hpp"
31 #include "Performance/Profiler.hpp"
32 #include "Scene/SceneManager.hpp"
33 #include "Scene/Camera/CameraManager.hpp"
34 #include "Scene/Light/LightManager.hpp"
35 #include "Graphics/GraphicsDriver.hpp"
36 #include "Threads/ThreadManager.hpp"
37 
38 //------------------------------------------------------------------------------------------
39 
44 namespace Ocular
45 {
50  {
51  public:
52 
53  static Engine& get();
54  ~Engine();
55 
70 
76  bool shutdown();
77 
81  bool isRunning() const;
82 
97  bool run();
98 
99  //----------------------------------------------------------------------------------
100  // Core Subsystem Retrieval
101 
105  std::shared_ptr<Core::Logger> Logger() const;
106 
110  std::shared_ptr<Core::Clock> Clock() const;
111 
115  std::shared_ptr<Core::EventManager> EventManager() const;
116 
120  std::shared_ptr<Core::WindowManager> WindowManager() const;
121 
125  std::shared_ptr<Core::ThreadManager> ThreadManager() const;
126 
130  std::shared_ptr<Utils::HashGenerator> HashGenerator() const;
131 
135  std::shared_ptr<Utils::String> StringUtils() const;
136 
140  std::shared_ptr<Utils::Config> Config() const;
141 
145  std::shared_ptr<Core::ResourceManager> ResourceManager() const;
146 
150  std::shared_ptr<Core::SceneManager> SceneManager() const;
151 
155  std::shared_ptr<Core::CameraManager> CameraManager() const;
156 
160  std::shared_ptr<Core::LightManager> LightManager() const;
161 
165  std::shared_ptr<Core::Profiler> Profiler() const;
166 
170  std::shared_ptr<Core::InputHandler> Input() const;
171 
175  std::shared_ptr<Graphics::GraphicsDriver> GraphicsDriver() const;
176 
177  //----------------------------------------------------------------------------------
178 
179  protected:
180 
181  virtual bool onEvent(std::shared_ptr<Core::AEvent> event);
182 
183  private:
184 
185  Engine();
186  Engine(Engine const&) = delete;
187  void operator=(Engine const&) = delete;
188 
189  // Running
190 
191  void update();
192  void render();
193 
194  // Setup
195 
196  void setupLogger();
197  void setupEvents();
198  void setupConfig();
199  void createDefaultConfig();
200 
201  void shutdownWindowManager();
202 
203  //--------------------------------------------
204 
205  std::shared_ptr<Core::Clock> m_Clock;
206  std::shared_ptr<Core::EventManager> m_EventManager;
207  std::shared_ptr<Core::InputHandler> m_InputHandler;
208  std::shared_ptr<Core::Logger> m_Logger;
209  std::shared_ptr<Core::ResourceManager> m_ResourceManager;
210  std::shared_ptr<Core::SceneManager> m_SceneManager;
211  std::shared_ptr<Core::CameraManager> m_CameraManager;
212  std::shared_ptr<Core::LightManager> m_LightManager;
213  std::shared_ptr<Core::WindowManager> m_WindowManager;
214  std::shared_ptr<Core::ThreadManager> m_ThreadManager;
215  std::shared_ptr<Utils::HashGenerator> m_HashGenerator;
216  std::shared_ptr<Utils::String> m_StringUtils;
217  std::shared_ptr<Utils::Config> m_Config;
218  std::shared_ptr<Core::Profiler> m_Profiler;
219  std::shared_ptr<Graphics::GraphicsDriver> m_GraphicsDriver;
220 
221  bool m_IsRunning;
222  };
223 }
228 #define OcularEngine Ocular::Engine::get()
229 #define OcularLogger OcularEngine.Logger()
230 #define OcularClock OcularEngine.Clock()
231 #define OcularScene OcularEngine.SceneManager()
232 #define OcularCameras OcularEngine.CameraManager()
233 #define OcularLights OcularEngine.LightManager()
234 #define OcularEvents OcularEngine.EventManager()
235 #define OcularInput OcularEngine.Input()
236 #define OcularResources OcularEngine.ResourceManager()
237 #define OcularWindows OcularEngine.WindowManager()
238 #define OcularThreads OcularEngine.ThreadManager()
239 #define OcularProfiler OcularEngine.Profiler()
240 #define OcularGraphics OcularEngine.GraphicsDriver()
241 #define OcularString OcularEngine.StringUtils()
242 #define OcularConfig OcularEngine.Config()
243 
245 #define OCULAR_INTERNAL_LOG(a,b) " [", a, "::", b, " @ ", __LINE__, "]"
246 // Example usage:
247 // OcularLogger->error("Some error message", OCULAR_INTERNAL_LOG("ClassWithError", "MethodWithError"));
248 // Outputs: "Some error message [ClassWithError::MethodWithError @ 220]"
249 
250 #endif
std::shared_ptr< Core::Clock > Clock() const
Definition: OcularEngine.cpp:128
Definition: OcularEngine.hpp:49
std::shared_ptr< Utils::HashGenerator > HashGenerator() const
Definition: OcularEngine.cpp:153
std::shared_ptr< Graphics::GraphicsDriver > GraphicsDriver() const
Definition: OcularEngine.cpp:193
bool isRunning() const
Definition: OcularEngine.cpp:198
std::shared_ptr< Core::ThreadManager > ThreadManager() const
Definition: OcularEngine.cpp:148
std::shared_ptr< Core::Profiler > Profiler() const
Definition: OcularEngine.cpp:188
Definition: AEventListener.hpp:43
std::shared_ptr< Core::ResourceManager > ResourceManager() const
Definition: OcularEngine.cpp:168
std::shared_ptr< Core::CameraManager > CameraManager() const
Definition: OcularEngine.cpp:178
bool run()
Definition: OcularEngine.cpp:112
Note: Once this library is made dynamic, this will no longer be needed.
Definition: Common.hpp:70
std::shared_ptr< Utils::String > StringUtils() const
Definition: OcularEngine.cpp:158
std::shared_ptr< Core::InputHandler > Input() const
Definition: OcularEngine.cpp:138
std::shared_ptr< Core::WindowManager > WindowManager() const
Definition: OcularEngine.cpp:143
std::shared_ptr< Core::LightManager > LightManager() const
Definition: OcularEngine.cpp:183
std::shared_ptr< Utils::Config > Config() const
Definition: OcularEngine.cpp:163
std::shared_ptr< Core::EventManager > EventManager() const
Definition: OcularEngine.cpp:133
bool shutdown()
Definition: OcularEngine.cpp:105
std::shared_ptr< Core::Logger > Logger() const
Definition: OcularEngine.cpp:123
bool initialize(Graphics::GraphicsDriver *driver)
Definition: OcularEngine.cpp:82
std::shared_ptr< Core::SceneManager > SceneManager() const
Definition: OcularEngine.cpp:173
Definition: GraphicsDriver.hpp:59