SpiecsEngine
 
Loading...
Searching...
No Matches
Console.h
Go to the documentation of this file.
1/**
2* @file Console.h
3* @brief The Console Class Definitions.
4* @author Spices.
5*/
6
7#pragma once
8#include "Core/Core.h"
9
10#include <spdlog/sinks/basic_file_sink.h>
11#include <deque>
12
13namespace Spices {
14
15 /**
16 * @brief Help data of specific level of information.
17 */
19 {
20 /**
21 * @brief Info information.
22 */
23 std::string str;
24
25 /**
26 * @brief specific level of this information.
27 */
28 std::string level;
29
30 /**
31 * @brief specific color of this information.
32 */
34 };
35
36 /**
37 * @brief Console Information Data.
38 */
39 struct InfoData
40 {
41 /**
42 * @brief trace deque.
43 */
45
46 /**
47 * @brief info deque.
48 */
50
51 /**
52 * @brief warn deque.
53 */
55
56 /**
57 * @brief error deque.
58 */
60
61 /**
62 * @brief critical deque.
63 */
65
66 void Clear()
67 {
69
70 m_TraceLogInfos.clear();
71 m_InfoLogInfos.clear();
72 m_WarnLogInfos.clear();
73 m_ErrorLogInfos.clear();
74 m_CriticalLogInfos.clear();
75 }
76 };
77
78 /**
79 * @brief Console Entity Class.
80 */
82 {
83 public:
84
85 /**
86 * @brief Constructor Function.
87 * @param[in] filePath Console output file.
88 * @param[in] maxInfos Maximum Num of Information.
89 */
90 Console(const std::string& filePath, uint32_t maxInfos = 50);
91
92 /**
93 * @brief Destructor Function.
94 */
95 virtual ~Console() override = default;
96
97 /**
98 * @brief Registry a console to ConsolePool.
99 * @param[in] name ConsoleName.
100 * @param[in] filePath Console output file.
101 * @return Returns Registered Console form Pool.
102 */
103 static std::shared_ptr<Console> Registry(
104 const std::string& name,
105 const std::string& filePath = ""
106 );
107
108 /**
109 * @brief Get Console Infos.
110 * @return Returns Console Infos.
111 */
112 const InfoData& GetInfos() const { return m_InfoData; }
113
114 /**
115 * @brief Clear Console Infos.
116 */
117 void Clear();
118
119 /**
120 * @brief Push a Command to Console.
121 * @param[in] cmd Command.
122 * @todo Implemented it.
123 */
124 void Push(const std::string& cmd);
125
126 /**
127 * @brief Get Console output file.
128 * @return Returns Console output file.
129 */
130 const std::string& GetFilePath() { return m_FilePath; }
131
132 protected:
133
134 /**
135 * @brief Inherited from spdlog, run when a message pushed.
136 * @param[in] msg spdlog message.
137 */
138 void sink_it_(const spdlog::details::log_msg& msg) override;
139
140 /**
141 * @brief Inherited from spdlog, run when spdlog flush.
142 */
143 virtual void flush_() override { Clear(); }
144
145 protected:
146
147 /**
148 * @brief Console File Path.
149 */
150 std::string m_FilePath;
151
152 /**
153 * @brief Maximum Num of Information's.
154 */
155 uint32_t m_MaxInfos;
156
157 /**
158 * @brief Console Information.
159 */
161 };
162}
#define SPICES_PROFILE_ZONE
const std::string & GetFilePath()
Get Console output file.
Definition Console.h:130
static std::shared_ptr< Console > Registry(const std::string &name, const std::string &filePath="")
Registry a console to ConsolePool.
Definition Console.cpp:26
Console(const std::string &filePath, uint32_t maxInfos=50)
Constructor Function.
Definition Console.cpp:17
std::string m_FilePath
Console File Path.
Definition Console.h:150
virtual void flush_() override
Inherited from spdlog, run when spdlog flush.
Definition Console.h:143
void Push(const std::string &cmd)
Push a Command to Console.
Definition Console.cpp:45
void Clear()
Clear Console Infos.
Definition Console.cpp:38
void sink_it_(const spdlog::details::log_msg &msg) override
Inherited from spdlog, run when a message pushed.
Definition Console.cpp:53
InfoData m_InfoData
Console Information.
Definition Console.h:160
uint32_t m_MaxInfos
Maximum Num of Information's.
Definition Console.h:155
const InfoData & GetInfos() const
Get Console Infos.
Definition Console.h:112
virtual ~Console() override=default
Destructor Function.
Console Entity Class.
Definition Console.h:82
static std::unordered_map< std::string, std::shared_ptr< Console > > m_GlobalConsolePool
Global Console Pool.
Definition Console.cpp:15
std::deque< InfoLevelHelper > m_InfoLogInfos
info deque.
Definition Console.h:49
std::deque< InfoLevelHelper > m_WarnLogInfos
warn deque.
Definition Console.h:54
std::deque< InfoLevelHelper > m_TraceLogInfos
trace deque.
Definition Console.h:44
std::deque< InfoLevelHelper > m_ErrorLogInfos
error deque.
Definition Console.h:59
std::deque< InfoLevelHelper > m_CriticalLogInfos
critical deque.
Definition Console.h:64
Console Information Data.
Definition Console.h:40
glm::vec4 color
specific color of this information.
Definition Console.h:33
std::string level
specific level of this information.
Definition Console.h:28
std::string str
Info information.
Definition Console.h:23
Help data of specific level of information.
Definition Console.h:19