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

#include <ConfigInstance.h>

Inheritance diagram for net::config::ConfigInstance:
Collaboration diagram for net::config::ConfigInstance:

Public Types

enum class  Role { SERVER , CLIENT }
using Instance = ConfigInstance

Public Member Functions

 ConfigInstance (ConfigInstance &)=delete
 ConfigInstance (ConfigInstance &&)=delete
ConfigInstanceoperator= (ConfigInstance &)=delete
ConfigInstanceoperator= (ConfigInstance &&)=delete
const std::string & getInstanceName () const
ConfigInstancesetInstanceName (const std::string &instanceName)
bool getDisabled () const
ConfigInstancesetDisabled (bool disabled=true)
ConfigInstanceconfigurable (bool configurable)
Public Member Functions inherited from utils::SubCommand
 SubCommand (const SubCommand &)=delete
 SubCommand (SubCommand &&)=delete
SubCommandoperator= (const SubCommand &)=delete
SubCommandoperator= (SubCommand &&)=delete
virtual ~SubCommand ()
std::string getName () const
std::string version () const
CLI::Option * setConfig (const std::string &defaultConfigFile) const
CLI::Option * setLogFile (const std::string &defaultLogFile) const
CLI::Option * setVersionFlag (const std::string &version) const
bool hasParent () const
SubCommandgetParent () const
SubCommandallowExtras (bool allow=true)
SubCommandrequired (bool required=true, bool force=true)
SubCommandrequired (SubCommand *subCommand, bool required=true)
SubCommandrequired (CLI::Option *option, bool required=true)
bool getRequired () const
SubCommandneeds (SubCommand *subCommand, bool needs=true)
SubCommanddisabled (SubCommand *subCommand, bool disabled=true)
SubCommandsetRequireCallback (const std::function< void(void)> &callback)
SubCommandfinalCallback (const std::function< void()> &finalCallback)
std::string configToStr () const
std::string help (const CLI::App *helpApp, const CLI::AppFormatMode &mode) const
template<typename NewSubCommand, typename... Args>
NewSubCommand * newSubCommand (Args &&... args)
template<typename RequestedSubCommand>
RequestedSubCommand * getSubCommand ()
template<typename RequestedSubCommand>
RequestedSubCommand * getSubCommand () const
CLI::Option * getOption (const std::string &name) const
CLI::Option * addOption (const std::string &name, const std::string &description, const std::string &typeName, const CLI::Validator &validator) const
template<typename ValueTypeT>
CLI::Option * addOption (const std::string &name, const std::string &description, const std::string &typeName, ValueTypeT defaultValue, const CLI::Validator &validator) const
template<typename ValueTypeT>
CLI::Option * addOptionVariable (const std::string &name, ValueTypeT &variable, const std::string &description, const std::string &typeName, const CLI::Validator &additionalValidator) const
template<typename ValueTypeT>
CLI::Option * addOptionVariable (const std::string &name, ValueTypeT &variable, const std::string &description, const std::string &typeName, ValueTypeT defaultValue, const CLI::Validator &additionalValidator) const
CLI::Option * addOptionFunction (const std::string &name, const std::function< void(const std::string &)> &callback, const std::string &description, const std::string &typeName, const CLI::Validator &validator) const
template<typename ValueTypeT>
CLI::Option * addOptionFunction (const std::string &name, const std::function< void(const std::string &)> &callback, const std::string &description, const std::string &typeName, ValueTypeT defaultValue, const CLI::Validator &validator) const
CLI::Option * addFlag (const std::string &name, const std::string &description, const std::string &typeName, const CLI::Validator &validator) const
template<typename ValueTypeT>
CLI::Option * addFlag (const std::string &name, const std::string &description, const std::string &typeName, ValueTypeT defaultValue, const CLI::Validator &validator) const
CLI::Option * addFlagFunction (const std::string &name, const std::function< void()> &callback, const std::string &description, const std::string &typeName, const CLI::Validator &validator) const
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) const

Static Public Member Functions

