From d7951a7179aa141568f1b9431b3149a66c8c346a Mon Sep 17 00:00:00 2001 From: WarmUpTill <19472752+WarmUpTill@users.noreply.github.com> Date: Fri, 30 May 2025 23:05:37 +0200 Subject: [PATCH] Cleanup constness --- lib/macro/macro-helpers.cpp | 14 +++++++------- lib/macro/macro-helpers.hpp | 14 +++++++------- lib/macro/macro.cpp | 15 +++++++++++++++ lib/macro/macro.hpp | 3 +++ 4 files changed, 32 insertions(+), 14 deletions(-) diff --git a/lib/macro/macro-helpers.cpp b/lib/macro/macro-helpers.cpp index 7afb8ed4..8cd9230f 100644 --- a/lib/macro/macro-helpers.cpp +++ b/lib/macro/macro-helpers.cpp @@ -78,36 +78,36 @@ bool MacroSwitchedScene() return macroSceneSwitched; } -std::string GetMacroName(Macro *macro) +std::string GetMacroName(const Macro *macro) { return macro ? macro->Name() : ""; } std::chrono::high_resolution_clock::time_point -LastMacroConditionCheckTime(Macro *macro) +LastMacroConditionCheckTime(const Macro *macro) { return macro ? macro->LastConditionCheckTime() : std::chrono::high_resolution_clock::time_point{}; } -bool MacroIsStopped(Macro *macro) +bool MacroIsStopped(const Macro *macro) { return macro ? macro->GetStop() : true; } -bool MacroIsPaused(Macro *macro) +bool MacroIsPaused(const Macro *macro) { return macro ? macro->Paused() : true; } bool MacroWasPausedSince( - Macro *macro, + const Macro *macro, const std::chrono::high_resolution_clock::time_point &time) { return macro ? macro->WasPausedSince(time) : false; } -bool MacroWasCheckedSinceLastStart(Macro *macro) +bool MacroWasCheckedSinceLastStart(const Macro *macro) { if (!macro) { return false; @@ -144,7 +144,7 @@ void ResetMacroRunCount(Macro *macro) macro->ResetRunCount(); } -bool IsValidMacroSegmentIndex(Macro *m, const int idx, bool isCondition) +bool IsValidMacroSegmentIndex(const Macro *m, const int idx, bool isCondition) { if (!m || idx < 0) { return false; diff --git a/lib/macro/macro-helpers.hpp b/lib/macro/macro-helpers.hpp index 44f79d16..12678cc6 100644 --- a/lib/macro/macro-helpers.hpp +++ b/lib/macro/macro-helpers.hpp @@ -41,17 +41,17 @@ EXPORT std::atomic_int &GetShutdownConditionCount(); EXPORT void SetMacroSwitchedScene(bool value); EXPORT bool MacroSwitchedScene(); -EXPORT std::string GetMacroName(Macro *); +EXPORT std::string GetMacroName(const Macro *); EXPORT std::chrono::high_resolution_clock::time_point -LastMacroConditionCheckTime(Macro *); +LastMacroConditionCheckTime(const Macro *); -EXPORT bool MacroIsStopped(Macro *); -EXPORT bool MacroIsPaused(Macro *); +EXPORT bool MacroIsStopped(const Macro *); +EXPORT bool MacroIsPaused(const Macro *); EXPORT bool -MacroWasPausedSince(Macro *, +MacroWasPausedSince(const Macro *, const std::chrono::high_resolution_clock::time_point &); -EXPORT bool MacroWasCheckedSinceLastStart(Macro *); +EXPORT bool MacroWasCheckedSinceLastStart(const Macro *); EXPORT void AddMacroHelperThread(Macro *, std::thread &&); @@ -68,6 +68,6 @@ EXPORT void InvalidateMacroTempVarValues(); EXPORT void ResetMacroConditionTimers(Macro *); EXPORT void ResetMacroRunCount(Macro *); -bool IsValidMacroSegmentIndex(Macro *m, const int idx, bool isCondition); +bool IsValidMacroSegmentIndex(const Macro *m, const int idx, bool isCondition); } // namespace advss diff --git a/lib/macro/macro.cpp b/lib/macro/macro.cpp index faf16b5c..a3697b38 100644 --- a/lib/macro/macro.cpp +++ b/lib/macro/macro.cpp @@ -724,16 +724,31 @@ std::deque> &Macro::Conditions() return _conditions; } +const std::deque> &Macro::Conditions() const +{ + return _conditions; +} + std::deque> &Macro::Actions() { return _actions; } +const std::deque> &Macro::Actions() const +{ + return _actions; +} + std::deque> &Macro::ElseActions() { return _elseActions; } +const std::deque> &Macro::ElseActions() const +{ + return _elseActions; +} + static void updateIndicesHelper(std::deque> &list) { int idx = 0; diff --git a/lib/macro/macro.hpp b/lib/macro/macro.hpp index c5e1c22d..8f859265 100644 --- a/lib/macro/macro.hpp +++ b/lib/macro/macro.hpp @@ -95,8 +95,11 @@ public: // Macro segments std::deque> &Conditions(); + const std::deque> &Conditions() const; std::deque> &Actions(); + const std::deque> &Actions() const; std::deque> &ElseActions(); + const std::deque> &ElseActions() const; void UpdateActionIndices(); void UpdateElseActionIndices(); void UpdateConditionIndices();