16#include "details/OptionsParser.h"
17#include "basic/EnumValue.h"
18#include "details/AdaptBasicField.h"
73template <
typename TFieldBase,
typename TEnum,
typename... TOptions>
74class EnumValue :
public details::AdaptBasicFieldT<basic::EnumValue<TFieldBase, TEnum>, TOptions...>
76 using BaseImpl = details::AdaptBasicFieldT<basic::EnumValue<TFieldBase, TEnum>, TOptions...>;
77 static_assert(std::is_enum<TEnum>::value,
"TEnum must be enum type");
84 using Endian =
typename BaseImpl::Endian;
126 return ParsedOptions::HasFailOnInvalid;
133 return ParsedOptions::HasIgnoreInvalid;
140 return ParsedOptions::HasEmptySerialization;
147 return ParsedOptions::HasFieldType;
154 return ParsedOptions::HasFixedValue;
161 return ParsedOptions::HasName;
167 return BaseImpl::value();
173 return BaseImpl::value();
180 return BaseImpl::getValue();
185 template <
typename U>
188 BaseImpl::setValue(std::forward<U>(val));
195 return BaseImpl::length();
202 return BaseImpl::minLength();
209 return BaseImpl::maxLength();
217 template <
typename TIter>
220 return BaseImpl::read(iter, size);
227 return BaseImpl::hasReadNoStatus();
235 template <
typename TIter>
238 BaseImpl::readNoStatus(iter);
244 return BaseImpl::canWrite();
252 template <
typename TIter>
255 return BaseImpl::write(iter, size);
262 return BaseImpl::hasWriteNoStatus();
270 template <
typename TIter>
273 BaseImpl::writeNoStatus(iter);
279 return BaseImpl::valid();
286 return BaseImpl::refresh();
292 return ParsedOptions::HasCustomVersionUpdate || BaseImpl::isVersionDependent();
298 return BaseImpl::hasNonDefaultRefresh();
305 return BaseImpl::getVersion();
312 return BaseImpl::setVersion(
version);
324 BaseImpl::setForcedLength(len);
331 return BaseImpl::getForcedLength();
335 using BaseImpl::readData;
336 using BaseImpl::writeData;
338 static_assert(!ParsedOptions::HasSequenceElemLengthForcing,
339 "comms::option::def::SequenceElemLengthForcingEnabled option is not applicable to EnumValue field");
340 static_assert(!ParsedOptions::HasSequenceSizeForcing,
341 "comms::option::def::SequenceSizeForcingEnabled option is not applicable to EnumValue field");
342 static_assert(!ParsedOptions::HasSequenceLengthForcing,
343 "comms::option::def::SequenceLengthForcingEnabled option is not applicable to EnumValue field");
344 static_assert(!ParsedOptions::HasSequenceFixedSize,
345 "comms::option::def::SequenceFixedSize option is not applicable to EnumValue field");
346 static_assert(!ParsedOptions::HasSequenceFixedSizeUseFixedSizeStorage,
347 "comms::option::app::SequenceFixedSizeUseFixedSizeStorage option is not applicable to EnumValue field");
348 static_assert(!ParsedOptions::HasSequenceSizeFieldPrefix,
349 "comms::option::def::SequenceSizeFieldPrefix option is not applicable to EnumValue field");
350 static_assert(!ParsedOptions::HasSequenceSerLengthFieldPrefix,
351 "comms::option::def::SequenceSerLengthFieldPrefix option is not applicable to EnumValue field");
352 static_assert(!ParsedOptions::HasSequenceElemSerLengthFieldPrefix,
353 "comms::option::def::SequenceElemSerLengthFieldPrefix option is not applicable to EnumValue field");
354 static_assert(!ParsedOptions::HasSequenceElemFixedSerLengthFieldPrefix,
355 "comms::option::def::SequenceElemSerLengthFixedFieldPrefix option is not applicable to EnumValue field");
356 static_assert(!ParsedOptions::HasSequenceTrailingFieldSuffix,
357 "comms::option::def::SequenceTrailingFieldSuffix option is not applicable to EnumValue field");
358 static_assert(!ParsedOptions::HasSequenceTerminationFieldSuffix,
359 "comms::option::def::SequenceTerminationFieldSuffix option is not applicable to EnumValue field");
360 static_assert(!ParsedOptions::HasFixedSizeStorage,
361 "comms::option::app::FixedSizeStorage option is not applicable to EnumValue field");
362 static_assert(!ParsedOptions::HasCustomStorageType,
363 "comms::option::app::CustomStorageType option is not applicable to EnumValue field");
364 static_assert(!ParsedOptions::HasScalingRatio,
365 "comms::option::def::ScalingRatio option is not applicable to EnumValue field");
366 static_assert(!ParsedOptions::HasUnits,
367 "comms::option::def::Units option is not applicable to EnumValue field");
368 static_assert(!ParsedOptions::HasOrigDataView,
369 "comms::option::app::OrigDataView option is not applicable to EnumValue field");
370 static_assert(!ParsedOptions::HasVersionsRange,
371 "comms::option::def::ExistsBetweenVersions (or similar) option is not applicable to EnumValue field");
372 static_assert(!ParsedOptions::HasMissingOnReadFail,
373 "comms::option::def::MissingOnReadFail option is not applicable to EnumValue field");
374 static_assert(!ParsedOptions::HasMissingOnInvalid,
375 "comms::option::def::MissingOnInvalid option is not applicable to EnumValue field");
385template <
typename TFieldBase,
typename TEnum,
typename... TOptions>
390 return field1.value() == field2.value();
398template <
typename TFieldBase,
typename TEnum,
typename... TOptions>
403 return field1.value() != field2.value();
411template <
typename TFieldBase,
typename TEnum,
typename... TOptions>
416 return field1.value() < field2.value();
427 return std::is_same<typename T::CommsTag, tag::Enum>::value;
433template <
typename TFieldBase,
typename TEnum,
typename... TOptions>
435EnumValue<TFieldBase, TEnum, TOptions...>&
444template <
typename TFieldBase,
typename TEnum,
typename... TOptions>
446const EnumValue<TFieldBase, TEnum, TOptions...>&
Enumerator value field.
Definition EnumValue.h:75
ValueType & value()
Get access to enum value storage.
Definition EnumValue.h:171
constexpr bool isEnumValue()
Compile time check function of whether a provided type is any variant of comms::field::EnumValue.
Definition EnumValue.h:425
bool operator!=(const EnumValue< TFieldBase, TEnum, TOptions... > &field1, const EnumValue< TFieldBase, TEnum, TOptions... > &field2) noexcept
Non-equality comparison operator.
Definition EnumValue.h:399
void writeNoStatus(TIter &iter) const
Write current field value to output data sequence without error check and status report.
Definition EnumValue.h:271
typename BaseImpl::VersionType VersionType
Version type.
Definition EnumValue.h:87
static constexpr std::size_t maxLength()
Get maximal length that is required to serialise field of this type.
Definition EnumValue.h:207
const EnumValue< TFieldBase, TEnum, TOptions... > & toFieldBase(const EnumValue< TFieldBase, TEnum, TOptions... > &field)
Upcast type of the field definition to its parent comms::field::EnumValue type in order to have acces...
Definition EnumValue.h:447
VersionType getVersion() const
Get version of the field.
Definition EnumValue.h:303
static constexpr bool hasNonDefaultRefresh()
Compile time check if this class has non-default refresh functionality.
Definition EnumValue.h:296
bool valid() const
Check validity of the field value.
Definition EnumValue.h:277
void readNoStatus(TIter &iter)
Read field value from input data sequence without error check and status report.
Definition EnumValue.h:236
typename BaseImpl::CommsTag CommsTag
Tag indicating type of the field.
Definition EnumValue.h:93
void setValue(U &&val)
Set value.
Definition EnumValue.h:186
const ValueType & getValue() const
Get value.
Definition EnumValue.h:178
static constexpr bool hasReadNoStatus()
Compile time check of whether the field has proper readNoStatus() member function.
Definition EnumValue.h:225
EnumValue(const EnumValue &)=default
Copy constructor.
bool operator<(const EnumValue< TFieldBase, TEnum, TOptions... > &field1, const EnumValue< TFieldBase, TEnum, TOptions... > &field2) noexcept
Equivalence comparison operator.
Definition EnumValue.h:412
TFieldBase FieldBase
Base class provided in the first template parameter.
Definition EnumValue.h:81
static constexpr bool hasFixedValue()
Compile time inquiry of whether comms::option::def::FixedValue option has been used.
Definition EnumValue.h:152
static constexpr bool hasIgnoreInvalid()
Compile time inquiry of whether comms::option::def::IgnoreInvalid option has been used.
Definition EnumValue.h:131
int getForcedLength() const
Get forced serialization length.
Definition EnumValue.h:329
ErrorStatus read(TIter &iter, std::size_t size)
Read field value from input data sequence.
Definition EnumValue.h:218
constexpr std::size_t length() const
Get length required to serialise the current field value.
Definition EnumValue.h:193
bool refresh()
Refresh the field's value.
Definition EnumValue.h:284
typename ParsedOptions::FieldType FieldType
Type of actual extending field specified via comms::option::def::FieldType.
Definition EnumValue.h:102
static constexpr bool hasWriteNoStatus()
Compile time check of whether the field has proper writeNoStatus() member function.
Definition EnumValue.h:260
static constexpr bool hasEmptySerialization()
Compile time inquiry of whether comms::option::def::EmptySerialization option has been used.
Definition EnumValue.h:138
EnumValue(const ValueType &val)
Constructor.
Definition EnumValue.h:108
ErrorStatus write(TIter &iter, std::size_t size) const
Write current field value to output data sequence.
Definition EnumValue.h:253
typename BaseImpl::ValueType ValueType
Type of underlying enum value.
Definition EnumValue.h:97
static constexpr bool isVersionDependent()
Compile time check if this class is version dependent.
Definition EnumValue.h:290
static constexpr bool hasFieldType()
Compile time inquiry of whether comms::option::def::FieldType option has been used.
Definition EnumValue.h:145
static constexpr std::size_t minLength()
Get minimal length that is required to serialise field of this type.
Definition EnumValue.h:200
~EnumValue() noexcept=default
Destructor.
void setForcedLength(int len)
Force serialization length of the field.
Definition EnumValue.h:322
details::OptionsParser< TOptions... > ParsedOptions
All the options provided to this class bundled into struct.
Definition EnumValue.h:90
EnumValue()=default
Default constructor.
bool operator==(const EnumValue< TFieldBase, TEnum, TOptions... > &field1, const EnumValue< TFieldBase, TEnum, TOptions... > &field2) noexcept
Equality comparison operator.
Definition EnumValue.h:386
bool canWrite() const
Check of whether the field has a consistent value for writing.
Definition EnumValue.h:242
EnumValue< TFieldBase, TEnum, TOptions... > & toFieldBase(EnumValue< TFieldBase, TEnum, TOptions... > &field)
Upcast type of the field definition to its parent comms::field::EnumValue type in order to have acces...
Definition EnumValue.h:436
static constexpr bool hasFailOnInvalid()
Compile time inquiry of whether comms::option::def::FailOnInvalid option has been used.
Definition EnumValue.h:124
static constexpr bool hasName()
Compile time inquiry of whether comms::option::def::HasName option has been used.
Definition EnumValue.h:159
typename BaseImpl::Endian Endian
Endian used for serialisation.
Definition EnumValue.h:84
bool setVersion(VersionType version)
Default implementation of version update.
Definition EnumValue.h:310
const ValueType & value() const
Get access to enum value storage.
Definition EnumValue.h:165
Main namespace for all classes / functions of COMMS library.
ErrorStatus
Error statuses reported by the Communication module.
Definition ErrorStatus.h:17
constexpr unsigned version()
Version of the COMMS library as single numeric value.
Definition version.h:64
Contains definition of all the options used by the COMMS library.