SNode.C
Loading...
Searching...
No Matches
net::rc::config::ConfigAddress< ConfigAddressTypeT > Class Template Reference

#include <ConfigAddress.h>

Inheritance diagram for net::rc::config::ConfigAddress< ConfigAddressTypeT >:
Collaboration diagram for net::rc::config::ConfigAddress< ConfigAddressTypeT >:

Public Member Functions

ConfigAddresssetSocketAddress (const SocketAddress &socketAddress)
ConfigAddresssetBtAddress (const std::string &btAddress)
std::string getBtAddress () const
ConfigAddresssetChannel (uint8_t channel)
uint8_t getChannel () const
void configurable (bool configurable=true) final
Public Member Functions inherited from net::config::ConfigSection
template<typename T>
 ConfigSection (ConfigInstance *instance, T *sectionPtr, const std::string &group="Sections")
 ~ConfigSection () override
 ConfigSection (const ConfigSection &)=delete
 ConfigSection (ConfigSection &&)=delete
ConfigSectionoperator= (const ConfigSection &)=delete
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

Protected Member Functions

 ConfigAddress (net::config::ConfigInstance *instance, const std::string &addressOptionName, const std::string &addressOptionDescription)
ConfigAddresssetBtAddressRequired (bool required=true)
ConfigAddresssetChannelRequired (bool required=true)
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

Protected Attributes

CLI::Option * btAddressOpt = nullptr
CLI::Option * channelOpt = nullptr

Private Types

using Super = ConfigAddressTypeT<net::rc::SocketAddress>

Private Member Functions

SocketAddressinit () final

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

template<template< typename SocketAddressT > typename ConfigAddressTypeT>
class net::rc::config::ConfigAddress< ConfigAddressTypeT >

Definition at line 77 of file ConfigAddress.h.

Member Typedef Documentation

◆ Super

template<template< typename SocketAddressT > typename ConfigAddressTypeT>
using net::rc::config::ConfigAddress< ConfigAddressTypeT >::Super = ConfigAddressTypeT<net::rc::SocketAddress>
private

Definition at line 81 of file ConfigAddress.h.

Constructor & Destructor Documentation

◆ ConfigAddress()

template<template< typename SocketAddress > typename ConfigAddressType>
net::rc::config::ConfigAddress< ConfigAddressType >::ConfigAddress ( net::config::ConfigInstance * instance,
const std::string & addressOptionName,
const std::string & addressOptionDescription )
protected

Definition at line 69 of file ConfigAddress.cpp.

72 : ConfigSection(instance, this)
75 "--host",
76 "Bluetooth address (format 01:23:45:67:89:AB)",
77 "address",
78 "00:00:00:00:00:00",
80 [](std::string& s) -> std::string {
81 // Classic 48-bit Bluetooth/MAC style: "01:23:45:67:89:AB"
82 static const std::regex re(R"(^([0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}$)");
83
84 if (std::regex_match(s, re)) {
85 return {}; // OK
86 }
87
88 return "Invalid Bluetooth address. Expected format like \"01:23:45:67:89:AB\" "
89 "(6 hex octets separated by ':').";
90 },
91 "BT_ADDR")
92 .name("BT_ADDR"));
93
95 "--channel",
96 "Channel number",
97 "channel",
98 "1",
99 CLI::Range(static_cast<uint16_t>(1), static_cast<uint16_t>(30)));
100 }
ConfigSection(ConfigInstance *instance, T *sectionPtr, const std::string &group="Sections")
std::string name
Definition SubCommand.h:250
CLI::Option * addOption(const std::string &name, const std::string &description, const std::string &typeName, const CLI::Validator &validator) const

Member Function Documentation

◆ configurable()

template<template< typename SocketAddressT > typename ConfigAddressTypeT>
void net::rc::config::ConfigAddress< ConfigAddressTypeT >::configurable ( bool configurable = true)
final

Definition at line 149 of file ConfigAddress.cpp.

149 {
152 }
void configurable(bool configurable=true) final
CLI::Option * setConfigurable(CLI::Option *option, bool configurable) const

References btAddressOpt, and channelOpt.

◆ getBtAddress()

template<template< typename SocketAddress > typename ConfigAddressType>
std::string net::rc::config::ConfigAddress< ConfigAddressType >::getBtAddress ( ) const

