15#include "basic/Bitfield.h"
16#include "details/AdaptBasicField.h"
88template <
typename TFieldBase,
typename TMembers,
typename... TOptions>
90 details::AdaptBasicFieldT<
93 details::OptionsParser<TOptions...>::ForcedMembersVersionDependency,
100 details::AdaptBasicFieldT<
103 details::OptionsParser<TOptions...>::ForcedMembersVersionDependency,
114 using Endian =
typename BaseImpl::Endian;
149 : BaseImpl(
std::move(val))
157 return ParsedOptions::HasFailOnInvalid;
164 return ParsedOptions::HasIgnoreInvalid;
171 return ParsedOptions::HasEmptySerialization;
178 return ParsedOptions::HasFieldType;
185 template <std::
size_t TIdx>
188 return BaseImpl::template memberBitLength<TIdx>();
196 return BaseImpl::value();
203 return BaseImpl::value();
210 return BaseImpl::getValue();
215 template <
typename U>
218 BaseImpl::setValue(std::forward<U>(val));
225 return BaseImpl::length();
232 return BaseImpl::minLength();
239 return BaseImpl::maxLength();
247 template <
typename TIter>
250 return BaseImpl::read(iter, size);
257 return BaseImpl::hasReadNoStatus();
265 template <
typename TIter>
268 BaseImpl::readNoStatus(iter);
274 return BaseImpl::canWrite();
282 template <
typename TIter>
285 return BaseImpl::write(iter, size);
292 return BaseImpl::hasWriteNoStatus();
300 template <
typename TIter>
303 BaseImpl::writeNoStatus(iter);
309 return BaseImpl::valid();
317 return BaseImpl::refresh();
323 return ParsedOptions::HasCustomVersionUpdate || BaseImpl::isVersionDependent();
329 return BaseImpl::hasNonDefaultRefresh();
336 return BaseImpl::getVersion();
343 return BaseImpl::setVersion(
version);
347 using BaseImpl::readData;
348 using BaseImpl::writeData;
351 static_assert(!ParsedOptions::HasSerOffset,
352 "comms::option::def::NumValueSerOffset option is not applicable to Bitfield field");
353 static_assert(!ParsedOptions::HasFixedLengthLimit,
354 "comms::option::def::FixedLength option is not applicable to Bitfield field");
355 static_assert(!ParsedOptions::HasFixedBitLengthLimit,
356 "comms::option::def::FixedBitLength option is not applicable to Bitfield field");
357 static_assert(!ParsedOptions::HasVarLengthLimits,
358 "comms::option::def::VarLength option is not applicable to Bitfield field");
359 static_assert(!ParsedOptions::HasAvailableLengthLimit,
360 "comms::option::def::AvailableLengthLimit option is not applicable to Bitfield field");
361 static_assert(!ParsedOptions::HasSequenceElemLengthForcing,
362 "comms::option::def::SequenceElemLengthForcingEnabled option is not applicable to Bitfield field");
363 static_assert(!ParsedOptions::HasSequenceSizeForcing,
364 "comms::option::def::SequenceSizeForcingEnabled option is not applicable to Bitfield field");
365 static_assert(!ParsedOptions::HasSequenceLengthForcing,
366 "comms::option::def::SequenceLengthorcingEnabled option is not applicable to Bitfield field");
367 static_assert(!ParsedOptions::HasSequenceFixedSize,
368 "comms::option::def::SequenceFixedSize option is not applicable to Bitfield field");
369 static_assert(!ParsedOptions::HasSequenceFixedSizeUseFixedSizeStorage,
370 "comms::option::app::SequenceFixedSizeUseFixedSizeStorage option is not applicable to Bitfield field");
371 static_assert(!ParsedOptions::HasSequenceSizeFieldPrefix,
372 "comms::option::def::SequenceSizeFieldPrefix option is not applicable to Bitfield field");
373 static_assert(!ParsedOptions::HasSequenceSerLengthFieldPrefix,
374 "comms::option::def::SequenceSerLengthFieldPrefix option is not applicable to Bitfield field");
375 static_assert(!ParsedOptions::HasSequenceElemSerLengthFieldPrefix,
376 "comms::option::def::SequenceElemSerLengthFieldPrefix option is not applicable to Bitfield field");
377 static_assert(!ParsedOptions::HasSequenceElemFixedSerLengthFieldPrefix,
378 "comms::option::def::SequenceElemSerLengthFixedFieldPrefix option is not applicable to Bitfield field");
379 static_assert(!ParsedOptions::HasSequenceTrailingFieldSuffix,
380 "comms::option::def::SequenceTrailingFieldSuffix option is not applicable to Bitfield field");
381 static_assert(!ParsedOptions::HasSequenceTerminationFieldSuffix,
382 "comms::option::def::SequenceTerminationFieldSuffix option is not applicable to Bitfield field");
383 static_assert(!ParsedOptions::HasFixedSizeStorage,
384 "comms::option::app::FixedSizeStorage option is not applicable to Bitfield field");
385 static_assert(!ParsedOptions::HasCustomStorageType,
386 "comms::option::app::CustomStorageType option is not applicable to Bitfield field");
387 static_assert(!ParsedOptions::HasScalingRatio,
388 "comms::option::def::ScalingRatio option is not applicable to Bitfield field");
389 static_assert(!ParsedOptions::HasUnits,
390 "comms::option::def::Units option is not applicable to Bitfield field");
391 static_assert(!ParsedOptions::HasOrigDataView,
392 "comms::option::app::OrigDataView option is not applicable to Bitfield field");
393 static_assert(!ParsedOptions::HasMultiRangeValidation,
394 "comms::option::def::ValidNumValueRange (or similar) option is not applicable to Bitfield field");
395 static_assert(!ParsedOptions::HasVersionsRange,
396 "comms::option::def::ExistsBetweenVersions (or similar) option is not applicable to Bitfield field");
397 static_assert(!ParsedOptions::HasInvalidByDefault,
398 "comms::option::def::InvalidByDefault option is not applicable to Bitfield field");
399 static_assert(!ParsedOptions::HasMissingOnReadFail,
400 "comms::option::def::MissingOnReadFail option is not applicable to Bitfield field");
401 static_assert(!ParsedOptions::HasMissingOnInvalid,
402 "comms::option::def::MissingOnInvalid option is not applicable to Bitfield field");
410template <
typename TFieldBase,
typename TMembers,
typename... TOptions>
415 return field1.value() == field2.value();
423template <
typename TFieldBase,
typename TMembers,
typename... TOptions>
428 return field1.value() != field2.value();
436template <
typename TFieldBase,
typename TMembers,
typename... TOptions>
441 return field1.value() < field2.value();
452 return std::is_same<typename T::CommsTag, tag::Bitfield>::value;
458template <
typename TFieldBase,
typename TMembers,
typename... TOptions>
460Bitfield<TFieldBase, TMembers, TOptions...>&
469template <
typename TFieldBase,
typename TMembers,
typename... TOptions>
471const Bitfield<TFieldBase, TMembers, TOptions...>&
This file contain definition of error statuses used by comms module.
Bitfield field.
Definition Bitfield.h:98
const ValueType & value() const
Get access to the stored tuple of fields.
Definition Bitfield.h:194
typename BaseImpl::Endian Endian
Endian used for serialisation.
Definition Bitfield.h:114
ErrorStatus read(TIter &iter, std::size_t size)
Read field value from input data sequence.
Definition Bitfield.h:248
typename BaseImpl::CommsTag CommsTag
Tag indicating type of the field.
Definition Bitfield.h:123
Bitfield()=default
Default constructor.
VersionType getVersion() const
Get version of the field.
Definition Bitfield.h:334
constexpr std::size_t length() const
Get length required to serialise the current field value.
Definition Bitfield.h:223
Bitfield(const ValueType &val)
Constructor.
Definition Bitfield.h:141
static constexpr bool hasEmptySerialization()
Compile time inquiry of whether comms::option::def::EmptySerialization option has been used.
Definition Bitfield.h:169
Bitfield< TFieldBase, TMembers, TOptions... > & toFieldBase(Bitfield< TFieldBase, TMembers, TOptions... > &field)
Upcast type of the field definition to its parent comms::field::Bitfield type in order to have access...
Definition Bitfield.h:461
bool operator==(const Bitfield< TFieldBase, TMembers, TOptions... > &field1, const Bitfield< TFieldBase, TMembers, TOptions... > &field2) noexcept
Equality comparison operator.
Definition Bitfield.h:411
void readNoStatus(TIter &iter)
Read field value from input data sequence without error check and status report.
Definition Bitfield.h:266
TFieldBase FieldBase
Base class provided in the first template parameter.
Definition Bitfield.h:111
constexpr bool isBitfield()
Compile time check function of whether a provided type is any variant of comms::field::Bitfield.
Definition Bitfield.h:450
ErrorStatus write(TIter &iter, std::size_t size) const
Write current field value to output data sequence.
Definition Bitfield.h:283
static constexpr std::size_t minLength()
Get minimal length that is required to serialise field of this type.
Definition Bitfield.h:230
Bitfield(ValueType &&val)
Constructor.
Definition Bitfield.h:148
bool refresh()
Refresh the field's contents.
Definition Bitfield.h:315
static constexpr bool hasIgnoreInvalid()
Compile time inquiry of whether comms::option::def::IgnoreInvalid option has been used.
Definition Bitfield.h:162
static constexpr bool hasFieldType()
Compile time inquiry of whether comms::option::def::FieldType option has been used.
Definition Bitfield.h:176
void writeNoStatus(TIter &iter) const
Write current field value to output data sequence without error check and status report.
Definition Bitfield.h:301
typename BaseImpl::ValueType ValueType
Value type.
Definition Bitfield.h:128
bool operator<(const Bitfield< TFieldBase, TMembers, TOptions... > &field1, const Bitfield< TFieldBase, TMembers, TOptions... > &field2) noexcept
Equivalence comparison operator.
Definition Bitfield.h:437
bool canWrite() const
Check of whether the field has a consistent value for writing.
Definition Bitfield.h:272
bool operator!=(const Bitfield< TFieldBase, TMembers, TOptions... > &field1, const Bitfield< TFieldBase, TMembers, TOptions... > &field2) noexcept
Non-equality comparison operator.
Definition Bitfield.h:424
const Bitfield< TFieldBase, TMembers, TOptions... > & toFieldBase(const Bitfield< TFieldBase, TMembers, TOptions... > &field)
Upcast type of the field definition to its parent comms::field::Bitfield type in order to have access...
Definition Bitfield.h:472
static constexpr std::size_t maxLength()
Get maximal length that is required to serialise field of this type.
Definition Bitfield.h:237
ValueType & value()
Get access to the stored tuple of fields.
Definition Bitfield.h:201
details::OptionsParser< TOptions... > ParsedOptions
All the options provided to this class bundled into struct.
Definition Bitfield.h:120
void setValue(U &&val)
Set value.
Definition Bitfield.h:216
static constexpr bool isVersionDependent()
Compile time check if this class is version dependent.
Definition Bitfield.h:321
bool setVersion(VersionType version)
Default implementation of version update.
Definition Bitfield.h:341
static constexpr bool hasFailOnInvalid()
Compile time inquiry of whether comms::option::def::FailOnInvalid option has been used.
Definition Bitfield.h:155
typename BaseImpl::VersionType VersionType
Version type.
Definition Bitfield.h:117
typename ParsedOptions::FieldType FieldType
Type of actual extending field specified via comms::option::def::FieldType.
Definition Bitfield.h:133
static constexpr bool hasWriteNoStatus()
Compile time check of whether the field has proper writeNoStatus() member function.
Definition Bitfield.h:290
const ValueType & getValue() const
Get value.
Definition Bitfield.h:208
static constexpr std::size_t memberBitLength()
Retrieve number of bits specified member field consumes.
Definition Bitfield.h:186
static constexpr bool hasNonDefaultRefresh()
Compile time check if this class has non-default refresh functionality.
Definition Bitfield.h:327
static constexpr bool hasReadNoStatus()
Compile time check of whether the field has proper readNoStatus() member function.
Definition Bitfield.h:255
bool valid() const
Check validity of the field value.
Definition Bitfield.h:307
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.