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

#include <ConfigAddress.h>

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

Public Member Functions

ConfigAddresssetSocketAddress (const SocketAddress &socketAddress)
ConfigAddresssetBtAddress (const std::string &btAddress)
std::string getBtAddress () const
ConfigAddresssetPsm (uint16_t psm)
uint16_t getPsm () 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)
ConfigAddresssetPsmRequired (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 * psmOpt = nullptr

Private Types

using Super = ConfigAddressTypeT<net::l2::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::l2::config::ConfigAddress< ConfigAddressTypeT >

Definition at line 77 of file ConfigAddress.h.

Member Typedef Documentation

◆ Super

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

Definition at line 81 of file ConfigAddress.h.

Constructor & Destructor Documentation

◆ ConfigAddress()

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

Definition at line 70 of file ConfigAddress.cpp.

73 : ConfigSection(instance, this)
76 "--host",
77 "Bluetooth address (format 01:23:45:67:89:AB)",
78 "address",
79 "00:00:00:00:00:00",
81 [](std::string& s) -> std::string {
82 // Classic 48-bit Bluetooth/MAC style: "01:23:45:67:89:AB"
83 static const std::regex re(R"(^([0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}$)");
84
85 if (std::regex_match(s, re)) {
86 return {}; // OK
87 }
88
89 return "Invalid Bluetooth address. Expected format like \"01:23:45:67:89:AB\" "
90 "(6 hex octets separated by ':').";
91 },
92 "BT_ADDR")
93 .name("BT_ADDR"));
94
95 psmOpt = addOption( //
96 "--psm",
97 "Protocol service multiplexer",
98 "psm",
99 "0",
101 }
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::l2::config::ConfigAddress< ConfigAddressTypeT >::configurable ( bool configurable = true)
final

Definition at line 150 of file ConfigAddress.cpp.

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

References btAddressOpt, and psmOpt.

◆ getBtAddress()

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

Definition at line 130 of file ConfigAddress.cpp.

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

References btAddressOpt.

◆ getPsm()

template<template< typename SocketAddress > typename ConfigAddressType>
uint16_t net::l2::config::ConfigAddress< ConfigAddressType >::getPsm ( ) const

Definition at line 145 of file ConfigAddress.cpp.

145 {
146 return psmOpt->as<uint16_t>();
147 }

References psmOpt.

◆ init()

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

Definition at line 104 of file ConfigAddress.cpp.

104 {
107
108 return socketAddress;
109 }
SocketAddress * init() final

References btAddressOpt, net::l2::SocketAddress::init(), psmOpt, and net::l2::SocketAddress::SocketAddress().

Here is the call graph for this function:

◆ setBtAddress()

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

Definition at line 120 of file ConfigAddress.cpp.

120 {
122
124 required(btAddressOpt, false);
125
126 return *this;
127 }
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::l2::config::ConfigAddress< ConfigAddressType >::setBtAddressRequired ( bool required = true)
protected

Definition at line 156 of file ConfigAddress.cpp.

156 {
158
159 return *this;
160 }

References btAddressOpt.

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

Here is the caller graph for this function:

◆ setPsm()

template<template< typename SocketAddress > typename ConfigAddressType>
ConfigAddress< ConfigAddressType > & net::l2::config::ConfigAddress< ConfigAddressType >::setPsm ( uint16_t psm)

Definition at line 135 of file ConfigAddress.cpp.

135 {
137
139 required(psmOpt, false);
140
141 return *this;
142 }

References psmOpt.

Referenced by setSocketAddress().

Here is the caller graph for this function:

◆ setPsmRequired()

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

Definition at line 163 of file ConfigAddress.cpp.

163 {
164 this->required(psmOpt, required);
165
166 return *this;
167 }

References psmOpt.

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

Here is the caller graph for this function:

◆ setSocketAddress()

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

Definition at line 112 of file ConfigAddress.cpp.

112 {
115
116 return *this;
117 }
ConfigAddress & setPsm(uint16_t psm)
ConfigAddress & setBtAddress(const std::string &btAddress)

References net::l2::SocketAddress::getBtAddress(), net::l2::SocketAddress::getPsm(), setBtAddress(), and setPsm().

Here is the call graph for this function:

Member Data Documentation

◆ btAddressOpt

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

◆ psmOpt

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

Definition at line 107 of file ConfigAddress.h.

Referenced by configurable(), getPsm(), init(), setPsm(), and setPsmRequired().


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