Definition at line 129 of file ConfigAddress.cpp.

129 {
130 return btAddressOpt->as<std::string>();
131 }

References btAddressOpt.

◆ getChannel()

template<template< typename SocketAddress > typename ConfigAddressType>
uint8_t net::rc::config::ConfigAddress< ConfigAddressType >::getChannel ( ) const

Definition at line 144 of file ConfigAddress.cpp.

144 {
145 return channelOpt->as<uint8_t>();
146 }

References channelOpt.

◆ init()

template<template< typename SocketAddress > typename ConfigAddressType>
SocketAddress * net::rc::config::ConfigAddress< ConfigAddressType >::init ( )
finalprivate

Definition at line 103 of file ConfigAddress.cpp.

103 {
106
107 return socketAddress;
108 }
SocketAddress * init() final

◆ setBtAddress()

template<template< typename SocketAddress > typename ConfigAddressType>
ConfigAddress< ConfigAddressType > & net::rc::config::ConfigAddress< ConfigAddressType >::setBtAddress ( const std::string & btAddress)

Definition at line 119 of file ConfigAddress.cpp.

119 {
121
123 required(btAddressOpt, false);
124
125 return *this;
126 }
SubCommand * required(bool required=true, bool force=true)
CLI::Option * setDefaultValue(CLI::Option *option, const ValueTypeT &value, bool clear=true) const
Definition SubCommand.h:347

References btAddressOpt.

Referenced by setSocketAddress().

Here is the caller graph for this function:

◆ setBtAddressRequired()

template<template< typename SocketAddress > typename ConfigAddressType>
ConfigAddress< ConfigAddressType > & net::rc::config::ConfigAddress< ConfigAddressType >::setBtAddressRequired ( bool required = true)
protected

Definition at line 155 of file ConfigAddress.cpp.

155 {
157
158 return *this;
159 }

References btAddressOpt.

Referenced by net::rc::stream::config::ConfigSocketClient::ConfigSocketClient().

Here is the caller graph for this function:

◆ setChannel()

template<template< typename SocketAddress > typename ConfigAddressType>
ConfigAddress< ConfigAddressType > & net::rc::config::ConfigAddress< ConfigAddressType >::setChannel ( uint8_t channel)

Definition at line 134 of file ConfigAddress.cpp.

134 {
136
138 required(channelOpt, false);
139
140 return *this;
141 }

References channelOpt.

Referenced by setSocketAddress().

Here is the caller graph for this function:

◆ setChannelRequired()

template<template< typename SocketAddress > typename ConfigAddressType>
ConfigAddress< ConfigAddressType > & net::rc::config::ConfigAddress< ConfigAddressType >::setChannelRequired ( bool required = true)
protected

Definition at line 162 of file ConfigAddress.cpp.

162 {
164
165 return *this;
166 }

References channelOpt.

Referenced by net::rc::stream::config::ConfigSocketClient::ConfigSocketClient(), and net::rc::stream::config::ConfigSocketServer::ConfigSocketServer().

Here is the caller graph for this function:

◆ setSocketAddress()

template<template< typename SocketAddress > typename ConfigAddressType>
ConfigAddress< ConfigAddressType > & net::rc::config::ConfigAddress< ConfigAddressType >::setSocketAddress ( const SocketAddress & socketAddress)

Definition at line 111 of file ConfigAddress.cpp.

111 {
114
115 return *this;
116 }
ConfigAddress & setChannel(uint8_t channel)
ConfigAddress & setBtAddress(const std::string &btAddress)

References net::rc::SocketAddress::getBtAddress(), net::rc::SocketAddress::getChannel(), setBtAddress(), and setChannel().

Here is the call graph for this function:

Member Data Documentation

◆ btAddressOpt

template<template< typename SocketAddressT > typename ConfigAddressTypeT>
CLI::Option* net::rc::config::ConfigAddress< ConfigAddressTypeT >::btAddressOpt = nullptr
protected

◆ channelOpt

template<template< typename SocketAddressT > typename ConfigAddressTypeT>
CLI::Option* net::rc::config::ConfigAddress< ConfigAddressTypeT >::channelOpt = nullptr
protected

Definition at line 107 of file ConfigAddress.h.

Referenced by configurable(), getChannel(), setChannel(), and setChannelRequired().


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