static CLI::App * getHelpTriggerApp ()
static CLI::App * getShowConfigTriggerApp ()
static CLI::App * getCommandlineTriggerApp ()

Protected Member Functions

 ConfigInstance (const std::string &instanceName, Role role)
 ~ConfigInstance () override
Protected Member Functions inherited from utils::SubCommand
 SubCommand (SubCommand *parent, std::shared_ptr< utils::AppWithPtr > appWithPtr, const std::string &group, bool final)
template<typename ConcretSubCommand>
 SubCommand (SubCommand *parent, ConcretSubCommand *concretSubCommand, const std::string &group, bool final=true)
void parse (int argc, char *argv[]) const
SubCommanddescription (const std::string &description)
SubCommandfooter (const std::string &footer)
void removeSubCommand ()
template<typename ValueTypeT>
CLI::Option * setDefaultValue (CLI::Option *option, const ValueTypeT &value, bool clear=true) const
CLI::Option * setConfigurable (CLI::Option *option, bool configurable) const

Private Attributes

std::string instanceName
Role role
CLI::Option * disableOpt = nullptr

Static Private Attributes

static const std::string nameAnonymous = "<anonymous>"

Friends

class net::config::ConfigSection

Additional Inherited Members

Static Protected Member Functions inherited from utils::SubCommand
static CLI::App * getHelpTriggerApp ()
static CLI::App * getShowConfigTriggerApp ()
static CLI::App * getCommandlineTriggerApp ()
Static Protected Attributes inherited from utils::SubCommand
static std::shared_ptr< CLI::Formatter > sectionFormatter = makeSectionFormatter()
static std::map< std::string, std::string > aliases
static CLI::App * helpTriggerApp = nullptr
static CLI::App * showConfigTriggerApp = nullptr
static CLI::App * commandlineTriggerApp = nullptr

Detailed Description

Definition at line 59 of file ConfigInstance.h.

Member Typedef Documentation

◆ Instance

Member Enumeration Documentation

◆ Role

Enumerator
SERVER 
CLIENT 

Definition at line 63 of file ConfigInstance.h.

63{ SERVER, CLIENT };

Constructor & Destructor Documentation

◆ ConfigInstance() [1/3]

net::config::ConfigInstance::ConfigInstance ( const std::string & instanceName,
Role role )
explicitprotected

Definition at line 58 of file ConfigInstance.cpp.

59 : utils::SubCommand(!instanceName.empty() ? &utils::Config::configRoot : nullptr,
60 std::make_shared<utils::AppWithPtr>(std::string("Configuration for ")
61 .append(role == Role::SERVER ? "server" : "client")
62 .append(" instance '")
63 .append(instanceName)
64 .append("'"),
66 this),
67 "Instances",
68 false)
70 , role(role) {
72 "--disabled{true}",
73 [this]() {
74 if (getParent() != nullptr) {
75 getParent()->disabled(this, disableOpt->as<bool>());
76 }
77 },
78 "Disable this instance",
79 "bool",
80 "false",
81 CLI::IsMember({"true", "false"})),
82 true);
83 }
static ConfigRoot configRoot
Definition Config.h:116
CLI::Option * addFlagFunction(const std::string &name, const std::function< void()> &callback, const std::string &description, const std::string &typeName, const CLI::Validator &validator) const
SubCommand * disabled(SubCommand *subCommand, bool disabled=true)
SubCommand * getParent() const
CLI::Option * setConfigurable(CLI::Option *option, bool configurable) const

References utils::SubCommand::addFlagFunction(), utils::Config::configRoot, utils::SubCommand::disabled(), disableOpt, utils::SubCommand::getParent(), instanceName, role, SERVER, utils::SubCommand::setConfigurable(), and utils::SubCommand::SubCommand().

Here is the call graph for this function:

◆ ~ConfigInstance()

net::config::ConfigInstance::~ConfigInstance ( )
overrideprotected

Definition at line 85 of file ConfigInstance.cpp.

85 {
87 }

References utils::SubCommand::removeSubCommand().

Here is the call graph for this function:

