SNode.C
Loading...
Searching...
No Matches
net::config::ConfigSection Class Reference

#include <ConfigSection.h>

Inheritance diagram for net::config::ConfigSection:
Collaboration diagram for net::config::ConfigSection:

Public Member Functions

 ConfigSection (ConfigInstance *instance, const std::string &name, const std::string &description)
 
 ConfigSection (const ConfigSection &)=delete
 
 ConfigSection (ConfigSection &&)=delete
 
ConfigSectionoperator= (const ConfigSection &)=delete
 
ConfigSectionoperator= (ConfigSection &&)=delete
 
CLI::Option * addOption (const std::string &name, const std::string &description)
 
CLI::Option * addOption (const std::string &name, const std::string &description, const std::string &typeName)
 
CLI::Option * addOption (const std::string &name, const std::string &description, const std::string &typeName, const CLI::Validator &additionalValidator)
 
template<typename ValueTypeT >
CLI::Option * addOption (const std::string &name, const std::string &description, const std::string &typeName, ValueTypeT defaultValue)
 
template<typename ValueTypeT >
CLI::Option * addOption (const std::string &name, const std::string &description, const std::string &typeName, ValueTypeT defaultValue, const CLI::Validator &additionalValidator)
 
CLI::Option * addFlag (const std::string &name, const std::string &description, const std::string &typeName)
 
CLI::Option * addFlag (const std::string &name, const std::string &description, const std::string &typeName, const CLI::Validator &additionalValidator)
 
template<typename ValueTypeT >
CLI::Option * addFlag (const std::string &name, const std::string &description, const std::string &typeName, ValueTypeT defaultValue)
 
template<typename ValueTypeT >
CLI::Option * addFlag (const std::string &name, const std::string &description, const std::string &typeName, ValueTypeT defaultValue, const CLI::Validator &additionalValidator)
 
CLI::Option * addFlagFunction (const std::string &name, const std::function< void()> &callback, const std::string &description, const std::string &typeName, const std::string &defaultValue)
 
CLI::Option * addFlagFunction (const std::string &name, const std::function< void()> &callback, const std::string &description, const std::string &typeName, const std::string &defaultValue, const CLI::Validator &validator)
 
void required (CLI::Option *opt, bool req=true)
 
bool required () const
 
template<typename ValueType >
CLI::Option * addOption (const std::string &name, const std::string &description, const std::string &typeName, ValueType defaultValue)
 
template<typename ValueType >
CLI::Option * addOption (const std::string &name, const std::string &description, const std::string &typeName, ValueType defaultValue, const CLI::Validator &additionalValidator)
 
template<typename ValueType >
CLI::Option * addFlag (const std::string &name, const std::string &description, const std::string &typeName, ValueType defaultValue)
 
template<typename ValueType >
CLI::Option * addFlag (const std::string &name, const std::string &description, const std::string &typeName, ValueType defaultValue, const CLI::Validator &additionalValidator)
 

Protected Attributes

CLI::App * section = nullptr
 

Private Attributes

ConfigInstanceinstance = nullptr
 
uint8_t requiredCount = 0
 

Detailed Description

Definition at line 65 of file ConfigSection.h.

Constructor & Destructor Documentation

◆ ConfigSection() [1/3]

net::config::ConfigSection::ConfigSection ( ConfigInstance * instance,
const std::string & name,
const std::string & description )

Definition at line 72 of file ConfigSection.cpp.

74 CLI::App* existingSection = instance->getSection(name);
75 section = existingSection != nullptr ? existingSection
76 : instance //
77 ->addSection(name, description + " for instance '" + instance->getInstanceName() + "'")
78 ->disabled()
79 ->group("Sections");
80 }
CLI::App * getSection(const std::string &name) const
CLI::App * addSection(const std::string &name, const std::string &description)
const std::string & getInstanceName() const

◆ ConfigSection() [2/3]

net::config::ConfigSection::ConfigSection ( const ConfigSection & )
delete

◆ ConfigSection() [3/3]

net::config::ConfigSection::ConfigSection ( ConfigSection && )
delete

Member Function Documentation

◆ addFlag() [1/6]

CLI::Option * net::config::ConfigSection::addFlag ( const std::string & name,
const std::string & description,
const std::string & typeName )

Definition at line 131 of file ConfigSection.cpp.

131 {
132 section->disabled(false);
133
134 CLI::Option* opt = section //
135 ->add_flag(name, description)
136 ->type_name(typeName);
137 if (opt->get_configurable()) {
138 opt->group(section->get_formatter()->get_label("Persistent Options"));
139 }
140
141 return opt;
142 }

◆ addFlag() [2/6]

CLI::Option * net::config::ConfigSection::addFlag ( const std::string & name,
const std::string & description,
const std::string & typeName,
const CLI::Validator & additionalValidator )

Definition at line 144 of file ConfigSection.cpp.

147 {
148 return addFlag(name, description, typeName) //
149 ->check(additionalValidator);
150 }
CLI::Option * addFlag(const std::string &name, const std::string &description, const std::string &typeName)

◆ addFlag() [3/6]

template<typename ValueType >
CLI::Option * net::config::ConfigSection::addFlag ( const std::string & name,
const std::string & description,
const std::string & typeName,
ValueType defaultValue )

Definition at line 86 of file ConfigSection.hpp.

86 {
87 return addFlag(name, description, typeName) //
88 ->default_val(defaultValue);
89 }

◆ addFlag() [4/6]

template<typename ValueType >
CLI::Option * net::config::ConfigSection::addFlag ( const std::string & name,
const std::string & description,
const std::string & typeName,
ValueType defaultValue,
const CLI::Validator & additionalValidator )

Definition at line 92 of file ConfigSection.hpp.

