SNode.C
Loading...
Searching...
No Matches
ConfigDb Class Reference
Collaboration diagram for ConfigDb:

Public Member Functions

 ConfigDb ()
ConfigDbsetHost (const std::string &host)
std::string getHost ()
 ConfigDb ()
ConfigDbsetHost (const std::string &host)
std::string getHost ()

Static Public Attributes

static constexpr std::string_view name {"db"}
static constexpr std::string_view description {"Database connection"}

Private Attributes

CLI::App * configDbSc
CLI::Option * hostOpt

Detailed Description

Definition at line 61 of file testmariadb.cpp.

Constructor & Destructor Documentation

◆ ConfigDb() [1/2]

ConfigDb::ConfigDb ( )
inline

Definition at line 66 of file testmariadb.cpp.

67 : configDbSc(
68 utils::Config::newInstance(net::config::Instance(std::string(name), std::string(description), this), "Database", true)) {
69 hostOpt = configDbSc->add_option("--db-host", "Hostname of IP-Address of Server")
70 ->group(configDbSc->get_formatter()->get_label("Persistent Options"))
71 ->type_name("[hostname|IP-address]")
72 ->configurable()
73 ->required();
74
75 configDbSc->needs(hostOpt)->required();
76 configDbSc->get_parent()->needs(configDbSc);
77 }
static constexpr std::string_view name
CLI::Option * hostOpt
static constexpr std::string_view description
CLI::App * configDbSc
static CLI::App * newInstance(std::shared_ptr< CLI::App > appWithPtr, const std::string &group, bool final=false)
Definition Config.cpp:736
std::shared_ptr< utils::AppWithPtr< T > > Instance(const std::string &name, const std::string &description, T *section)

References configDbSc, description, hostOpt, name, and utils::Config::newInstance().

Here is the call graph for this function:

◆ ConfigDb() [2/2]

ConfigDb::ConfigDb ( )
inline

Definition at line 66 of file testmariadb.cpp.

67 : configDbSc(
68 utils::Config::newInstance(net::config::Instance(std::string(name), std::string(description), this), "Database", true)) {
69 hostOpt = configDbSc->add_option("--db-host", "Hostname of IP-Address of Server")
70 ->group(configDbSc->get_formatter()->get_label("Persistent Options"))
71 ->type_name("[hostname|IP-address]")
72 ->configurable()
73 ->required();
74
75 configDbSc->needs(hostOpt)->required();
76 configDbSc->get_parent()->needs(configDbSc);
77 }

Member Function Documentation

◆ getHost() [1/2]

std::string ConfigDb::getHost ( )
inline

Definition at line 90 of file testmariadb.cpp.

90 {
91 return hostOpt->as<std::string>();
92 }

References hostOpt.

◆ getHost() [2/2]

std::string ConfigDb::getHost ( )
inline

Definition at line 90 of file testmariadb.cpp.

90 {
91 return hostOpt->as<std::string>();
92 }

◆ setHost() [1/2]

ConfigDb & ConfigDb::setHost ( const std::string & host)
inline

Definition at line 79 of file testmariadb.cpp.

79 {
80 hostOpt->default_str(host)->clear();
81 hostOpt->required(false);
82
83 configDbSc->remove_needs(hostOpt);
84 configDbSc->required(false);
85 configDbSc->get_parent()->remove_needs(configDbSc);
86
87 return *this;
88 }

References configDbSc, and hostOpt.

◆ setHost() [2/2]

ConfigDb & ConfigDb::setHost ( const std::string & host)
inline

Definition at line 79 of file testmariadb.cpp.

79 {
80 hostOpt->default_str(host)->clear();
81 hostOpt->required(false);
82
83 configDbSc->remove_needs(hostOpt);
84 configDbSc->required(false);
85 configDbSc->get_parent()->remove_needs(configDbSc);
86
87 return *this;
88 }

Member Data Documentation

◆ configDbSc

CLI::App * ConfigDb::configDbSc
private

Definition at line 95 of file testmariadb.cpp.

Referenced by ConfigDb(), and setHost().

◆ description

constexpr std::string_view ConfigDb::description {"Database connection"}
staticconstexpr

Definition at line 64 of file testmariadb.cpp.

64{"Database connection"};

Referenced by ConfigDb().

◆ hostOpt

CLI::Option * ConfigDb::hostOpt
private

Definition at line 96 of file testmariadb.cpp.

Referenced by ConfigDb(), getHost(), and setHost().

◆ name

constexpr std::string_view ConfigDb::name {"db"}
staticconstexpr

Definition at line 63 of file testmariadb.cpp.

63{"db"};

Referenced by ConfigDb().


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