From 5e06f767e9a419f2b1ebe66db9051c2dfbded06b Mon Sep 17 00:00:00 2001 From: Maximilian Kueffner Date: Sun, 17 Aug 2025 21:51:13 +0200 Subject: [PATCH] Some cleanup --- lib/app/AppGLFW.cpp | 2 +- lib/app/AppGLFW.hpp | 8 ++++---- lib/utilities/ILog.hpp | 10 +++++----- lib/utilities/SpdLogger.cpp | 10 +++++----- lib/utilities/SpdLogger.hpp | 10 +++++----- src/MyApp.hpp | 5 ++--- src/main.cpp | 2 +- 7 files changed, 23 insertions(+), 24 deletions(-) diff --git a/lib/app/AppGLFW.cpp b/lib/app/AppGLFW.cpp index aca8c60..77bc66d 100644 --- a/lib/app/AppGLFW.cpp +++ b/lib/app/AppGLFW.cpp @@ -95,7 +95,7 @@ void pixelarium::application::AppGLFW::InitMainWindow() ImGui_ImplOpenGL3_Init(glsl_version); } -int pixelarium::application::AppGLFW::RunInternal() +int pixelarium::application::AppGLFW::RunLoop() { ImGuiIO& io = ImGui::GetIO(); (void)io; diff --git a/lib/app/AppGLFW.hpp b/lib/app/AppGLFW.hpp index 35bcde6..99a53a8 100644 --- a/lib/app/AppGLFW.hpp +++ b/lib/app/AppGLFW.hpp @@ -12,9 +12,9 @@ namespace pixelarium::application class AppGLFW { public: - explicit AppGLFW(std::unique_ptr& log) : logger_(*log) { this->InitMainWindow(); } + explicit AppGLFW(const utils::log::ILog& log) : logger_(log) { this->InitMainWindow(); } - void Start() { this->RunInternal(); } + void Start() { this->RunLoop(); } protected: virtual void MenuBarOptionsColumn1() {} @@ -24,10 +24,10 @@ class AppGLFW virtual void MenuBarOptionsColumn5() {} virtual void Run() {} - utils::log::ILog& logger_; + const utils::log::ILog& logger_; private: - int RunInternal(); + int RunLoop(); void InitMainWindow(); void MenuBar(); void LogLevelSelect(); diff --git a/lib/utilities/ILog.hpp b/lib/utilities/ILog.hpp index be551d9..4f2c1ea 100644 --- a/lib/utilities/ILog.hpp +++ b/lib/utilities/ILog.hpp @@ -14,11 +14,11 @@ enum class LogLevel class ILog { public: - virtual void Info(const std::string& msg) = 0; - virtual void Debug(const std::string& msg) = 0; - virtual void Warn(const std::string& msg) = 0; - virtual void Error(const std::string& msg) = 0; - virtual void ChangeLevel(LogLevel lvl) = 0; + virtual void Info(const std::string& msg) const = 0; + virtual void Debug(const std::string& msg) const = 0; + virtual void Warn(const std::string& msg) const = 0; + virtual void Error(const std::string& msg) const = 0; + virtual void ChangeLevel(LogLevel lvl) const = 0; virtual ~ILog() {} }; diff --git a/lib/utilities/SpdLogger.cpp b/lib/utilities/SpdLogger.cpp index c04512d..112c526 100644 --- a/lib/utilities/SpdLogger.cpp +++ b/lib/utilities/SpdLogger.cpp @@ -19,12 +19,12 @@ SpdLogger::SpdLogger(const std::string& file_sink, const std::string& name) logger_->info("Logger initiated"); } -void SpdLogger::Info(const std::string& msg) { this->logger_->info(msg); } -void SpdLogger::Debug(const std::string& msg) { this->logger_->debug(msg); } -void SpdLogger::Warn(const std::string& msg) { this->logger_->warn(msg); } -void SpdLogger::Error(const std::string& msg) { this->logger_->error(msg); } +void SpdLogger::Info(const std::string& msg) const { this->logger_->info(msg); } +void SpdLogger::Debug(const std::string& msg) const { this->logger_->debug(msg); } +void SpdLogger::Warn(const std::string& msg) const { this->logger_->warn(msg); } +void SpdLogger::Error(const std::string& msg) const { this->logger_->error(msg); } -void SpdLogger::ChangeLevel(LogLevel lvl) +void SpdLogger::ChangeLevel(LogLevel lvl) const { constexpr auto LogLevelToString = [](LogLevel l) -> const char* { diff --git a/lib/utilities/SpdLogger.hpp b/lib/utilities/SpdLogger.hpp index 3a8907d..c844ffc 100644 --- a/lib/utilities/SpdLogger.hpp +++ b/lib/utilities/SpdLogger.hpp @@ -13,11 +13,11 @@ class SpdLogger : public ILog public: explicit SpdLogger(const std::string& file_sink, const std::string& name); - void Info(const std::string& msg) override; - void Debug(const std::string& msg) override; - void Warn(const std::string& msg) override; - void Error(const std::string& msg) override; - void ChangeLevel(LogLevel lvl) override; + void Info(const std::string& msg) const override; + void Debug(const std::string& msg) const override; + void Warn(const std::string& msg) const override; + void Error(const std::string& msg) const override; + void ChangeLevel(LogLevel lvl) const override; private: std::shared_ptr logger_; diff --git a/src/MyApp.hpp b/src/MyApp.hpp index 3ddefb2..b5a15e4 100644 --- a/src/MyApp.hpp +++ b/src/MyApp.hpp @@ -15,8 +15,8 @@ namespace pixelarium::ui class MyApp : public application::AppGLFW { public: - MyApp(std::unique_ptr& log, std::unique_ptr& pool) - : application::AppGLFW(log), pool_(*pool) + MyApp(const utils::log::ILog& log, pixelarium::resources::ImageResourcePool& pool) + : application::AppGLFW(log), pool_(pool) { image_view_model_ = std::make_unique(pool_); } @@ -34,7 +34,6 @@ class MyApp : public application::AppGLFW std::unique_ptr image_view_model_; bool imagep_{false}; bool demop_{false}; - int log_level_{0}; ImVec2 curr_dim_; }; } // namespace pixelarium::ui diff --git a/src/main.cpp b/src/main.cpp index 82f1c4f..9bebb2c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -23,7 +23,7 @@ int main(int argc, char** argv) logger->ChangeLevel(utils::log::LogLevel::Debug); auto image_pool{std::make_unique()}; - pixelarium::ui::MyApp app = pixelarium::ui::MyApp(logger, image_pool); + pixelarium::ui::MyApp app = pixelarium::ui::MyApp(*logger, *image_pool); app.Start(); }