15#include "comms/details/FieldBase.h"
16#include "comms/details/field_alias.h"
17#include "comms/details/fields_access.h"
18#include "comms/details/macro_common.h"
34template <
typename... TOptions>
35class Field :
public details::FieldBase<TOptions...>
37 using BaseImpl = details::FieldBase<TOptions...>;
42 using Endian =
typename BaseImpl::Endian;
137 template <
typename T,
typename TIter>
140 writeData<sizeof(T), T>(value, iter);
157 template <std::
size_t TSize,
typename T,
typename TIter>
160 static_assert(TSize <=
sizeof(T),
161 "Cannot put more bytes than type contains");
162 return util::writeData<TSize, T>(value, iter,
Endian());
178 template <
typename T,
typename TIter>
181 return readData<T, sizeof(T)>(iter);
198 template <
typename T, std::
size_t TSize,
typename TIter>
201 static_assert(TSize <=
sizeof(T),
202 "Cannot get more bytes than type contains");
203 return util::readData<T, TSize>(iter,
Endian());
246#define COMMS_FIELD_MEMBERS_ACCESS(...) \
247 COMMS_EXPAND(COMMS_DEFINE_FIELD_ENUM(__VA_ARGS__)) \
248 COMMS_FIELD_VALUE_ACCESS_FUNC { \
249 auto& val = comms::field::toFieldBase(*this).value(); \
250 using AllFieldsTuple = typename std::decay<decltype(val)>::type; \
251 static_assert(std::tuple_size<AllFieldsTuple>::value == FieldIdx_numOfValues, \
252 "Invalid number of names for fields tuple"); \
255 COMMS_FIELD_VALUE_ACCESS_CONST_FUNC { \
256 auto& val = comms::field::toFieldBase(*this).value(); \
257 using AllFieldsTuple = typename std::decay<decltype(val)>::type; \
258 static_assert(std::tuple_size<AllFieldsTuple>::value == FieldIdx_numOfValues, \
259 "Invalid number of names for fields tuple"); \
262 COMMS_EXPAND(COMMS_DO_FIELD_ACC_FUNC(ValueType, value(), __VA_ARGS__))
276#define COMMS_FIELD_MEMBERS_ACCESS_NOTEMPLATE(...) \
277 COMMS_EXPAND(COMMS_DEFINE_FIELD_ENUM(__VA_ARGS__)) \
278 COMMS_EXPAND(COMMS_DO_FIELD_ACC_FUNC_NOTEMPLATE(__VA_ARGS__))
390#define COMMS_FIELD_MEMBERS_NAMES(...) \
391 COMMS_EXPAND(COMMS_FIELD_MEMBERS_ACCESS(__VA_ARGS__)) \
392 COMMS_EXPAND(COMMS_DO_FIELD_TYPEDEF(typename Base::ValueType, Field_, FieldIdx_, __VA_ARGS__))
400#define COMMS_FIELD_ALIAS(f_, ...) COMMS_DO_ALIAS(field_, f_, __VA_ARGS__)
Contains functions for raw data access / (de)serialization.
Base class to all the field classes.
Definition Field.h:36
static constexpr bool canWrite()
Default check of whether the field has a consistent value for writing.
Definition Field.h:103
static void writeData(T value, TIter &iter)
Write data into the output buffer.
Definition Field.h:138
static constexpr bool setVersion(VersionType)
Default version update functionality.
Definition Field.h:112
static constexpr bool isVersionDependent()
Default check of whether the field is version dependent.
Definition Field.h:66
static constexpr bool refresh()
Default refresh functionality.
Definition Field.h:59
static T readData(TIter &iter)
Read data from input buffer.
Definition Field.h:179
static constexpr bool hasReadNoStatus()
Default check of whether the field has readNoStatus() member function.
Definition Field.h:80
typename BaseImpl::Endian Endian
Endian type.
Definition Field.h:42
typename BaseImpl::VersionType VersionType
Version type.
Definition Field.h:45
static constexpr bool hasNonDefaultRefresh()
Default check of whether the field has defines refresh functionality.
Definition Field.h:73
static constexpr bool hasWriteNoStatus()
Default check of whether the field has writeNoStatus() member function.
Definition Field.h:87
static void writeData(T value, TIter &iter)
Write partial data into the output buffer.
Definition Field.h:158
static T readData(TIter &iter)
Read partial data from input buffer.
Definition Field.h:199
static constexpr bool valid()
Default validity check.
Definition Field.h:50
static constexpr bool hasVarLength()
Default check of whether the field has variable length definition via comms::option::def::VarLength o...
Definition Field.h:95
static constexpr bool hasName()
Check of whether the field class defines name() function.
Definition Field.h:119
Main namespace for all classes / functions of COMMS library.