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)
ConfigInstancesetOnDestroy (const std::function< void(ConfigInstance *)> &onDestroy)
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
std::string configToStr () const
std::string help (const CLI::App *helpApp, const CLI::AppFormatMode &mode) const
bool hasParent () const
SubCommandgetParent () const
SubCommandallowExtras (bool allow=true)
SubCommandforceUnrequired (bool unrequired=true)
SubCommandrequired (bool required=true)
SubCommandrequired (CLI::Option *option, bool required=true)
bool getRequired () const
SubCommandneeds (SubCommand *subCommand, bool needs=true)
SubCommandsetRequireCallback (const std::function< void(void)> &callback)
SubCommandfinalCallback (const std::function< void()> &finalCallback)
void addSubCommandApp (std::shared_ptr< utils::AppWithPtr > subCommand)
template<typename NewSubCommand, typename... Args>
NewSubCommand * newSubCommand (Args &&... args)
template<typename RequestedSubCommand>
RequestedSubCommand * getSubCommand ()
template<typename RequestedSubCommand>
RequestedSubCommand * getSubCommand () 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
CLI::Option * getOption (const std::string &name) const
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

Static Public Member Functions

static CLI::App * getHelpTriggerApp ()
static CLI::App * getShowConfigTriggerApp ()
static CLI::App * extracted ()
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=false)
template<typename ConcretSubCommand>
 SubCommand (SubCommand *parent, ConcretSubCommand *concretSubCommand, const std::string &group, bool final=false)
void parse (int argc, char *argv[]) const
SubCommanddescription (const std::string &description)
SubCommandfooter (const std::string &footer)
void removeSubCommand ()
CLI::Option * addConfigFlag (const std::string &defaultConfigFile) const
CLI::Option * addLogFileFlag (const std::string &defaultLogFile) const
CLI::Option * addVersionFlag (const std::string &version) const

Private Attributes

std::string instanceName
Role role
CLI::Option * disableOpt = nullptr
std::function< void(ConfigInstance *)> onDestroy

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 ()
Protected Attributes inherited from utils::SubCommand
CLI::Option * helpOpt = nullptr
CLI::Option * showConfigOpt = nullptr
CLI::Option * commandlineOpt = nullptr
Static Protected Attributes inherited from utils::SubCommand
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 60 of file ConfigInstance.h.

Member Typedef Documentation

◆ Instance

Member Enumeration Documentation

◆ Role

Enumerator
SERVER 
CLIENT 

Definition at line 64 of file ConfigInstance.h.

64{ 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")
69 , role(role)
71 "--disabled{true}",
72 [this]() {
73 forceUnrequired(disableOpt->as<bool>());
74 },
75 "Disable this instance",
76 "BOOL",
77 "false",
78 CLI::IsMember({"true", "false"})),
79 true))
81 }) {
82 }
ConfigInstance(const std::string &instanceName, Role role)
std::function< void(ConfigInstance *)> onDestroy
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 * forceUnrequired(bool unrequired=true)
CLI::Option * setConfigurable(CLI::Option *option, bool configurable) const

References utils::SubCommand::addFlagFunction(), utils::Config::configRoot, disableOpt, utils::SubCommand::forceUnrequired(), 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 84 of file ConfigInstance.cpp.

84 {
86
87 onDestroy(this);
88 }

References onDestroy, and 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 113 of file ConfigInstance.cpp.

113 {
115
116 return this;
117 }
ConfigInstance * configurable(bool configurable)

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

Here is the call graph for this function:

◆ extracted()

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

◆ getCommandlineTriggerApp()

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

Definition at line 136 of file ConfigInstance.cpp.

136 {
138 }
static CLI::App * getCommandlineTriggerApp()

References utils::SubCommand::getCommandlineTriggerApp().

Here is the call graph for this function:

◆ getDisabled()

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

Definition at line 100 of file ConfigInstance.cpp.

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

References disableOpt.

◆ getHelpTriggerApp()

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

Definition at line 129 of file ConfigInstance.cpp.

129 {
131 }
static CLI::App * getHelpTriggerApp()

References utils::SubCommand::getHelpTriggerApp().

Here is the call graph for this function:

◆ getInstanceName()

◆ getShowConfigTriggerApp()

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

Definition at line 133 of file ConfigInstance.cpp.

133 {
135 }
static CLI::App * getShowConfigTriggerApp()

References 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 105 of file ConfigInstance.cpp.

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

References disableOpt, utils::SubCommand::forceUnrequired(), 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 94 of file ConfigInstance.cpp.

94 {
96
97 return this;
98 }

References instanceName.

◆ setOnDestroy()

ConfigInstance * net::config::ConfigInstance::setOnDestroy ( const std::function< void(ConfigInstance *)> & onDestroy)

Definition at line 119 of file ConfigInstance.cpp.

119 {
120 const std::function<void(ConfigInstance*)> oldOnDestroy = this->onDestroy;
121 this->onDestroy = [oldOnDestroy, onDestroy](ConfigInstance* configInstance) {
122 oldOnDestroy(configInstance);
123 onDestroy(configInstance);
124 };
125
126 return this;
127 }

References onDestroy.

Referenced by core::socket::stream::FlowController< ConcreteFlowController >::setOnFlowCompleted().

Here is the caller graph for this function:

◆ net::config::ConfigSection

friend class net::config::ConfigSection
friend

Definition at line 103 of file ConfigInstance.h.

Member Data Documentation

◆ disableOpt

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

Definition at line 99 of file ConfigInstance.h.

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

◆ instanceName

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

Definition at line 94 of file ConfigInstance.h.

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

◆ nameAnonymous

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

Definition at line 95 of file ConfigInstance.h.

Referenced by getInstanceName().

◆ onDestroy

std::function<void(ConfigInstance*)> net::config::ConfigInstance::onDestroy
private

Definition at line 101 of file ConfigInstance.h.

Referenced by setOnDestroy(), and ~ConfigInstance().

◆ role

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

Definition at line 97 of file ConfigInstance.h.

Referenced by ConfigInstance().


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