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;
134 template <
typename T,
typename TIter>
137 writeData<sizeof(T), T>(value, iter);
154 template <std::
size_t TSize,
typename T,
typename TIter>
157 static_assert(TSize <=
sizeof(T),
158 "Cannot put more bytes than type contains");
159 return util::writeData<TSize, T>(value, iter,
Endian());
175 template <
typename T,
typename TIter>
178 return readData<T, sizeof(T)>(iter);
195 template <
typename T, std::
size_t TSize,
typename TIter>
198 static_assert(TSize <=
sizeof(T),
199 "Cannot get more bytes than type contains");
200 return util::readData<T, TSize>(iter,
Endian());
243#define COMMS_FIELD_MEMBERS_ACCESS(...) \
244 COMMS_EXPAND(COMMS_DEFINE_FIELD_ENUM(__VA_ARGS__)) \
245 COMMS_FIELD_VALUE_ACCESS_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_FIELD_VALUE_ACCESS_CONST_FUNC { \
253 auto& val = comms::field::toFieldBase(*this).value(); \
254 using AllFieldsTuple = typename std::decay<decltype(val)>::type; \
255 static_assert(std::tuple_size<AllFieldsTuple>::value == FieldIdx_numOfValues, \
256 "Invalid number of names for fields tuple"); \
259 COMMS_EXPAND(COMMS_DO_FIELD_ACC_FUNC(ValueType, value(), __VA_ARGS__))
273#define COMMS_FIELD_MEMBERS_ACCESS_NOTEMPLATE(...) \
274 COMMS_EXPAND(COMMS_DEFINE_FIELD_ENUM(__VA_ARGS__)) \
275 COMMS_EXPAND(COMMS_DO_FIELD_ACC_FUNC_NOTEMPLATE(__VA_ARGS__))
387#define COMMS_FIELD_MEMBERS_NAMES(...) \
388 COMMS_EXPAND(COMMS_FIELD_MEMBERS_ACCESS(__VA_ARGS__)) \
389 COMMS_EXPAND(COMMS_DO_FIELD_TYPEDEF(typename Base::ValueType, Field_, FieldIdx_, __VA_ARGS__))
397#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:135
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:176
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:155
static T readData(TIter &iter)
Read partial data from input buffer.
Definition Field.h:196
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
static constexpr bool hasName()
Check of whether the field class defines name() function.
Definition Field.h:116
Main namespace for all classes / functions of COMMS library.