15#include "comms/field/basic/Bundle.h"
16#include "comms/field/details/AdaptBasicField.h"
54template <
typename TFieldBase,
typename TMembers,
typename... TOptions>
56 details::AdaptBasicFieldT<
59 details::OptionsParser<TOptions...>::ForcedMembersVersionDependency,
65 details::AdaptBasicFieldT<
68 details::OptionsParser<TOptions...>::ForcedMembersVersionDependency,
73 "TMembers is expected to be a tuple of std::tuple<...>");
76 1U <= std::tuple_size<TMembers>::value,
77 "Number of members is expected to be at least 1.");
84 using Endian =
typename BaseImpl::Endian;
117 : BaseImpl(
std::move(val))
125 return ParsedOptions::HasFailOnInvalid;
132 return ParsedOptions::HasIgnoreInvalid;
139 return ParsedOptions::HasEmptySerialization;
146 return ParsedOptions::HasFieldType;
153 return ParsedOptions::HasFixedValue;
160 return ParsedOptions::HasName;
166 return BaseImpl::value();
172 return BaseImpl::value();
179 return BaseImpl::getValue();
184 template <
typename U>
187 BaseImpl::setValue(std::forward<U>(val));
196 return BaseImpl::length();
205 template <std::
size_t TFromIdx>
208 return BaseImpl::template lengthFrom<TFromIdx>();
217 template <std::
size_t TUntilIdx>
220 return BaseImpl::template lengthUntil<TUntilIdx>();
231 template <std::
size_t TFromIdx, std::
size_t TUntilIdx>
234 return BaseImpl::template lengthFromUntil<TFromIdx, TUntilIdx>();
241 return BaseImpl::minLength();
248 template <std::
size_t TFromIdx>
251 return BaseImpl::template minLengthFrom<TFromIdx>();
258 template <std::
size_t TUntilIdx>
261 return BaseImpl::template minLengthUntil<TUntilIdx>();
270 template <std::
size_t TFromIdx, std::
size_t TUntilIdx>
273 return BaseImpl::template minLengthFromUntil<TFromIdx, TUntilIdx>();
280 return BaseImpl::maxLength();
287 template <std::
size_t TFromIdx>
290 return BaseImpl::template maxLengthFrom<TFromIdx>();
297 template <std::
size_t TUntilIdx>
300 return BaseImpl::template maxLengthUntil<TUntilIdx>();
309 template <std::
size_t TFromIdx, std::
size_t TUntilIdx>
312 return BaseImpl::template maxLengthFromUntil<TFromIdx, TUntilIdx>();
321 template <
typename TIter>
324 return BaseImpl::read(iter, size);
337 template <std::
size_t TFromIdx,
typename TIter>
340 return BaseImpl::template readFrom<TFromIdx>(iter, len);
354 template <std::
size_t TFromIdx,
typename TIter>
357 return BaseImpl::template readFromAndUpdateLen<TFromIdx>(iter, len);
370 template <std::
size_t TUntilIdx,
typename TIter>
373 return BaseImpl::template readUntil<TUntilIdx>(iter, len);
387 template <std::
size_t TUntilIdx,
typename TIter>
390 return BaseImpl::template readUntilAndUpdateLen<TUntilIdx>(iter, len);
406 template <std::
size_t TFromIdx, std::
size_t TUntilIdx,
typename TIter>
409 return BaseImpl::template readFromUntil<TFromIdx, TUntilIdx>(iter, len);
426 template <std::
size_t TFromIdx, std::
size_t TUntilIdx,
typename TIter>
429 return BaseImpl::template readFromUntilAndUpdateLen<TFromIdx, TUntilIdx>(iter, len);
436 return BaseImpl::hasReadNoStatus();
444 template <
typename TIter>
447 BaseImpl::readNoStatus(iter);
459 template <std::
size_t TFromIdx,
typename TIter>
462 BaseImpl::template readFromNoStatus<TFromIdx>(iter);
474 template <std::
size_t TUntilIdx,
typename TIter>
477 BaseImpl::template readUntilNoStatus<TUntilIdx>(iter);
492 template <std::
size_t TFromIdx, std::
size_t TUntilIdx,
typename TIter>
495 BaseImpl::template readFromUntilNoStatus<TFromIdx, TUntilIdx>(iter);
501 return BaseImpl::canWrite();
510 template <
typename TIter>
513 return BaseImpl::write(iter, size);
526 template <std::
size_t TFromIdx,
typename TIter>
529 return BaseImpl::template writeFrom<TFromIdx>(iter, size);
542 template <std::
size_t TUntilIdx,
typename TIter>
545 return BaseImpl::template writeUntil<TUntilIdx>(iter, size);
561 template <std::
size_t TFromIdx, std::
size_t TUntilIdx,
typename TIter>
564 return BaseImpl::template writeFromUntil<TFromIdx, TUntilIdx>(iter, size);
571 return BaseImpl::hasWriteNoStatus();
579 template <
typename TIter>
582 BaseImpl::writeNoStatus(iter);
594 template <std::
size_t TFromIdx,
typename TIter>
597 BaseImpl::template writeFromNoStatus<TFromIdx>(iter);
609 template <std::
size_t TUntilIdx,
typename TIter>
612 BaseImpl::template writeUntilNoStatus<TUntilIdx>(iter);
626 template <std::
size_t TFromIdx, std::
size_t TUntilIdx,
typename TIter>
629 BaseImpl::template writeFromUntilNoStatus<TFromIdx, TUntilIdx>(iter);
635 return BaseImpl::valid();
643 return BaseImpl::refresh();
649 return ParsedOptions::HasCustomVersionUpdate || BaseImpl::isVersionDependent();
655 return BaseImpl::hasNonDefaultRefresh();
662 return BaseImpl::getVersion();
669 return BaseImpl::setVersion(
version);
673 using BaseImpl::readData;
674 using BaseImpl::writeData;
677 static_assert(!ParsedOptions::HasSerOffset,
678 "comms::option::def::NumValueSerOffset option is not applicable to Bundle field");
679 static_assert(!ParsedOptions::HasFixedLengthLimit,
680 "comms::option::def::FixedLength option is not applicable to Bundle field");
681 static_assert(!ParsedOptions::HasFixedBitLengthLimit,
682 "comms::option::def::FixedBitLength option is not applicable to Bundle field");
683 static_assert(!ParsedOptions::HasVarLengthLimits,
684 "comms::option::def::VarLength option is not applicable to Bundle field");
685 static_assert(!ParsedOptions::HasAvailableLengthLimit,
686 "comms::option::def::AvailableLengthLimit option is not applicable to Bundle field");
687 static_assert(!ParsedOptions::HasSequenceElemLengthForcing,
688 "comms::option::def::SequenceElemLengthForcingEnabled option is not applicable to Bundle field");
689 static_assert(!ParsedOptions::HasSequenceSizeForcing,
690 "comms::option::def::SequenceSizeForcingEnabled option is not applicable to Bundle field");
691 static_assert(!ParsedOptions::HasSequenceLengthForcing,
692 "comms::option::def::SequenceLengthForcingEnabled option is not applicable to Bundle field");
693 static_assert(!ParsedOptions::HasSequenceFixedSize,
694 "comms::option::def::SequenceFixedSize option is not applicable to Bundle field");
695 static_assert(!ParsedOptions::HasSequenceFixedSizeUseFixedSizeStorage,
696 "comms::option::app::SequenceFixedSizeUseFixedSizeStorage option is not applicable to Bundle field");
697 static_assert(!ParsedOptions::HasSequenceSizeFieldPrefix,
698 "comms::option::def::SequenceSizeFieldPrefix option is not applicable to Bundle field");
699 static_assert(!ParsedOptions::HasSequenceSerLengthFieldPrefix,
700 "comms::option::def::SequenceSerLengthFieldPrefix option is not applicable to Bundle field");
701 static_assert(!ParsedOptions::HasSequenceElemSerLengthFieldPrefix,
702 "comms::option::def::SequenceElemSerLengthFieldPrefix option is not applicable to Bundle field");
703 static_assert(!ParsedOptions::HasSequenceElemFixedSerLengthFieldPrefix,
704 "comms::option::def::SequenceElemSerLengthFixedFieldPrefix option is not applicable to Bundle field");
705 static_assert(!ParsedOptions::HasSequenceTrailingFieldSuffix,
706 "comms::option::def::SequenceTrailingFieldSuffix option is not applicable to Bundle field");
707 static_assert(!ParsedOptions::HasSequenceTerminationFieldSuffix,
708 "comms::option::def::SequenceTerminationFieldSuffix option is not applicable to Bundle field");
709 static_assert(!ParsedOptions::HasFixedSizeStorage,
710 "comms::option::app::FixedSizeStorage option is not applicable to Bundle field");
711 static_assert(!ParsedOptions::HasCustomStorageType,
712 "comms::option::app::CustomStorageType option is not applicable to Bundle field");
713 static_assert(!ParsedOptions::HasScalingRatio,
714 "comms::option::def::ScalingRatio option is not applicable to Bundle field");
715 static_assert(!ParsedOptions::HasUnits,
716 "comms::option::def::Units option is not applicable to Bundle field");
717 static_assert(!ParsedOptions::HasOrigDataView,
718 "comms::option::app::OrigDataView option is not applicable to Bundle field");
719 static_assert(!ParsedOptions::HasMultiRangeValidation,
720 "comms::option::def::ValidNumValueRange (or similar) option is not applicable to Bundle field");
721 static_assert(!ParsedOptions::HasVersionsRange,
722 "comms::option::def::ExistsBetweenVersions (or similar) option is not applicable to Bundle field");
723 static_assert(!ParsedOptions::HasInvalidByDefault,
724 "comms::option::def::InvalidByDefault option is not applicable to Bundle field");
725 static_assert(!ParsedOptions::HasMissingOnReadFail,
726 "comms::option::def::MissingOnReadFail option is not applicable to Bundle field");
727 static_assert(!ParsedOptions::HasMissingOnInvalid,
728 "comms::option::def::MissingOnInvalid option is not applicable to Bundle field");
736template <
typename TFieldBase,
typename TMembers,
typename... TOptions>
741 return field1.value() == field2.value();
749template <
typename TFieldBase,
typename TMembers,
typename... TOptions>
754 return field1.value() != field2.value();
761template <
typename TFieldBase,
typename TMembers,
typename... TOptions>
766 return field1.value() < field2.value();
773template <
typename TFieldBase,
typename TMembers,
typename... TOptions>
778 return field1.value() <= field2.value();
785template <
typename TFieldBase,
typename TMembers,
typename... TOptions>
790 return field1.value() > field2.value();
797template <
typename TFieldBase,
typename TMembers,
typename... TOptions>
802 return field1.value() >= field2.value();
813 return std::is_same<typename T::CommsTag, tag::Bundle>::value;
818template <
typename TFieldBase,
typename TMembers,
typename... TOptions>
820Bundle<TFieldBase, TMembers, TOptions...>&
828template <
typename TFieldBase,
typename TMembers,
typename... TOptions>
830const 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:63
ValueType & value()
Get access to the stored tuple of fields.
Definition Bundle.h:164
static constexpr std::size_t maxLengthFromUntil()
Get maximal length that is required to serialise specified bundled fields.
Definition Bundle.h:310
bool operator>(const Bundle< TFieldBase, TMembers, TOptions... > &field1, const Bundle< TFieldBase, TMembers, TOptions... > &field2) noexcept
Equivalence comparison operator.
Definition Bundle.h:786
ErrorStatus readFrom(TIter &iter, std::size_t len)
Read selected number of member fields (from specified index).
Definition Bundle.h:338
static constexpr bool hasNonDefaultRefresh()
Compile time check if this class has non-default refresh functionality.
Definition Bundle.h:653
std::size_t length() const
Get length required to serialise bundled fields.
Definition Bundle.h:194
ErrorStatus readUntil(TIter &iter, std::size_t len)
Read selected number of member fields (until specified index).
Definition Bundle.h:371
Bundle()=default
Default constructor.
typename BaseImpl::ValueType ValueType
Value type.
Definition Bundle.h:98
static constexpr std::size_t minLength()
Get minimal length that is required to serialise all bundled fields.
Definition Bundle.h:239
static constexpr std::size_t maxLength()
Get maximal length that is required to serialise all bundled fields.
Definition Bundle.h:278
Bundle(const ValueType &val)
Constructor.
Definition Bundle.h:110
typename BaseImpl::Endian Endian
Endian used for serialisation.
Definition Bundle.h:84
void readFromUntilNoStatus(TIter &iter)
Read selected member fields from input data sequence without error check and status report.
Definition Bundle.h:493
bool operator>=(const Bundle< TFieldBase, TMembers, TOptions... > &field1, const Bundle< TFieldBase, TMembers, TOptions... > &field2) noexcept
Equivalence comparison operator.
Definition Bundle.h:798
constexpr bool isBundle()
Compile time check function of whether a provided type is any variant of comms::field::Bundle.
Definition Bundle.h:811
std::size_t lengthFrom() const
Get length required to serialise specified bundled member fields.
Definition Bundle.h:206
static constexpr std::size_t minLengthFrom()
Get minimal length that is required to serialise specified bundled fields.
Definition Bundle.h:249
void readNoStatus(TIter &iter)
Read field value from input data sequence without error check and status report.
Definition Bundle.h:445
static constexpr std::size_t maxLengthFrom()
Get maximal length that is required to serialise specified bundled fields.
Definition Bundle.h:288
static constexpr bool hasFailOnInvalid()
Compile time inquiry of whether comms::option::def::FailOnInvalid option has been used.
Definition Bundle.h:123
void writeFromUntilNoStatus(TIter &iter)
Write selected member fields to output data sequence without error check and status report.
Definition Bundle.h:627
bool operator<(const Bundle< TFieldBase, TMembers, TOptions... > &field1, const Bundle< TFieldBase, TMembers, TOptions... > &field2) noexcept
Equivalence comparison operator.
Definition Bundle.h:762
ErrorStatus write(TIter &iter, std::size_t size) const
Write current field value to output data sequence.
Definition Bundle.h:511
TFieldBase FieldBase
Base class provided in the first template parameter.
Definition Bundle.h:81
const ValueType & value() const
Get access to the stored tuple of fields.
Definition Bundle.h:170
bool operator==(const Bundle< TFieldBase, TMembers, TOptions... > &field1, const Bundle< TFieldBase, TMembers, TOptions... > &field2) noexcept
Equality comparison operator.
Definition Bundle.h:737
void readUntilNoStatus(TIter &iter)
Read selected member fields from input data sequence without error check and status report.
Definition Bundle.h:475
static constexpr bool hasWriteNoStatus()
Compile time check of whether the field has proper writeNoStatus() member function.
Definition Bundle.h:569
ErrorStatus writeFromUntil(TIter &iter, std::size_t size) const
Write selected member fields to output data sequence.
Definition Bundle.h:562
static constexpr std::size_t maxLengthUntil()
Get maximal length that is required to serialise specified bundled fields.
Definition Bundle.h:298
VersionType getVersion() const
Get version of the field.
Definition Bundle.h:660
static constexpr bool hasIgnoreInvalid()
Compile time inquiry of whether comms::option::def::IgnoreInvalid option has been used.
Definition Bundle.h:130
typename BaseImpl::CommsTag CommsTag
Tag indicating type of the field.
Definition Bundle.h:93
const ValueType & getValue() const
Get value.
Definition Bundle.h:177
ErrorStatus read(TIter &iter, std::size_t size)
Read field value from input data sequence.
Definition Bundle.h:322
std::size_t lengthUntil() const
Get length required to serialise specified bundled member fields.
Definition Bundle.h:218
bool canWrite() const
Check of whether the field has a consistent value for writing.
Definition Bundle.h:499
bool valid() const
Check validity of all the bundled fields.
Definition Bundle.h:633
typename ParsedOptions::FieldType FieldType
Type of actual extending field specified via comms::option::def::FieldType.
Definition Bundle.h:103
Bundle(ValueType &&val)
Constructor.
Definition Bundle.h:116
bool operator<=(const Bundle< TFieldBase, TMembers, TOptions... > &field1, const Bundle< TFieldBase, TMembers, TOptions... > &field2) noexcept
Equivalence comparison operator.
Definition Bundle.h:774
static constexpr bool isVersionDependent()
Compile time check if this class is version dependent.
Definition Bundle.h:647
static constexpr std::size_t minLengthUntil()
Get minimal length that is required to serialise specified bundled fields.
Definition Bundle.h:259
details::OptionsParser< TOptions... > ParsedOptions
All the options provided to this class bundled into struct.
Definition Bundle.h:90
void setValue(U &&val)
Set value.
Definition Bundle.h:185
ErrorStatus writeUntil(TIter &iter, std::size_t size) const
Write selected member fields to output data sequence.
Definition Bundle.h:543
static constexpr bool hasName()
Compile time inquiry of whether comms::option::def::HasName option has been used.
Definition Bundle.h:158
void writeFromNoStatus(TIter &iter)
Write selected member fields to output data sequence without error check and status report.
Definition Bundle.h:595
void writeNoStatus(TIter &iter) const
Write current field value to output data sequence without error check and status report.
Definition Bundle.h:580
bool setVersion(VersionType version)
Default implementation of version update.
Definition Bundle.h:667
ErrorStatus writeFrom(TIter &iter, std::size_t size) const
Write selected member fields to output data sequence.
Definition Bundle.h:527
void readFromNoStatus(TIter &iter)
Read selected member fields from input data sequence without error check and status report.
Definition Bundle.h:460
static constexpr std::size_t minLengthFromUntil()
Get minimal length that is required to serialise specified bundled fields.
Definition Bundle.h:271
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:388
static constexpr bool hasReadNoStatus()
Compile time check of whether the field has proper readNoStatus() member function (or similar).
Definition Bundle.h:434
ErrorStatus readFromUntil(TIter &iter, std::size_t len)
Read selected number of member fields (between specified indices).
Definition Bundle.h:407
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:427
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:355
std::size_t lengthFromUntil() const
Get length required to serialise specified bundled member fields.
Definition Bundle.h:232
static constexpr bool hasFixedValue()
Compile time inquiry of whether comms::option::def::FixedValue option has been used.
Definition Bundle.h:151
void writeUntilNoStatus(TIter &iter)
Write selected member fields to output data sequence without error check and status report.
Definition Bundle.h:610
typename BaseImpl::VersionType VersionType
Version type.
Definition Bundle.h:87
bool refresh()
Refresh the field's contents.
Definition Bundle.h:641
bool operator!=(const Bundle< TFieldBase, TMembers, TOptions... > &field1, const Bundle< TFieldBase, TMembers, TOptions... > &field2) noexcept
Non-equality comparison operator.
Definition Bundle.h:750
static constexpr bool hasFieldType()
Compile time inquiry of whether comms::option::def::FieldType option has been used.
Definition Bundle.h:144
static constexpr bool hasEmptySerialization()
Compile time inquiry of whether comms::option::def::EmptySerialization option has been used.
Definition Bundle.h:137
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:821
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