15#include "comms/field/basic/Bundle.h"
16#include "comms/field/details/AdaptBasicField.h"
52template <
typename TFieldBase,
typename TMembers,
typename... TOptions>
54 details::AdaptBasicFieldT<
57 details::OptionsParser<TOptions...>::ForcedMembersVersionDependency,
63 details::AdaptBasicFieldT<
66 details::OptionsParser<TOptions...>::ForcedMembersVersionDependency,
71 "TMembers is expected to be a tuple of std::tuple<...>");
74 1U <= std::tuple_size<TMembers>::value,
75 "Number of members is expected to be at least 1.");
82 using Endian =
typename BaseImpl::Endian;
115 : BaseImpl(
std::move(val))
123 return ParsedOptions::HasFailOnInvalid;
130 return ParsedOptions::HasIgnoreInvalid;
137 return ParsedOptions::HasEmptySerialization;
144 return ParsedOptions::HasFieldType;
150 return BaseImpl::value();
156 return BaseImpl::value();
163 return BaseImpl::getValue();
168 template <
typename U>
171 BaseImpl::setValue(std::forward<U>(val));
180 return BaseImpl::length();
189 template <std::
size_t TFromIdx>
192 return BaseImpl::template lengthFrom<TFromIdx>();
201 template <std::
size_t TUntilIdx>
204 return BaseImpl::template lengthUntil<TUntilIdx>();
215 template <std::
size_t TFromIdx, std::
size_t TUntilIdx>
218 return BaseImpl::template lengthFromUntil<TFromIdx, TUntilIdx>();
225 return BaseImpl::minLength();
232 template <std::
size_t TFromIdx>
235 return BaseImpl::template minLengthFrom<TFromIdx>();
242 template <std::
size_t TUntilIdx>
245 return BaseImpl::template minLengthUntil<TUntilIdx>();
254 template <std::
size_t TFromIdx, std::
size_t TUntilIdx>
257 return BaseImpl::template minLengthFromUntil<TFromIdx, TUntilIdx>();
264 return BaseImpl::maxLength();
271 template <std::
size_t TFromIdx>
274 return BaseImpl::template maxLengthFrom<TFromIdx>();
281 template <std::
size_t TUntilIdx>
284 return BaseImpl::template maxLengthUntil<TUntilIdx>();
293 template <std::
size_t TFromIdx, std::
size_t TUntilIdx>
296 return BaseImpl::template maxLengthFromUntil<TFromIdx, TUntilIdx>();
305 template <
typename TIter>
308 return BaseImpl::read(iter, size);
321 template <std::
size_t TFromIdx,
typename TIter>
324 return BaseImpl::template readFrom<TFromIdx>(iter, len);
338 template <std::
size_t TFromIdx,
typename TIter>
341 return BaseImpl::template readFromAndUpdateLen<TFromIdx>(iter, len);
354 template <std::
size_t TUntilIdx,
typename TIter>
357 return BaseImpl::template readUntil<TUntilIdx>(iter, len);
371 template <std::
size_t TUntilIdx,
typename TIter>
374 return BaseImpl::template readUntilAndUpdateLen<TUntilIdx>(iter, len);
390 template <std::
size_t TFromIdx, std::
size_t TUntilIdx,
typename TIter>
393 return BaseImpl::template readFromUntil<TFromIdx, TUntilIdx>(iter, len);
410 template <std::
size_t TFromIdx, std::
size_t TUntilIdx,
typename TIter>
413 return BaseImpl::template readFromUntilAndUpdateLen<TFromIdx, TUntilIdx>(iter, len);
420 return BaseImpl::hasReadNoStatus();
428 template <
typename TIter>
431 BaseImpl::readNoStatus(iter);
443 template <std::
size_t TFromIdx,
typename TIter>
446 BaseImpl::template readFromNoStatus<TFromIdx>(iter);
458 template <std::
size_t TUntilIdx,
typename TIter>
461 BaseImpl::template readUntilNoStatus<TUntilIdx>(iter);
476 template <std::
size_t TFromIdx, std::
size_t TUntilIdx,
typename TIter>
479 BaseImpl::template readFromUntilNoStatus<TFromIdx, TUntilIdx>(iter);
485 return BaseImpl::canWrite();
494 template <
typename TIter>
497 return BaseImpl::write(iter, size);
510 template <std::
size_t TFromIdx,
typename TIter>
513 return BaseImpl::template writeFrom<TFromIdx>(iter, size);
526 template <std::
size_t TUntilIdx,
typename TIter>
529 return BaseImpl::template writeUntil<TUntilIdx>(iter, size);
545 template <std::
size_t TFromIdx, std::
size_t TUntilIdx,
typename TIter>
548 return BaseImpl::template writeFromUntil<TFromIdx, TUntilIdx>(iter, size);
555 return BaseImpl::hasWriteNoStatus();
563 template <
typename TIter>
566 BaseImpl::writeNoStatus(iter);
578 template <std::
size_t TFromIdx,
typename TIter>
581 BaseImpl::template writeFromNoStatus<TFromIdx>(iter);
593 template <std::
size_t TUntilIdx,
typename TIter>
596 BaseImpl::template writeUntilNoStatus<TUntilIdx>(iter);
610 template <std::
size_t TFromIdx, std::
size_t TUntilIdx,
typename TIter>
613 BaseImpl::template writeFromUntilNoStatus<TFromIdx, TUntilIdx>(iter);
619 return BaseImpl::valid();
627 return BaseImpl::refresh();
633 return ParsedOptions::HasCustomVersionUpdate || BaseImpl::isVersionDependent();
639 return BaseImpl::hasNonDefaultRefresh();
646 return BaseImpl::getVersion();
653 return BaseImpl::setVersion(
version);
657 using BaseImpl::readData;
658 using BaseImpl::writeData;
661 static_assert(!ParsedOptions::HasSerOffset,
662 "comms::option::def::NumValueSerOffset option is not applicable to Bundle field");
663 static_assert(!ParsedOptions::HasFixedLengthLimit,
664 "comms::option::def::FixedLength option is not applicable to Bundle field");
665 static_assert(!ParsedOptions::HasFixedBitLengthLimit,
666 "comms::option::def::FixedBitLength option is not applicable to Bundle field");
667 static_assert(!ParsedOptions::HasVarLengthLimits,
668 "comms::option::def::VarLength option is not applicable to Bundle field");
669 static_assert(!ParsedOptions::HasAvailableLengthLimit,
670 "comms::option::def::AvailableLengthLimit option is not applicable to Bundle field");
671 static_assert(!ParsedOptions::HasSequenceElemLengthForcing,
672 "comms::option::def::SequenceElemLengthForcingEnabled option is not applicable to Bundle field");
673 static_assert(!ParsedOptions::HasSequenceSizeForcing,
674 "comms::option::def::SequenceSizeForcingEnabled option is not applicable to Bundle field");
675 static_assert(!ParsedOptions::HasSequenceLengthForcing,
676 "comms::option::def::SequenceLengthForcingEnabled option is not applicable to Bundle field");
677 static_assert(!ParsedOptions::HasSequenceFixedSize,
678 "comms::option::def::SequenceFixedSize option is not applicable to Bundle field");
679 static_assert(!ParsedOptions::HasSequenceFixedSizeUseFixedSizeStorage,
680 "comms::option::app::SequenceFixedSizeUseFixedSizeStorage option is not applicable to Bundle field");
681 static_assert(!ParsedOptions::HasSequenceSizeFieldPrefix,
682 "comms::option::def::SequenceSizeFieldPrefix option is not applicable to Bundle field");
683 static_assert(!ParsedOptions::HasSequenceSerLengthFieldPrefix,
684 "comms::option::def::SequenceSerLengthFieldPrefix option is not applicable to Bundle field");
685 static_assert(!ParsedOptions::HasSequenceElemSerLengthFieldPrefix,
686 "comms::option::def::SequenceElemSerLengthFieldPrefix option is not applicable to Bundle field");
687 static_assert(!ParsedOptions::HasSequenceElemFixedSerLengthFieldPrefix,
688 "comms::option::def::SequenceElemSerLengthFixedFieldPrefix option is not applicable to Bundle field");
689 static_assert(!ParsedOptions::HasSequenceTrailingFieldSuffix,
690 "comms::option::def::SequenceTrailingFieldSuffix option is not applicable to Bundle field");
691 static_assert(!ParsedOptions::HasSequenceTerminationFieldSuffix,
692 "comms::option::def::SequenceTerminationFieldSuffix option is not applicable to Bundle field");
693 static_assert(!ParsedOptions::HasFixedSizeStorage,
694 "comms::option::app::FixedSizeStorage option is not applicable to Bundle field");
695 static_assert(!ParsedOptions::HasCustomStorageType,
696 "comms::option::app::CustomStorageType option is not applicable to Bundle field");
697 static_assert(!ParsedOptions::HasScalingRatio,
698 "comms::option::def::ScalingRatio option is not applicable to Bundle field");
699 static_assert(!ParsedOptions::HasUnits,
700 "comms::option::def::Units option is not applicable to Bundle field");
701 static_assert(!ParsedOptions::HasOrigDataView,
702 "comms::option::app::OrigDataView option is not applicable to Bundle field");
703 static_assert(!ParsedOptions::HasMultiRangeValidation,
704 "comms::option::def::ValidNumValueRange (or similar) option is not applicable to Bundle field");
705 static_assert(!ParsedOptions::HasVersionsRange,
706 "comms::option::def::ExistsBetweenVersions (or similar) option is not applicable to Bundle field");
707 static_assert(!ParsedOptions::HasInvalidByDefault,
708 "comms::option::def::InvalidByDefault option is not applicable to Bundle field");
709 static_assert(!ParsedOptions::HasMissingOnReadFail,
710 "comms::option::def::MissingOnReadFail option is not applicable to Bundle field");
711 static_assert(!ParsedOptions::HasMissingOnInvalid,
712 "comms::option::def::MissingOnInvalid option is not applicable to Bundle field");
720template <
typename TFieldBase,
typename TMembers,
typename... TOptions>
725 return field1.value() == field2.value();
733template <
typename TFieldBase,
typename TMembers,
typename... TOptions>
738 return field1.value() != field2.value();
745template <
typename TFieldBase,
typename TMembers,
typename... TOptions>
750 return field1.value() < field2.value();
757template <
typename TFieldBase,
typename TMembers,
typename... TOptions>
762 return field1.value() <= field2.value();
769template <
typename TFieldBase,
typename TMembers,
typename... TOptions>
774 return field1.value() > field2.value();
781template <
typename TFieldBase,
typename TMembers,
typename... TOptions>
786 return field1.value() >= field2.value();
797 return std::is_same<typename T::CommsTag, tag::Bundle>::value;
802template <
typename TFieldBase,
typename TMembers,
typename... TOptions>
804Bundle<TFieldBase, TMembers, TOptions...>&
812template <
typename TFieldBase,
typename TMembers,
typename... TOptions>
814const Bundle<TFieldBase, TMembers, TOptions...>&
This file contain definition of error statuses used by comms module.
Bundles multiple fields into a single field.
Definition Bundle.h:61
ValueType & value()
Get access to the stored tuple of fields.
Definition Bundle.h:148
static constexpr std::size_t maxLengthFromUntil()
Get maximal length that is required to serialise specified bundled fields.
Definition Bundle.h:294
bool operator>(const Bundle< TFieldBase, TMembers, TOptions... > &field1, const Bundle< TFieldBase, TMembers, TOptions... > &field2) noexcept
Equivalence comparison operator.
Definition Bundle.h:770
ErrorStatus readFrom(TIter &iter, std::size_t len)
Read selected number of member fields (from specified index).
Definition Bundle.h:322
static constexpr bool hasNonDefaultRefresh()
Compile time check if this class has non-default refresh functionality.
Definition Bundle.h:637
std::size_t length() const
Get length required to serialise bundled fields.
Definition Bundle.h:178
ErrorStatus readUntil(TIter &iter, std::size_t len)
Read selected number of member fields (until specified index).
Definition Bundle.h:355
Bundle()=default
Default constructor.
typename BaseImpl::ValueType ValueType
Value type.
Definition Bundle.h:96
static constexpr std::size_t minLength()
Get minimal length that is required to serialise all bundled fields.
Definition Bundle.h:223
static constexpr std::size_t maxLength()
Get maximal length that is required to serialise all bundled fields.
Definition Bundle.h:262
Bundle(const ValueType &val)
Constructor.
Definition Bundle.h:108
typename BaseImpl::Endian Endian
Endian used for serialisation.
Definition Bundle.h:82
void readFromUntilNoStatus(TIter &iter)
Read selected member fields from input data sequence without error check and status report.
Definition Bundle.h:477
bool operator>=(const Bundle< TFieldBase, TMembers, TOptions... > &field1, const Bundle< TFieldBase, TMembers, TOptions... > &field2) noexcept
Equivalence comparison operator.
Definition Bundle.h:782
constexpr bool isBundle()
Compile time check function of whether a provided type is any variant of comms::field::Bundle.
Definition Bundle.h:795
std::size_t lengthFrom() const
Get length required to serialise specified bundled member fields.
Definition Bundle.h:190
static constexpr std::size_t minLengthFrom()
Get minimal length that is required to serialise specified bundled fields.
Definition Bundle.h:233
void readNoStatus(TIter &iter)
Read field value from input data sequence without error check and status report.
Definition Bundle.h:429
static constexpr std::size_t maxLengthFrom()
Get maximal length that is required to serialise specified bundled fields.
Definition Bundle.h:272
static constexpr bool hasFailOnInvalid()
Compile time inquiry of whether comms::option::def::FailOnInvalid option has been used.
Definition Bundle.h:121
void writeFromUntilNoStatus(TIter &iter)
Write selected member fields to output data sequence without error check and status report.
Definition Bundle.h:611
bool operator<(const Bundle< TFieldBase, TMembers, TOptions... > &field1, const Bundle< TFieldBase, TMembers, TOptions... > &field2) noexcept
Equivalence comparison operator.
Definition Bundle.h:746
ErrorStatus write(TIter &iter, std::size_t size) const
Write current field value to output data sequence.
Definition Bundle.h:495
TFieldBase FieldBase
Base class provided in the first template parameter.
Definition Bundle.h:79
const ValueType & value() const
Get access to the stored tuple of fields.
Definition Bundle.h:154
bool operator==(const Bundle< TFieldBase, TMembers, TOptions... > &field1, const Bundle< TFieldBase, TMembers, TOptions... > &field2) noexcept
Equality comparison operator.
Definition Bundle.h:721
void readUntilNoStatus(TIter &iter)
Read selected member fields from input data sequence without error check and status report.
Definition Bundle.h:459
static constexpr bool hasWriteNoStatus()
Compile time check of whether the field has proper writeNoStatus() member function.
Definition Bundle.h:553
ErrorStatus writeFromUntil(TIter &iter, std::size_t size) const
Write selected member fields to output data sequence.
Definition Bundle.h:546
static constexpr std::size_t maxLengthUntil()
Get maximal length that is required to serialise specified bundled fields.
Definition Bundle.h:282
VersionType getVersion() const
Get version of the field.
Definition Bundle.h:644
static constexpr bool hasIgnoreInvalid()
Compile time inquiry of whether comms::option::def::IgnoreInvalid option has been used.
Definition Bundle.h:128
typename BaseImpl::CommsTag CommsTag
Tag indicating type of the field.
Definition Bundle.h:91
const ValueType & getValue() const
Get value.
Definition Bundle.h:161
ErrorStatus read(TIter &iter, std::size_t size)
Read field value from input data sequence.
Definition Bundle.h:306
std::size_t lengthUntil() const
Get length required to serialise specified bundled member fields.
Definition Bundle.h:202
bool canWrite() const
Check of whether the field has a consistent value for writing.
Definition Bundle.h:483
bool valid() const
Check validity of all the bundled fields.
Definition Bundle.h:617
typename ParsedOptions::FieldType FieldType
Type of actual extending field specified via comms::option::def::FieldType.
Definition Bundle.h:101
Bundle(ValueType &&val)
Constructor.
Definition Bundle.h:114
bool operator<=(const Bundle< TFieldBase, TMembers, TOptions... > &field1, const Bundle< TFieldBase, TMembers, TOptions... > &field2) noexcept
Equivalence comparison operator.
Definition Bundle.h:758
static constexpr bool isVersionDependent()
Compile time check if this class is version dependent.
Definition Bundle.h:631
static constexpr std::size_t minLengthUntil()
Get minimal length that is required to serialise specified bundled fields.
Definition Bundle.h:243
details::OptionsParser< TOptions... > ParsedOptions
All the options provided to this class bundled into struct.
Definition Bundle.h:88
void setValue(U &&val)
Set value.
Definition Bundle.h:169
ErrorStatus writeUntil(TIter &iter, std::size_t size) const
Write selected member fields to output data sequence.
Definition Bundle.h:527
void writeFromNoStatus(TIter &iter)
Write selected member fields to output data sequence without error check and status report.
Definition Bundle.h:579
void writeNoStatus(TIter &iter) const
Write current field value to output data sequence without error check and status report.
Definition Bundle.h:564
bool setVersion(VersionType version)
Default implementation of version update.
Definition Bundle.h:651
ErrorStatus writeFrom(TIter &iter, std::size_t size) const
Write selected member fields to output data sequence.
Definition Bundle.h:511
void readFromNoStatus(TIter &iter)
Read selected member fields from input data sequence without error check and status report.
Definition Bundle.h:444
static constexpr std::size_t minLengthFromUntil()
Get minimal length that is required to serialise specified bundled fields.
Definition Bundle.h:255
ErrorStatus readUntilAndUpdateLen(TIter &iter, std::size_t &len)
Read selected number of member fields (until specified index) while updating remaining length informa...
Definition Bundle.h:372
static constexpr bool hasReadNoStatus()
Compile time check of whether the field has proper readNoStatus() member function (or similar).
Definition Bundle.h:418
ErrorStatus readFromUntil(TIter &iter, std::size_t len)
Read selected number of member fields (between specified indices).
Definition Bundle.h:391
ErrorStatus readFromUntilAndUpdateLen(TIter &iter, std::size_t &len)
Read selected number of member fields (between specified indices) while updating remaining length inf...
Definition Bundle.h:411
ErrorStatus readFromAndUpdateLen(TIter &iter, std::size_t &len)
Read selected number of member fields (from specified index) while updating remaining length informat...
Definition Bundle.h:339
std::size_t lengthFromUntil() const
Get length required to serialise specified bundled member fields.
Definition Bundle.h:216
void writeUntilNoStatus(TIter &iter)
Write selected member fields to output data sequence without error check and status report.
Definition Bundle.h:594
typename BaseImpl::VersionType VersionType
Version type.
Definition Bundle.h:85
bool refresh()
Refresh the field's contents.
Definition Bundle.h:625
bool operator!=(const Bundle< TFieldBase, TMembers, TOptions... > &field1, const Bundle< TFieldBase, TMembers, TOptions... > &field2) noexcept
Non-equality comparison operator.
Definition Bundle.h:734
static constexpr bool hasFieldType()
Compile time inquiry of whether comms::option::def::FieldType option has been used.
Definition Bundle.h:142
static constexpr bool hasEmptySerialization()
Compile time inquiry of whether comms::option::def::EmptySerialization option has been used.
Definition Bundle.h:135
Bundle< TFieldBase, TMembers, TOptions... > & toFieldBase(Bundle< TFieldBase, TMembers, TOptions... > &field)
Upcast type of the field definition to its parent comms::field::Bundle type in order to have access t...
Definition Bundle.h:805
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.
Check whether provided type is a variant of std::tuple.
Definition Tuple.h:36