From ae7d98cd3df25490cc806cc843d14cee731fefa8 Mon Sep 17 00:00:00 2001 From: Vitaly Date: Fri, 4 Oct 2024 14:34:30 +0200 Subject: [PATCH] Marked various methods of the Application class as const. --- src/app/application/application.cpp | 24 ++++++++++++------------ src/app/application/application.hpp | 24 ++++++++++++------------ 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/app/application/application.cpp b/src/app/application/application.cpp index d485c02..f4fdab5 100644 --- a/src/app/application/application.cpp +++ b/src/app/application/application.cpp @@ -26,7 +26,7 @@ #include "ksysinfo/ksysinfo.hpp" #include "ksysversion/ksysversion.hpp" -void Application::PrintDebugInfo() +void Application::PrintDebugInfo() const { if (!ZSwapDebugger -> IsDebugAvailable()) { @@ -58,7 +58,7 @@ void Application::PrintDebugInfo() << std::endl; } -void Application::PrintSettings() +void Application::PrintSettings() const { if (!ZSwap -> IsAvailable()) { @@ -87,7 +87,7 @@ void Application::PrintSettings() << std::endl; } -void Application::PrintSummary() +void Application::PrintSummary() const { std::unique_ptr SysInfo = std::make_unique(); @@ -115,7 +115,7 @@ void Application::PrintSummary() << std::endl; } -void Application::PrintCombined() +void Application::PrintCombined() const { std::cout << "ZSWAP KERNEL MODULE SETTINGS:" << std::endl; PrintSettings(); @@ -127,7 +127,7 @@ void Application::PrintCombined() PrintDebugInfo(); } -int Application::PrintStats(const int Value) +int Application::PrintStats(const int Value) const { switch (Value) { @@ -149,13 +149,13 @@ int Application::PrintStats(const int Value) return 0; } -int Application::PrintHelp() +int Application::PrintHelp() const { CmdLineOptions -> print(std::cout); return 0; } -int Application::PrintVersion() +int Application::PrintVersion() const { std::unique_ptr SysVersion = std::make_unique(); std::cout << std::format("{0} project version: {1}.\n" @@ -168,7 +168,7 @@ int Application::PrintVersion() return 0; } -int Application::ExecuteEnv() +int Application::ExecuteEnv() const { bool Result = true; const std::vector>> Handlers @@ -201,7 +201,7 @@ int Application::ExecuteEnv() return !Result; } -int Application::ExecuteConfig(const std::string& ConfigFile) +int Application::ExecuteConfig(const std::string& ConfigFile) const { std::unique_ptr Config = std::make_unique(); std::unique_ptr ConfigOptions = std::make_unique("Configuration file options."); @@ -253,7 +253,7 @@ int Application::ExecuteConfig(const std::string& ConfigFile) return !Result; } -int Application::ExecuteCmdLine() +int Application::ExecuteCmdLine() const { bool Result = true; const std::vector>> Handlers @@ -285,7 +285,7 @@ int Application::ExecuteCmdLine() return !Result; } -int Application::Run() +int Application::Run() const { if (CmdLine -> empty() || CmdLine -> count("help")) return PrintHelp(); if (CmdLine -> count("version")) return PrintVersion(); @@ -295,7 +295,7 @@ int Application::Run() return ExecuteCmdLine(); } -void Application::CheckIfRunningBySuperUser() +void Application::CheckIfRunningBySuperUser() const { if (CWrappers::CheckRoot()) { diff --git a/src/app/application/application.hpp b/src/app/application/application.hpp index 0bb8d49..8cafd9d 100644 --- a/src/app/application/application.hpp +++ b/src/app/application/application.hpp @@ -36,7 +36,7 @@ class Application * Runs an application and return exit code. * @returns Exit code. */ - int Run(); + int Run() const; private: /** * Stores an instance of the ZSwapObject class. @@ -83,14 +83,14 @@ class Application * @exception Raises an instance of std::runtime_error on missing * super-user privileges. */ - void CheckIfRunningBySuperUser(); + void CheckIfRunningBySuperUser() const; /** * Handles \-\-env command-line argument. Gets parameters from * the environment variables. * @returns Exit code. */ - int ExecuteEnv(); + int ExecuteEnv() const; /** * Handles \-\-config command-line argument. Gets parameters from @@ -100,33 +100,33 @@ class Application * if incorrect file path was specified. * @returns Exit code. */ - int ExecuteConfig(const std::string&); + int ExecuteConfig(const std::string&) const; /** * Gets parameters from command-line arguments. * @returns Exit code. */ - int ExecuteCmdLine(); + int ExecuteCmdLine() const; /** * Prints ZSwap kernel module debug information. */ - void PrintDebugInfo(); + void PrintDebugInfo() const; /** * Prints ZSwap kernel module current settings. */ - void PrintSettings(); + void PrintSettings() const; /** * Prints ZSwap kernel module usage summary. */ - void PrintSummary(); + void PrintSummary() const; /** * Prints all available information about ZSwap kernel module. */ - void PrintCombined(); + void PrintCombined() const; /** * Handles \-\-stats command-line argument. Prints requested by @@ -137,21 +137,21 @@ class Application * if incorrect request code was specified. * @returns Exit code. */ - int PrintStats(int); + int PrintStats(int) const; /** * Handles \-\-help command-line argument. Prints useful documentation * about using this application. * @returns Exit code. */ - int PrintHelp(); + int PrintHelp() const; /** * Handles \-\-version command-line argument. Prints version * information. * @returns Exit code. */ - int PrintVersion(); + int PrintVersion() const; }; #endif // APPLICATION_HPP