96 {
97 return addFlag(name, description, typeName, defaultValue) //
98 ->check(additionalValidator);
99 }

◆ addFlag() [5/6]

template<typename ValueTypeT >
CLI::Option * net::config::ConfigSection::addFlag ( const std::string & name,
const std::string & description,
const std::string & typeName,
ValueTypeT defaultValue )

◆ addFlag() [6/6]

template<typename ValueTypeT >
CLI::Option * net::config::ConfigSection::addFlag ( const std::string & name,
const std::string & description,
const std::string & typeName,
ValueTypeT defaultValue,
const CLI::Validator & additionalValidator )

◆ addFlagFunction() [1/2]

CLI::Option * net::config::ConfigSection::addFlagFunction ( const std::string & name,
const std::function< void()> & callback,
const std::string & description,
const std::string & typeName,
const std::string & defaultValue )

Definition at line 152 of file ConfigSection.cpp.

156 {
157 section->disabled(false);
158
159 CLI::Option* opt = section //
160 ->add_flag_function(
161 name,
162 [callback](std::int64_t) {
163 callback();
164 },
165 description)
166 ->default_val(defaultValue)
167 ->type_name(typeName)
168 ->take_last();
169 if (opt->get_configurable()) {
170 opt->group(section->get_formatter()->get_label("Persistent Options"));
171 }
172
173 return opt;
174 }

◆ addFlagFunction() [2/2]

CLI::Option * net::config::ConfigSection::addFlagFunction ( const std::string & name,
const std::function< void()> & callback,
const std::string & description,
const std::string & typeName,
const std::string & defaultValue,
const CLI::Validator & validator )

Definition at line 176 of file ConfigSection.cpp.

181 {
182 return addFlagFunction(name, callback, description, typeName, defaultValue) //
183 ->check(validator);
184 }
CLI::Option * addFlagFunction(const std::string &name, const std::function< void()> &callback, const std::string &description, const std::string &typeName, const std::string &defaultValue)

◆ addOption() [1/7]

CLI::Option * net::config::ConfigSection::addOption ( const std::string & name,
const std::string & description )

Definition at line 103 of file ConfigSection.cpp.

103 {
104 if (!instance->getInstanceName().empty() && !section->get_display_name().empty()) {
105 section->disabled(false);
106 }
107
108 CLI::Option* opt = section //
109 ->add_option(name, description);
110
111 if (opt->get_configurable()) {
112 opt->group(section->get_formatter()->get_label("Persistent Options"));
113 }
114
115 return opt;
116 }

◆ addOption() [2/7]

CLI::Option * net::config::ConfigSection::addOption ( const std::string & name,
const std::string & description,
const std::string & typeName )

Definition at line 118 of file ConfigSection.cpp.

118 {
119 return addOption(name, description) //
120 ->type_name(typeName);
121 }
CLI::Option * addOption(const std::string &name, const std::string &description)

◆ addOption() [3/7]

CLI::Option * net::config::ConfigSection::addOption ( const std::string & name,
const std::string & description,
const std::string & typeName,
const CLI::Validator & additionalValidator )

Definition at line 123 of file ConfigSection.cpp.

126 {
127 return addOption(name, description, typeName) //
128 ->check(additionalValidator);
129 }

◆ addOption() [4/7]

template<typename ValueType >
CLI::Option * net::config::ConfigSection::addOption ( const std::string & name,
const std::string & description,
const std::string & typeName,
ValueType defaultValue )

Definition at line 69 of file ConfigSection.hpp.

69 {
70 return addOption(name, description, typeName) //
71 ->default_val(defaultValue);
72 }

◆ addOption() [5/7]

template<typename ValueType >
CLI::Option * net::config::ConfigSection::addOption ( const std::string & name,
const std::string & description,
const std::string & typeName,
ValueType defaultValue,
const CLI::Validator & additionalValidator )

Definition at line 75 of file ConfigSection.hpp.

79 {
80 return addOption(name, description, typeName, defaultValue) //
81 ->check(additionalValidator);
82 }

◆ addOption() [6/7]

template<typename ValueTypeT >
CLI::Option * net::config::ConfigSection::addOption ( const std::string & name,
const std::string & description,
const std::string & typeName,
ValueTypeT defaultValue )

◆ addOption() [7/7]

template<typename ValueTypeT >
CLI::Option * net::config::ConfigSection::addOption ( const std::string & name,
const std::string & description,
const std::string & typeName,
ValueTypeT defaultValue,
const CLI::Validator & additionalValidator )

◆ operator=() [1/2]

ConfigSection & net::config::ConfigSection::operator= ( ConfigSection && )
delete

◆ operator=() [2/2]

ConfigSection & net::config::ConfigSection::operator= ( const ConfigSection & )
delete

◆ required() [1/2]

bool net::config::ConfigSection::required ( ) const

Definition at line 99 of file ConfigSection.cpp.

99 {
100 return requiredCount > 0;
101 }

◆ required() [2/2]

void net::config::ConfigSection::required ( CLI::Option * opt,
bool req = true )

Definition at line 82 of file ConfigSection.cpp.

82 {
83 if (req != opt->get_required()) {
84 if (req) {
86 section->needs(opt);
87 opt->default_str("");
88 } else {
90 section->remove_needs(opt);
91 }
92
93 opt->required(req);
94
96 }
97 }
void required(CLI::App *section, bool req=true)

Member Data Documentation

◆ instance

ConfigInstance* net::config::ConfigSection::instance = nullptr
private

Definition at line 133 of file ConfigSection.h.

◆ requiredCount

uint8_t net::config::ConfigSection::requiredCount = 0
private

Definition at line 135 of file ConfigSection.h.

◆ section

CLI::App* net::config::ConfigSection::section = nullptr
protected

Definition at line 130 of file ConfigSection.h.


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