16#include "comms/details/FieldBase.h"
17#include "comms/details/macro_common.h"
18#include "comms/details/fields_access.h"
19#include "comms/details/field_alias.h"
31template <
typename... TOptions>
32class Field :
public details::FieldBase<TOptions...>
34 using BaseImpl = details::FieldBase<TOptions...>;
39 using Endian =
typename BaseImpl::Endian;
127 template <
typename T,
typename TIter>
130 writeData<sizeof(T), T>(value, iter);
147 template <std::
size_t TSize,
typename T,
typename TIter>
150 static_assert(TSize <=
sizeof(T),
151 "Cannot put more bytes than type contains");
152 return util::writeData<TSize, T>(value, iter,
Endian());
168 template <
typename T,
typename TIter>
171 return readData<T, sizeof(T)>(iter);
188 template <
typename T, std::
size_t TSize,
typename TIter>
191 static_assert(TSize <=
sizeof(T),
192 "Cannot get more bytes than type contains");
193 return util::readData<T, TSize>(iter,
Endian());
236#define COMMS_FIELD_MEMBERS_ACCESS(...) \
237 COMMS_EXPAND(COMMS_DEFINE_FIELD_ENUM(__VA_ARGS__)) \
238 COMMS_FIELD_VALUE_ACCESS_FUNC { \
239 auto& val = comms::field::toFieldBase(*this).value(); \
240 using AllFieldsTuple = typename std::decay<decltype(val)>::type; \
241 static_assert(std::tuple_size<AllFieldsTuple>::value == FieldIdx_numOfValues, \
242 "Invalid number of names for fields tuple"); \
245 COMMS_FIELD_VALUE_ACCESS_CONST_FUNC { \
246 auto& val = comms::field::toFieldBase(*this).value(); \
247 using AllFieldsTuple = typename std::decay<decltype(val)>::type; \
248 static_assert(std::tuple_size<AllFieldsTuple>::value == FieldIdx_numOfValues, \
249 "Invalid number of names for fields tuple"); \
252 COMMS_EXPAND(COMMS_DO_FIELD_ACC_FUNC(ValueType, value(), __VA_ARGS__))
266#define COMMS_FIELD_MEMBERS_ACCESS_NOTEMPLATE(...) \
267 COMMS_EXPAND(COMMS_DEFINE_FIELD_ENUM(__VA_ARGS__)) \
268 COMMS_EXPAND(COMMS_DO_FIELD_ACC_FUNC_NOTEMPLATE(__VA_ARGS__))
380#define COMMS_FIELD_MEMBERS_NAMES(...) \
381 COMMS_EXPAND(COMMS_FIELD_MEMBERS_ACCESS(__VA_ARGS__)) \
382 COMMS_EXPAND(COMMS_DO_FIELD_TYPEDEF(typename Base::ValueType, Field_, FieldIdx_, __VA_ARGS__))
390#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:33
static constexpr bool canWrite()
Default check of whether the field has a consistent value for writing.
Definition Field.h:100
static void writeData(T value, TIter &iter)
Write data into the output buffer.
Definition Field.h:128
static constexpr bool setVersion(VersionType)
Default version update functionality.
Definition Field.h:109
static constexpr bool isVersionDependent()
Default check of whether the field is version dependent.
Definition Field.h:63
static constexpr bool refresh()
Default refresh functionality.
Definition Field.h:56
static T readData(TIter &iter)
Read data from input buffer.
Definition Field.h:169
static constexpr bool hasReadNoStatus()
Default check of whether the field has readNoStatus() member function.
Definition Field.h:77
typename BaseImpl::Endian Endian
Endian type.
Definition Field.h:39
typename BaseImpl::VersionType VersionType
Version type.
Definition Field.h:42
static constexpr bool hasNonDefaultRefresh()
Default check of whether the field has defines refresh functionality.
Definition Field.h:70
static constexpr bool hasWriteNoStatus()
Default check of whether the field has writeNoStatus() member function.
Definition Field.h:84
static void writeData(T value, TIter &iter)
Write partial data into the output buffer.
Definition Field.h:148
static T readData(TIter &iter)
Read partial data from input buffer.
Definition Field.h:189
static constexpr bool valid()
Default validity check.
Definition Field.h:47
static constexpr bool hasVarLength()
Default check of whether the field has variable length definition via comms::option::def::VarLength o...
Definition Field.h:92
Main namespace for all classes / functions of COMMS library.