16#include "details/OptionsParser.h"
17#include "basic/EnumValue.h"
18#include "details/AdaptBasicField.h"
71template <
typename TFieldBase,
typename TEnum,
typename... TOptions>
72class EnumValue :
public details::AdaptBasicFieldT<basic::EnumValue<TFieldBase, TEnum>, TOptions...>
74 using BaseImpl = details::AdaptBasicFieldT<basic::EnumValue<TFieldBase, TEnum>, TOptions...>;
75 static_assert(std::is_enum<TEnum>::value,
"TEnum must be enum type");
82 using Endian =
typename BaseImpl::Endian;
124 return ParsedOptions::HasFailOnInvalid;
131 return ParsedOptions::HasIgnoreInvalid;
138 return ParsedOptions::HasEmptySerialization;
145 return ParsedOptions::HasFieldType;
151 return BaseImpl::value();
157 return BaseImpl::value();
164 return BaseImpl::getValue();
169 template <
typename U>
172 BaseImpl::setValue(std::forward<U>(val));
179 return BaseImpl::length();
186 return BaseImpl::minLength();
193 return BaseImpl::maxLength();
201 template <
typename TIter>
204 return BaseImpl::read(iter, size);
211 return BaseImpl::hasReadNoStatus();
219 template <
typename TIter>
222 BaseImpl::readNoStatus(iter);
228 return BaseImpl::canWrite();
236 template <
typename TIter>
239 return BaseImpl::write(iter, size);
246 return BaseImpl::hasWriteNoStatus();
254 template <
typename TIter>
257 BaseImpl::writeNoStatus(iter);
263 return BaseImpl::valid();
270 return BaseImpl::refresh();
276 return ParsedOptions::HasCustomVersionUpdate || BaseImpl::isVersionDependent();
282 return BaseImpl::hasNonDefaultRefresh();
289 return BaseImpl::getVersion();
296 return BaseImpl::setVersion(
version);
308 BaseImpl::setForcedLength(len);
315 return BaseImpl::getForcedLength();
319 using BaseImpl::readData;
320 using BaseImpl::writeData;
322 static_assert(!ParsedOptions::HasSequenceElemLengthForcing,
323 "comms::option::def::SequenceElemLengthForcingEnabled option is not applicable to EnumValue field");
324 static_assert(!ParsedOptions::HasSequenceSizeForcing,
325 "comms::option::def::SequenceSizeForcingEnabled option is not applicable to EnumValue field");
326 static_assert(!ParsedOptions::HasSequenceLengthForcing,
327 "comms::option::def::SequenceLengthForcingEnabled option is not applicable to EnumValue field");
328 static_assert(!ParsedOptions::HasSequenceFixedSize,
329 "comms::option::def::SequenceFixedSize option is not applicable to EnumValue field");
330 static_assert(!ParsedOptions::HasSequenceFixedSizeUseFixedSizeStorage,
331 "comms::option::app::SequenceFixedSizeUseFixedSizeStorage option is not applicable to EnumValue field");
332 static_assert(!ParsedOptions::HasSequenceSizeFieldPrefix,
333 "comms::option::def::SequenceSizeFieldPrefix option is not applicable to EnumValue field");
334 static_assert(!ParsedOptions::HasSequenceSerLengthFieldPrefix,
335 "comms::option::def::SequenceSerLengthFieldPrefix option is not applicable to EnumValue field");
336 static_assert(!ParsedOptions::HasSequenceElemSerLengthFieldPrefix,
337 "comms::option::def::SequenceElemSerLengthFieldPrefix option is not applicable to EnumValue field");
338 static_assert(!ParsedOptions::HasSequenceElemFixedSerLengthFieldPrefix,
339 "comms::option::def::SequenceElemSerLengthFixedFieldPrefix option is not applicable to EnumValue field");
340 static_assert(!ParsedOptions::HasSequenceTrailingFieldSuffix,
341 "comms::option::def::SequenceTrailingFieldSuffix option is not applicable to EnumValue field");
342 static_assert(!ParsedOptions::HasSequenceTerminationFieldSuffix,
343 "comms::option::def::SequenceTerminationFieldSuffix option is not applicable to EnumValue field");
344 static_assert(!ParsedOptions::HasFixedSizeStorage,
345 "comms::option::app::FixedSizeStorage option is not applicable to EnumValue field");
346 static_assert(!ParsedOptions::HasCustomStorageType,
347 "comms::option::app::CustomStorageType option is not applicable to EnumValue field");
348 static_assert(!ParsedOptions::HasScalingRatio,
349 "comms::option::def::ScalingRatio option is not applicable to EnumValue field");
350 static_assert(!ParsedOptions::HasUnits,
351 "comms::option::def::Units option is not applicable to EnumValue field");
352 static_assert(!ParsedOptions::HasOrigDataView,
353 "comms::option::app::OrigDataView option is not applicable to EnumValue field");
354 static_assert(!ParsedOptions::HasVersionsRange,
355 "comms::option::def::ExistsBetweenVersions (or similar) option is not applicable to EnumValue field");
356 static_assert(!ParsedOptions::HasMissingOnReadFail,
357 "comms::option::def::MissingOnReadFail option is not applicable to EnumValue field");
358 static_assert(!ParsedOptions::HasMissingOnInvalid,
359 "comms::option::def::MissingOnInvalid option is not applicable to EnumValue field");
369template <
typename TFieldBase,
typename TEnum,
typename... TOptions>
374 return field1.value() == field2.value();
382template <
typename TFieldBase,
typename TEnum,
typename... TOptions>
387 return field1.value() != field2.value();
395template <
typename TFieldBase,
typename TEnum,
typename... TOptions>
400 return field1.value() < field2.value();
411 return std::is_same<typename T::CommsTag, tag::Enum>::value;
417template <
typename TFieldBase,
typename TEnum,
typename... TOptions>
419EnumValue<TFieldBase, TEnum, TOptions...>&
428template <
typename TFieldBase,
typename TEnum,
typename... TOptions>
430const EnumValue<TFieldBase, TEnum, TOptions...>&
Enumerator value field.
Definition EnumValue.h:73
ValueType & value()
Get access to enum value storage.
Definition EnumValue.h:155
constexpr bool isEnumValue()
Compile time check function of whether a provided type is any variant of comms::field::EnumValue.
Definition EnumValue.h:409
bool operator!=(const EnumValue< TFieldBase, TEnum, TOptions... > &field1, const EnumValue< TFieldBase, TEnum, TOptions... > &field2) noexcept
Non-equality comparison operator.
Definition EnumValue.h:383
void writeNoStatus(TIter &iter) const
Write current field value to output data sequence without error check and status report.
Definition EnumValue.h:255
typename BaseImpl::VersionType VersionType
Version type.
Definition EnumValue.h:85
static constexpr std::size_t maxLength()
Get maximal length that is required to serialise field of this type.
Definition EnumValue.h:191
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:431
VersionType getVersion() const
Get version of the field.
Definition EnumValue.h:287
static constexpr bool hasNonDefaultRefresh()
Compile time check if this class has non-default refresh functionality.
Definition EnumValue.h:280
bool valid() const
Check validity of the field value.
Definition EnumValue.h:261
void readNoStatus(TIter &iter)
Read field value from input data sequence without error check and status report.
Definition EnumValue.h:220
typename BaseImpl::CommsTag CommsTag
Tag indicating type of the field.
Definition EnumValue.h:91
void setValue(U &&val)
Set value.
Definition EnumValue.h:170
const ValueType & getValue() const
Get value.
Definition EnumValue.h:162
static constexpr bool hasReadNoStatus()
Compile time check of whether the field has proper readNoStatus() member function.
Definition EnumValue.h:209
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:396
TFieldBase FieldBase
Base class provided in the first template parameter.
Definition EnumValue.h:79
static constexpr bool hasIgnoreInvalid()
Compile time inquiry of whether comms::option::def::IgnoreInvalid option has been used.
Definition EnumValue.h:129
int getForcedLength() const
Get forced serialization length.
Definition EnumValue.h:313
ErrorStatus read(TIter &iter, std::size_t size)
Read field value from input data sequence.
Definition EnumValue.h:202
constexpr std::size_t length() const
Get length required to serialise the current field value.
Definition EnumValue.h:177
bool refresh()
Refresh the field's value.
Definition EnumValue.h:268
typename ParsedOptions::FieldType FieldType
Type of actual extending field specified via comms::option::def::FieldType.
Definition EnumValue.h:100
static constexpr bool hasWriteNoStatus()
Compile time check of whether the field has proper writeNoStatus() member function.
Definition EnumValue.h:244
static constexpr bool hasEmptySerialization()
Compile time inquiry of whether comms::option::def::EmptySerialization option has been used.
Definition EnumValue.h:136
EnumValue(const ValueType &val)
Constructor.
Definition EnumValue.h:106
ErrorStatus write(TIter &iter, std::size_t size) const
Write current field value to output data sequence.
Definition EnumValue.h:237
typename BaseImpl::ValueType ValueType
Type of underlying enum value.
Definition EnumValue.h:95
static constexpr bool isVersionDependent()
Compile time check if this class is version dependent.
Definition EnumValue.h:274
static constexpr bool hasFieldType()
Compile time inquiry of whether comms::option::def::FieldType option has been used.
Definition EnumValue.h:143
static constexpr std::size_t minLength()
Get minimal length that is required to serialise field of this type.
Definition EnumValue.h:184
~EnumValue() noexcept=default
Destructor.
void setForcedLength(int len)
Force serialization length of the field.
Definition EnumValue.h:306
details::OptionsParser< TOptions... > ParsedOptions
All the options provided to this class bundled into struct.
Definition EnumValue.h:88
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:370
bool canWrite() const
Check of whether the field has a consistent value for writing.
Definition EnumValue.h:226
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:420
static constexpr bool hasFailOnInvalid()
Compile time inquiry of whether comms::option::def::FailOnInvalid option has been used.
Definition EnumValue.h:122
typename BaseImpl::Endian Endian
Endian used for serialisation.
Definition EnumValue.h:82
bool setVersion(VersionType version)
Default implementation of version update.
Definition EnumValue.h:294
const ValueType & value() const
Get access to enum value storage.
Definition EnumValue.h:149
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.