Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
openlcb::NumericConfigEntry< TR > Class Template Reference

Implementation class for numeric configuration entries, templated by the integer type. More...

#include <ConfigEntry.hxx>

Inheritance diagram for openlcb::NumericConfigEntry< TR >:
openlcb::ConfigEntryBase openlcb::ConfigReference openlcb::EventConfigEntry

Public Member Functions

constexpr unsigned end_offset () const
 
TR read (int fd) const
 Reads the data from the configuration file.
 
TR read_or_write_trimmed (int fd, TR min_value, TR max_value)
 Reads data from configuration file obeying a specific trimming.
 
TR read_or_write_default (int fd, TR min_value, TR max_value, TR def_value)
 Reads data from configuration file if the value is valid.
 
void write (int fd, TR d) const
 Writes the data to the configuration file.
 
- Public Member Functions inherited from openlcb::ConfigReference
constexpr ConfigReference (unsigned offset)
 Initializes the config reference from a configuration space offset.
 
constexpr ConfigReference (const ConfigReference &ref)
 Initializes the config reference from an existing config reference.
 
constexpr unsigned offset () const
 

Static Public Member Functions

static uint8_t endian_convert (uint8_t d)
 Performs endian conversion.
 
static uint16_t endian_convert (uint16_t d)
 Performs endian conversion.
 
static uint32_t endian_convert (uint32_t d)
 Performs endian conversion.
 
static uint64_t endian_convert (uint64_t d)
 Performs endian conversion.
 
static int8_t endian_convert (int8_t d)
 Performs endian conversion.
 
static int16_t endian_convert (int16_t d)
 Performs endian conversion.
 
static int32_t endian_convert (int32_t d)
 Performs endian conversion.
 
static int64_t endian_convert (int64_t d)
 Performs endian conversion.
 
static constexpr unsigned size ()
 Storage bytes occupied by the instance in the config file.
 
static constexpr NumericConfigRenderer config_renderer ()
 
- Static Public Member Functions inherited from openlcb::ConfigEntryBase
template<typename... Args>
static constexpr GroupConfigOptions group_opts (Args... args)
 
static void handle_events (const EventOffsetCallback &fn)
 

Additional Inherited Members

- Protected Member Functions inherited from openlcb::ConfigEntryBase
template<class T >
raw_read (int fd) const
 Reads a given typed variable from the configuration file.
 
template<class T >
void raw_write (int fd, const T &value) const
 Writes a given typed variable to the configuration file.
 
void repeated_read (int fd, void *buf, size_t size) const
 Performs a reliable read from the given FD.
 
void repeated_write (int fd, const void *buf, size_t size) const
 Performs a reliable write to the given FD.
 
- Protected Attributes inherited from openlcb::ConfigReference
unsigned offset_
 zero-based offset from the beginning of the configuration file.
 

Detailed Description

template<class TR>
class openlcb::NumericConfigEntry< TR >

Implementation class for numeric configuration entries, templated by the integer type.

Definition at line 150 of file ConfigEntry.hxx.

Member Function Documentation

◆ config_renderer()

template<class TR >
static constexpr NumericConfigRenderer openlcb::NumericConfigEntry< TR >::config_renderer ( )
inlinestaticconstexpr

Definition at line 252 of file ConfigEntry.hxx.

◆ end_offset()

template<class TR >
constexpr unsigned openlcb::NumericConfigEntry< TR >::end_offset ( ) const
inlineconstexpr

Definition at line 247 of file ConfigEntry.hxx.

◆ endian_convert() [1/8]

template<class TR >
static int16_t openlcb::NumericConfigEntry< TR >::endian_convert ( int16_t  d)
inlinestatic

Performs endian conversion.

Parameters
dnetwork-byte-order data
Returns
host-byte-order data

Definition at line 212 of file ConfigEntry.hxx.

◆ endian_convert() [2/8]

template<class TR >
static int32_t openlcb::NumericConfigEntry< TR >::endian_convert ( int32_t  d)
inlinestatic

Performs endian conversion.

Parameters
dnetwork-byte-order data
Returns
host-byte-order data

