Skip to content

Commit

Permalink
Marked various methods of the Application class as const.
Browse files Browse the repository at this point in the history
  • Loading branch information
xvitaly committed Oct 4, 2024
1 parent 64a2c4c commit ae7d98c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
24 changes: 12 additions & 12 deletions src/app/application/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include "ksysinfo/ksysinfo.hpp"
#include "ksysversion/ksysversion.hpp"

void Application::PrintDebugInfo()
void Application::PrintDebugInfo() const
{
if (!ZSwapDebugger -> IsDebugAvailable())
{
Expand Down Expand Up @@ -58,7 +58,7 @@ void Application::PrintDebugInfo()
<< std::endl;
}

void Application::PrintSettings()
void Application::PrintSettings() const
{
if (!ZSwap -> IsAvailable())
{
Expand Down Expand Up @@ -87,7 +87,7 @@ void Application::PrintSettings()
<< std::endl;
}

void Application::PrintSummary()
void Application::PrintSummary() const
{
std::unique_ptr<KSysInfo> SysInfo = std::make_unique<KSysInfo>();

Expand Down Expand Up @@ -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();
Expand All @@ -127,7 +127,7 @@ void Application::PrintCombined()
PrintDebugInfo();
}

int Application::PrintStats(const int Value)
int Application::PrintStats(const int Value) const
{
switch (Value)
{
Expand All @@ -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<KSysVersion> SysVersion = std::make_unique<KSysVersion>();
std::cout << std::format("{0} project version: {1}.\n"
Expand All @@ -168,7 +168,7 @@ int Application::PrintVersion()
return 0;
}

int Application::ExecuteEnv()
int Application::ExecuteEnv() const
{
bool Result = true;
const std::vector<std::pair<std::string, std::function<void(const std::string&)>>> Handlers
Expand Down Expand Up @@ -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<boost::program_options::variables_map> Config = std::make_unique<boost::program_options::variables_map>();
std::unique_ptr<boost::program_options::options_description> ConfigOptions = std::make_unique<boost::program_options::options_description>("Configuration file options.");
Expand Down Expand Up @@ -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<std::pair<std::string, std::function<void(const std::string&)>>> Handlers
Expand Down Expand Up @@ -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();
Expand All @@ -295,7 +295,7 @@ int Application::Run()
return ExecuteCmdLine();
}

void Application::CheckIfRunningBySuperUser()
void Application::CheckIfRunningBySuperUser() const
{
if (CWrappers::CheckRoot())
{
Expand Down
24 changes: 12 additions & 12 deletions src/app/application/application.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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

0 comments on commit ae7d98c

Please sign in to comment.