◆ ConfigInstance() [2/3]

net::config::ConfigInstance::ConfigInstance ( ConfigInstance & )
delete

◆ ConfigInstance() [3/3]

net::config::ConfigInstance::ConfigInstance ( ConfigInstance && )
delete

Member Function Documentation

◆ configurable()

ConfigInstance & net::config::ConfigInstance::configurable ( bool configurable)

Definition at line 114 of file ConfigInstance.cpp.

114 {
116
117 return *this;
118 }
ConfigInstance & configurable(bool configurable)

References disableOpt, and utils::SubCommand::setConfigurable().

Here is the call graph for this function:

◆ getCommandlineTriggerApp()

CLI::App * net::config::ConfigInstance::getCommandlineTriggerApp ( )
static

Definition at line 127 of file ConfigInstance.cpp.

127 {
129 }
static CLI::App * getCommandlineTriggerApp()

References utils::Config::configRoot, and utils::SubCommand::getCommandlineTriggerApp().

Here is the call graph for this function:

◆ getDisabled()

bool net::config::ConfigInstance::getDisabled ( ) const

Definition at line 99 of file ConfigInstance.cpp.

99 {
100 return disableOpt //
101 ->as<bool>();
102 }

References disableOpt.

◆ getHelpTriggerApp()

CLI::App * net::config::ConfigInstance::getHelpTriggerApp ( )
static

Definition at line 120 of file ConfigInstance.cpp.

120 {
122 }
static CLI::App * getHelpTriggerApp()

References utils::Config::configRoot, and utils::SubCommand::getHelpTriggerApp().

Here is the call graph for this function:

◆ getInstanceName()

const std::string & net::config::ConfigInstance::getInstanceName ( ) const

◆ getShowConfigTriggerApp()

CLI::App * net::config::ConfigInstance::getShowConfigTriggerApp ( )
static

Definition at line 124 of file ConfigInstance.cpp.

124 {
126 }
static CLI::App * getShowConfigTriggerApp()

References utils::Config::configRoot, and utils::SubCommand::getShowConfigTriggerApp().

Here is the call graph for this function:

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ setDisabled()

ConfigInstance & net::config::ConfigInstance::setDisabled ( bool disabled = true)

Definition at line 104 of file ConfigInstance.cpp.

104 {
105 setDefaultValue(disableOpt, disabled ? "true" : "false");
106
107 if (getParent() != nullptr) {
108 getParent()->disabled(this, disabled);
109 }
110
111 return *this;
112 }
CLI::Option * setDefaultValue(CLI::Option *option, const ValueTypeT &value, bool clear=true) const
Definition SubCommand.h:347

References utils::SubCommand::disabled(), disableOpt, utils::SubCommand::getParent(), and utils::SubCommand::setDefaultValue().

Here is the call graph for this function:

◆ setInstanceName()

ConfigInstance & net::config::ConfigInstance::setInstanceName ( const std::string & instanceName)

Definition at line 93 of file ConfigInstance.cpp.

93 {
95
96 return *this;
97 }

References instanceName.

◆ net::config::ConfigSection

friend class net::config::ConfigSection
friend

Definition at line 97 of file ConfigInstance.h.

Member Data Documentation

◆ disableOpt

CLI::Option* net::config::ConfigInstance::disableOpt = nullptr
private

Definition at line 95 of file ConfigInstance.h.

Referenced by ConfigInstance(), configurable(), getDisabled(), and setDisabled().

◆ instanceName

std::string net::config::ConfigInstance::instanceName
private

Definition at line 90 of file ConfigInstance.h.

Referenced by ConfigInstance(), getInstanceName(), and setInstanceName().

◆ nameAnonymous

const std::string net::config::ConfigInstance::nameAnonymous = "<anonymous>"
staticprivate

Definition at line 91 of file ConfigInstance.h.

Referenced by getInstanceName().

◆ role

Role net::config::ConfigInstance::role
private

Definition at line 93 of file ConfigInstance.h.

Referenced by ConfigInstance().


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