Definition at line 222 of file ConfigEntry.hxx.

◆ endian_convert() [3/8]

template<class TR >
static int64_t openlcb::NumericConfigEntry< TR >::endian_convert ( int64_t  d)
inlinestatic

Performs endian conversion.

Parameters
dnetwork-byte-order data
Returns
host-byte-order data

Definition at line 232 of file ConfigEntry.hxx.

◆ endian_convert() [4/8]

template<class TR >
static int8_t openlcb::NumericConfigEntry< TR >::endian_convert ( int8_t  d)
inlinestatic

Performs endian conversion.

Parameters
dnetwork-byte-order data
Returns
host-byte-order data

Definition at line 202 of file ConfigEntry.hxx.

◆ endian_convert() [5/8]

template<class TR >
static uint16_t openlcb::NumericConfigEntry< TR >::endian_convert ( uint16_t  d)
inlinestatic

Performs endian conversion.

Parameters
dnetwork-byte-order data
Returns
host-byte-order data

Definition at line 171 of file ConfigEntry.hxx.

◆ endian_convert() [6/8]

template<class TR >
static uint32_t openlcb::NumericConfigEntry< TR >::endian_convert ( uint32_t  d)
inlinestatic

Performs endian conversion.

Parameters
dnetwork-byte-order data
Returns
host-byte-order data

Definition at line 181 of file ConfigEntry.hxx.

◆ endian_convert() [7/8]

template<class TR >
static uint64_t openlcb::NumericConfigEntry< TR >::endian_convert ( uint64_t  d)
inlinestatic

Performs endian conversion.

Parameters
dnetwork-byte-order data
Returns
host-byte-order data

Definition at line 191 of file ConfigEntry.hxx.

◆ endian_convert() [8/8]

template<class TR >
static uint8_t openlcb::NumericConfigEntry< TR >::endian_convert ( uint8_t  d)
inlinestatic

Performs endian conversion.

Parameters
dnetwork-byte-order data
Returns
host-byte-order data

Definition at line 161 of file ConfigEntry.hxx.

◆ read()

template<class TR >
TR openlcb::NumericConfigEntry< TR >::read ( int  fd) const
inline

Reads the data from the configuration file.

Parameters
fdfile descriptor of the config file.
Returns
value of the configuration atom that *this represents.

Definition at line 263 of file ConfigEntry.hxx.

◆ read_or_write_default()

template<class TR >
TR openlcb::NumericConfigEntry< TR >::read_or_write_default ( int  fd,
TR  min_value,
TR  max_value,
TR  def_value 
)
inline

Reads data from configuration file if the value is valid.

If the value violates the trimming constraints, the configuration file will be overwritten with the default value.

Parameters
fdthe descriptor of the config file.
min_valueminimum acceptable value
max_valuemaximum acceptable value
def_valuedefault value to write when out of range
Returns
current value after trimming.

Definition at line 298 of file ConfigEntry.hxx.

◆ read_or_write_trimmed()

template<class TR >
TR openlcb::NumericConfigEntry< TR >::read_or_write_trimmed ( int  fd,
TR  min_value,
TR  max_value 
)
inline

Reads data from configuration file obeying a specific trimming.

If the value violates the trimming constraints, the configuration file will be overwritten with a trimmed value.

Parameters
fdthe descriptor of the config file.
min_valueminimum acceptable value
max_valuemaximum acceptable value
Returns
current value after trimming.

Definition at line 276 of file ConfigEntry.hxx.

◆ size()

template<class TR >
static constexpr unsigned openlcb::NumericConfigEntry< TR >::size ( )
inlinestaticconstexpr

Storage bytes occupied by the instance in the config file.

Returns
number of bytes that the config parser offset will be incremented by this entry.

Definition at line 242 of file ConfigEntry.hxx.

◆ write()

template<class TR >
void openlcb::NumericConfigEntry< TR >::write ( int  fd,
TR  d 
) const
inline

Writes the data to the configuration file.

Parameters
fdfile descriptor of the config file.
valueof the configuration atom that should be written.

Definition at line 315 of file ConfigEntry.hxx.


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