Enigma 3.2.2
A Simple, Reliable and Efficient Encryption Tool
Loading...
Searching...
No Matches
Application.hpp
Go to the documentation of this file.
1#pragma once
2#ifndef ENIGMA_APPLICATION_H
3#define ENIGMA_APPLICATION_H
4
5#include <Core/Core.hpp>
6#include <Logger/Logger.hpp>
7
8#include <Window/Window.hpp>
9
11#include <Events/KeyEvent.hpp>
12#include <Events/MouseEvent.hpp>
13
15
16#include <cpr/threadpool.h>
17
19
23class ImGuiRenderer;
24class Scene;
25class RAMInfo;
26class CPUInfo;
27
28class Application final : public SingleProcessInstance {
29 public:
33 explicit Application(const WindowSettings& window_settings = WindowSettings());
34 ~Application() override;
35
37 void Run();
38
43 void Exit(const std::string& message, const std::int32_t exit_code) noexcept;
44
51 std::future<void> LaunchWorkerThread(Scene *scene, const std::string& loading_text, const std::function<void()>& work_func);
52
53
54 public: //https://www.doxygen.nl/manual/grouping.html#memgroup
61 void OnEvent(Event& event);
68 public: // Accessors
70 static Application *getInstance() noexcept { return m_instance; }
71
73 const std::unique_ptr<Window>& GetWindow() const noexcept { return m_window; }
74
76 void EndApplication() noexcept;
77
81 void PushScene(std::unique_ptr<Scene> scene);
82
84 std::uint32_t GetFPS() const noexcept { return m_FPS ? *m_FPS : 0u; }
85
87 float GetDeltaTime() const noexcept { return m_delta_time; }
88
90 constexpr const std::unique_ptr<RAMInfo>& GetRAMInfo() const noexcept { return m_ram_info; }
91
93 constexpr const std::unique_ptr<CPUInfo>& GetCPUInfo() const noexcept { return m_cpu_info; }
94
95 private: // Updates
97 void UpdateDeltaTime() noexcept;
99 void UpdateHardwareInfo() noexcept;
100
101
102 private: // Initializer Functions
104 void InitWindow(const WindowSettings& window_settings);
106 void InitImGuiRenderer();
108 void InitHardwareInfo(const WindowSettings& window_settings);
110 void InitImGuiFonts();
111
112 private:
113 std::unique_ptr<Window> m_window;
115 private:
116 std::vector<std::unique_ptr<Scene>> m_scenes;
117 std::unique_ptr<Scene> m_loading_scene;
121 private:
122 float m_last_frame_time;
123 float m_current_frame_time;
124 float m_delta_time;
126 private:
127 static constexpr float HARWARE_INFO_UPDATE_TIME = 1.0f;
128 float m_hardware_info_timer;
129 std::unique_ptr<std::uint32_t> m_FPS;
130 std::unique_ptr<RAMInfo> m_ram_info;
131 std::unique_ptr<CPUInfo> m_cpu_info;
133 private:
134 std::unique_ptr<ImGuiRenderer> m_imgui_renderer;
136 private:
137 inline static Application *m_instance{nullptr};
139 private:
140 std::unique_ptr<cpr::ThreadPool> m_threadPool{};
141};
142
144
145#endif // !ENIGMA_APPLICATION_H
#define NS_ENIGMA_BEGIN
Enable/Disable Assertions.
Definition Macros.hpp:13
#define NS_ENIGMA_END
Definition Macros.hpp:14
void OnEvent(Event &event)
Event callbacks.
static Application * getInstance() noexcept
Application(const WindowSettings &window_settings=WindowSettings())
std::uint32_t GetFPS() const noexcept
bool OnWindowResize(WindowResizeEvent &event)
const std::unique_ptr< Window > & GetWindow() const noexcept
~Application() override
std::future< void > LaunchWorkerThread(Scene *scene, const std::string &loading_text, const std::function< void()> &work_func)
Launches detached thread seperated from main UI thread.
constexpr const std::unique_ptr< RAMInfo > & GetRAMInfo() const noexcept
bool OnWindowClose(WindowCloseEvent &event)
void Exit(const std::string &message, const std::int32_t exit_code) noexcept
void PushScene(std::unique_ptr< Scene > scene)
constexpr const std::unique_ptr< CPUInfo > & GetCPUInfo() const noexcept
float GetDeltaTime() const noexcept
void EndApplication() noexcept
bool OnFrameBufferResize(FrameBufferResizeEvent &event)
Single process instance class.