From d8ce76f85a4fa09959b2c82008db014f078bc23e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96zg=C3=BCr?= Date: Mon, 9 Dec 2024 17:41:58 +0300 Subject: [PATCH] refactoring --- HephCommon/HeaderFiles/Complex.h | 2 +- HephCommon/HeaderFiles/ConsoleLogger.h | 83 +++++++++++++++++++++++++- HephCommon/HeaderFiles/Stopwatch.h | 4 +- HephCommon/HeaderFiles/UserEventArgs.h | 3 +- 4 files changed, 86 insertions(+), 6 deletions(-) diff --git a/HephCommon/HeaderFiles/Complex.h b/HephCommon/HeaderFiles/Complex.h index 92acc02a..e0a702c2 100644 --- a/HephCommon/HeaderFiles/Complex.h +++ b/HephCommon/HeaderFiles/Complex.h @@ -145,7 +145,7 @@ namespace Heph constexpr bool operator!=(const Complex& rhs) const { - return this->real != rhs.real || this->imag != rhs.imag; + return !((*this) == rhs); } /** diff --git a/HephCommon/HeaderFiles/ConsoleLogger.h b/HephCommon/HeaderFiles/ConsoleLogger.h index 83671761..11dcea64 100644 --- a/HephCommon/HeaderFiles/ConsoleLogger.h +++ b/HephCommon/HeaderFiles/ConsoleLogger.h @@ -14,7 +14,7 @@ namespace Heph { /** * @brief class for printing formatted messages to the console. - * @note this class cannot be instantiated. + * @note this is a static class and cannot be instantiated. */ class HEPH_API ConsoleLogger final { @@ -34,26 +34,105 @@ namespace Heph /** * prints the provided message to the console. * + * @param message message that will be printed. * @param logLevel one of the HEPH_CL_* macros. + * */ static void Log(const std::string& message, const char* logLevel); /** * prints the provided message to the console. * - * @param logLevel one of the HEPH_CL_* macros. + * @param message message that will be printed. + * @param logLevel one of the HEPH_CL_* macros. * @param libName name of the library thats printing. The default value is "HephLibs". + * */ static void Log(const std::string& message, const char* logLevel, const std::string& libName); + + /** + * prints the provided message to the console as INFO. + * + * @param message message that will be printed. + * + */ static void LogInfo(const std::string& message); + + /** + * prints the provided message to the console as INFO. + * + * @param message message that will be printed. + * @param libName name of the library thats printing. The default value is "HephLibs". + * + */ static void LogInfo(const std::string& message, const std::string& libName); + + /** + * prints the provided message to the console as WARNING. + * + * @param message message that will be printed. + * + */ static void LogWarning(const std::string& message); + + /** + * prints the provided message to the console as WARNING. + * + * @param message message that will be printed. + * @param libName name of the library thats printing. The default value is "HephLibs". + * + */ static void LogWarning(const std::string& message, const std::string& libName); + + /** + * prints the provided message to the console as ERROR. + * + * @param message message that will be printed. + * + */ static void LogError(const std::string& message); + + /** + * prints the provided message to the console as ERROR. + * + * @param message message that will be printed. + * @param libName name of the library thats printing. The default value is "HephLibs". + * + */ static void LogError(const std::string& message, const std::string& libName); + + /** + * prints the provided message to the console as SUCCESS. + * + * @param message message that will be printed. + * + */ static void LogSuccess(const std::string& message); + + /** + * prints the provided message to the console as SUCCESS. + * + * @param message message that will be printed. + * @param libName name of the library thats printing. The default value is "HephLibs". + * + */ static void LogSuccess(const std::string& message, const std::string& libName); + + /** + * prints the provided message to the console as DEBUG. + * + * @param message message that will be printed. + * + */ static void LogDebug(const std::string& message); + + /** + * prints the provided message to the console as DEBUG. + * + * @param message message that will be printed. + * @param libName name of the library thats printing. The default value is "HephLibs". + * + */ static void LogDebug(const std::string& message, const std::string& libName); /** diff --git a/HephCommon/HeaderFiles/Stopwatch.h b/HephCommon/HeaderFiles/Stopwatch.h index 671741dc..4f5bc4e7 100644 --- a/HephCommon/HeaderFiles/Stopwatch.h +++ b/HephCommon/HeaderFiles/Stopwatch.h @@ -25,7 +25,7 @@ * gets the elapsed time since the last reset of the thread local Stopwatch instance in seconds. * */ -#define HEPH_SW_DT_S Heph::Stopwatch::GetInstance().DeltaTime() +#define HEPH_SW_DT_S HEPH_SW_DT /** * gets the elapsed time since the last reset of the thread local Stopwatch instance in milliseconds. @@ -75,7 +75,7 @@ namespace Heph /** * gets the elapsed time since the last reset. * - * @param prefix the desired metric prefix. + * @param prefix the metric prefix of the time unit. */ double DeltaTime(double prefix) const; diff --git a/HephCommon/HeaderFiles/UserEventArgs.h b/HephCommon/HeaderFiles/UserEventArgs.h index d5e9fb85..fbb2f93e 100644 --- a/HephCommon/HeaderFiles/UserEventArgs.h +++ b/HephCommon/HeaderFiles/UserEventArgs.h @@ -10,7 +10,8 @@ namespace Heph /** * @brief class for passing custom data to the event handlers as key/value pairs. * - * @important This class only stores the pointers to the arguments. So it's your responsibility to ensure that the arguments still exist when handling the events. + * @important This class only stores the pointers to the arguments. + * Thus you have to ensure that the arguments still exist when handling the events. * */ class HEPH_API UserEventArgs final