35#ifndef _OPENLCB_CONFIGENTRY_HXX_
36#define _OPENLCB_CONFIGENTRY_HXX_
73 constexpr unsigned offset()
const
96 template<
typename... Args>
126 template <
class T>
void raw_write(
int fd,
const T &value)
const
242 static constexpr unsigned size()
247 constexpr unsigned end_offset()
const
249 return offset() +
size();
252 static constexpr NumericConfigRenderer config_renderer()
254 return NumericConfigRenderer(
"int",
size());
278 if (value < min_value) {
282 if (value > max_value) {
301 if (value < min_value || value > max_value)
343 template <
typename T>
372 static constexpr
unsigned size()
377 constexpr unsigned end_offset()
const
379 return offset() +
size();
382 static constexpr AtomConfigRenderer config_renderer()
384 return AtomConfigRenderer(
"string",
size());
387 string read(
int fd)
const
389 string s(
size(),
'\0');
391 size_t real_len = strlen(s.c_str());
396 void write(
int fd,
string data)
const
398 if (data.size() >
size() - 1) {
399 data.resize(
size() - 1);
414 static_assert(SIZE <= 256,
"BytesConfigEntry cannot store longer than 255");
421 static constexpr unsigned size()
426 constexpr unsigned end_offset()
const
428 return offset() +
size();
431 static constexpr EmptyGroupConfigRenderer config_renderer()
433 return EmptyGroupConfigRenderer(
size());
436 string read(
int fd)
const
438 string s(
size(),
'\0');
440 size_t real_len = (
unsigned char)s[0];
441 return s.substr(1, real_len);
444 void write(
int fd,
string data)
const
447 data.insert(0, 1, data.size());
Helper class for rendering an atom data element into the cdi.xml.
Implementation class for internal data bytes configuration entries.
static constexpr unsigned size()
Storage bytes occupied by the instance in the config file.
Base class for individual configuration entries.
void raw_write(int fd, const T &value) const
Writes a given typed variable to the configuration file.
T raw_read(int fd) const
Reads a given typed variable from 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.
Class representing a particular location in the configuration space.
unsigned offset_
zero-based offset from the beginning of the configuration file.
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.
Implementation class for event ID configuration entries.
Implementation class for the condifuration options of a CDI group element.
Implementation class for numeric configuration entries, templated by the integer type.
static int32_t endian_convert(int32_t d)
Performs endian conversion.
static uint32_t endian_convert(uint32_t d)
Performs endian conversion.
static int16_t endian_convert(int16_t d)
Performs endian conversion.
void write(int fd, TR d) const
Writes the data to the configuration file.
static uint8_t endian_convert(uint8_t d)
Performs endian conversion.
static int64_t endian_convert(int64_t d)
Performs endian conversion.
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.
static constexpr unsigned size()
Storage bytes occupied by the instance in the config 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(int fd) const
Reads the data from the configuration file.
static uint64_t endian_convert(uint64_t d)
Performs endian conversion.
static uint16_t endian_convert(uint16_t d)
Performs endian conversion.
static int8_t endian_convert(int8_t d)
Performs endian conversion.
Implementation class for string configuration entries.
static constexpr unsigned size()
Storage bytes occupied by the instance in the config file.
#define HASSERT(x)
Checks that the value of expression x is true, else terminates the current process.
#define INHERIT_CONSTEXPR_CONSTRUCTOR(CURRENT_CLASS, BASE_CLASS)
Adds a constexpr constructor to the current class that proxies every argument to the base constructor...
std::function< void(unsigned)> EventOffsetCallback
Function declaration that will be called with all event offsets that exist in the configuration space...
NumericConfigEntry< uint64_t > Uint64ConfigEntry
Unsigned numeric config entry with 8 bytes width.