idle_detect  0.8.3.0
Provides overall idle detection for a linux computer
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
Config Class Referenceabstract

The Config class is a singleton that stores program config read from the config file, with applied defaults if the config file cannot be read, or a config parameter is not in the config file. More...

#include <util.h>

Inheritance diagram for Config:
Inheritance graph
[legend]

Public Member Functions

 Config ()
 Constructor.
 
void ReadAndUpdateConfig (const fs::path &config_file)
 Reads and parses the config file provided by the argument and populates m_config_in, then calls private method ProcessArgs() to populate m_config. More...
 
config_variant GetArg (const std::string &arg)
 Provides the config_variant type value of the config parameter (argument). More...
 

Protected Member Functions

std::string GetArgString (const std::string &arg, const std::string &default_value) const
 Private version of GetArg that operates on m_config_in and also selects the provided default value if the arg is not found. This is how default values for parameters are established. More...
 

Protected Attributes

std::multimap< std::string, config_variant > m_config
 Holds the processed parameter-values, which are strongly typed and in a config_variant union, and where default values are populated if not found in the config file (m_config_in).
 

Private Member Functions

virtual void ProcessArgs ()=0
 Private helper method used by ReadAndUpdateConfig. Note this is pure virtual. It must be implemented in a specialization of a derived class for use by a specific application.
 

Private Attributes

std::mutex mtx_config
 This is the mutex member that provides lock control for the config object. This is used to ensure the config object is thread-safe.
 
std::multimap< std::string, std::string > m_config_in
 Holds the raw parsed parameter-values from the config file.
 

Detailed Description

The Config class is a singleton that stores program config read from the config file, with applied defaults if the config file cannot be read, or a config parameter is not in the config file.

Member Function Documentation

◆ GetArg()

config_variant Config::GetArg ( const std::string &  arg)

Provides the config_variant type value of the config parameter (argument).

Parameters
arg(key) to look up value.
Returns
config_variant type value of the value of the config parameter (argument).
Here is the caller graph for this function:

◆ GetArgString()

std::string Config::GetArgString ( const std::string &  arg,
const std::string &  default_value 
) const
protected

Private version of GetArg that operates on m_config_in and also selects the provided default value if the arg is not found. This is how default values for parameters are established.

Parameters
arg(key) to look up value as string.
default_valueif arg is not found.
Returns
string value found in lookup, default value if not found.
Here is the caller graph for this function:

◆ ReadAndUpdateConfig()

void Config::ReadAndUpdateConfig ( const fs::path &  config_file)

Reads and parses the config file provided by the argument and populates m_config_in, then calls private method ProcessArgs() to populate m_config.

Parameters
config_file
Here is the call graph for this function:

The documentation for this class was generated from the following files: