16#include "comms/field/basic/Bundle.h"
17#include "comms/field/details/AdaptBasicField.h"
61template <
typename TFieldBase,
typename TMembers,
typename... TOptions>
63 details::AdaptBasicFieldT<
66 details::OptionsParser<TOptions...>::ForcedMembersVersionDependency,
72 details::AdaptBasicFieldT<
75 details::OptionsParser<TOptions...>::ForcedMembersVersionDependency,
80 "TMembers is expected to be a tuple of std::tuple<...>");
83 1U <= std::tuple_size<TMembers>::value,
84 "Number of members is expected to be at least 1.");
91 using Endian =
typename BaseImpl::Endian;
124 : BaseImpl(
std::move(val))
132 return ParsedOptions::HasFailOnInvalid;
139 return ParsedOptions::HasIgnoreInvalid;
146 return ParsedOptions::HasEmptySerialization;
153 return ParsedOptions::HasFieldType;
160 return ParsedOptions::HasFixedValue;
167 return ParsedOptions::HasName;
173 return BaseImpl::value();
179 return BaseImpl::value();
186 return BaseImpl::getValue();
191 template <
typename U>
194 BaseImpl::setValue(std::forward<U>(val));
203 return BaseImpl::length();
212 template <std::
size_t TFromIdx>
215 return BaseImpl::template lengthFrom<TFromIdx>();
224 template <std::
size_t TUntilIdx>
227 return BaseImpl::template lengthUntil<TUntilIdx>();
238 template <std::
size_t TFromIdx, std::
size_t TUntilIdx>
241 return BaseImpl::template lengthFromUntil<TFromIdx, TUntilIdx>();
248 return BaseImpl::minLength();
255 template <std::
size_t TFromIdx>
258 return BaseImpl::template minLengthFrom<TFromIdx>();
265 template <std::
size_t TUntilIdx>
268 return BaseImpl::template minLengthUntil<TUntilIdx>();
277 template <std::
size_t TFromIdx, std::
size_t TUntilIdx>
280 return BaseImpl::template minLengthFromUntil<TFromIdx, TUntilIdx>();
287 return BaseImpl::maxLength();
294 template <std::
size_t TFromIdx>
297 return BaseImpl::template maxLengthFrom<TFromIdx>();
304 template <std::
size_t TUntilIdx>
307 return BaseImpl::template maxLengthUntil<TUntilIdx>();
316 template <std::
size_t TFromIdx, std::
size_t TUntilIdx>
319 return BaseImpl::template maxLengthFromUntil<TFromIdx, TUntilIdx>();
328 template <
typename TIter>
331 return BaseImpl::read(iter, size);
344 template <std::
size_t TFromIdx,
typename TIter>
347 return BaseImpl::template readFrom<TFromIdx>(iter, len);
361 template <std::
size_t TFromIdx,
typename TIter>
364 return BaseImpl::template readFromAndUpdateLen<TFromIdx>(iter, len);
377 template <std::
size_t TUntilIdx,
typename TIter>
380 return BaseImpl::template readUntil<TUntilIdx>(iter, len);
394 template <std::
size_t TUntilIdx,
typename TIter>
397 return BaseImpl::template readUntilAndUpdateLen<TUntilIdx>(iter, len);
413 template <std::
size_t TFromIdx, std::
size_t TUntilIdx,
typename TIter>
416 return BaseImpl::template readFromUntil<TFromIdx, TUntilIdx>(iter, len);
433 template <std::
size_t TFromIdx, std::
size_t TUntilIdx,
typename TIter>
436 return BaseImpl::template readFromUntilAndUpdateLen<TFromIdx, TUntilIdx>(iter, len);
443 return BaseImpl::hasReadNoStatus();
451 template <
typename TIter>
454 BaseImpl::readNoStatus(iter);
466 template <std::
size_t TFromIdx,
typename TIter>
469 BaseImpl::template readFromNoStatus<TFromIdx>(iter);
481 template <std::
size_t TUntilIdx,
typename TIter>
484 BaseImpl::template readUntilNoStatus<TUntilIdx>(iter);
499 template <std::
size_t TFromIdx, std::
size_t TUntilIdx,
typename TIter>
502 BaseImpl::template readFromUntilNoStatus<TFromIdx, TUntilIdx>(iter);
508 return BaseImpl::canWrite();
517 template <
typename TIter>
520 return BaseImpl::write(iter, size);
533 template <std::
size_t TFromIdx,
typename TIter>
536 return BaseImpl::template writeFrom<TFromIdx>(iter, size);
549 template <std::
size_t TUntilIdx,
typename TIter>
552 return BaseImpl::template writeUntil<TUntilIdx>(iter, size);
568 template <std::
size_t TFromIdx, std::
size_t TUntilIdx,
typename TIter>
571 return BaseImpl::template writeFromUntil<TFromIdx, TUntilIdx>(iter, size);
578 return BaseImpl::hasWriteNoStatus();
586 template <
typename TIter>
589 BaseImpl::writeNoStatus(iter);
601 template <std::
size_t TFromIdx,
typename TIter>
604 BaseImpl::template writeFromNoStatus<TFromIdx>(iter);
616 template <std::
size_t TUntilIdx,
typename TIter>
619 BaseImpl::template writeUntilNoStatus<TUntilIdx>(iter);
633 template <std::
size_t TFromIdx, std::
size_t TUntilIdx,
typename TIter>
636 BaseImpl::template writeFromUntilNoStatus<TFromIdx, TUntilIdx>(iter);
642 return BaseImpl::valid();
650 return BaseImpl::refresh();
656 return ParsedOptions::HasCustomVersionUpdate || BaseImpl::isVersionDependent();
662 return BaseImpl::hasNonDefaultRefresh();
669 return BaseImpl::getVersion();
676 return BaseImpl::setVersion(
version);
680 using BaseImpl::readData;
681 using BaseImpl::writeData;
684 static_assert(!ParsedOptions::HasSerOffset,
685 "comms::option::def::NumValueSerOffset option is not applicable to Bundle field");
686 static_assert(!ParsedOptions::HasFixedLengthLimit,
687 "comms::option::def::FixedLength option is not applicable to Bundle field");
688 static_assert(!ParsedOptions::HasFixedBitLengthLimit,
689 "comms::option::def::FixedBitLength option is not applicable to Bundle field");
690 static_assert(!ParsedOptions::HasVarLengthLimits,
691 "comms::option::def::VarLength option is not applicable to Bundle field");
692 static_assert(!ParsedOptions::HasAvailableLengthLimit,
693 "comms::option::def::AvailableLengthLimit option is not applicable to Bundle field");
694 static_assert(!ParsedOptions::HasSequenceElemLengthForcing,
695 "comms::option::def::SequenceElemLengthForcingEnabled option is not applicable to Bundle field");
696 static_assert(!ParsedOptions::HasSequenceSizeForcing,
697 "comms::option::def::SequenceSizeForcingEnabled option is not applicable to Bundle field");
698 static_assert(!ParsedOptions::HasSequenceLengthForcing,
699 "comms::option::def::SequenceLengthForcingEnabled option is not applicable to Bundle field");
700 static_assert(!ParsedOptions::HasSequenceFixedSize,
701 "comms::option::def::SequenceFixedSize option is not applicable to Bundle field");
702 static_assert(!ParsedOptions::HasSequenceFixedSizeUseFixedSizeStorage,
703 "comms::option::app::SequenceFixedSizeUseFixedSizeStorage option is not applicable to Bundle field");
704 static_assert(!ParsedOptions::HasSequenceSizeFieldPrefix,
705 "comms::option::def::SequenceSizeFieldPrefix option is not applicable to Bundle field");
706 static_assert(!ParsedOptions::HasSequenceSerLengthFieldPrefix,
707 "comms::option::def::SequenceSerLengthFieldPrefix option is not applicable to Bundle field");
708 static_assert(!ParsedOptions::HasSequenceElemSerLengthFieldPrefix,
709 "comms::option::def::SequenceElemSerLengthFieldPrefix option is not applicable to Bundle field");
710 static_assert(!ParsedOptions::HasSequenceElemFixedSerLengthFieldPrefix,
711 "comms::option::def::SequenceElemSerLengthFixedFieldPrefix option is not applicable to Bundle field");
712 static_assert(!ParsedOptions::HasSequenceTrailingFieldSuffix,
713 "comms::option::def::SequenceTrailingFieldSuffix option is not applicable to Bundle field");
714 static_assert(!ParsedOptions::HasSequenceTerminationFieldSuffix,
715 "comms::option::def::SequenceTerminationFieldSuffix option is not applicable to Bundle field");
716 static_assert(!ParsedOptions::HasFixedSizeStorage,
717 "comms::option::app::FixedSizeStorage option is not applicable to Bundle field");
718 static_assert(!ParsedOptions::HasCustomStorageType,
719 "comms::option::app::CustomStorageType option is not applicable to Bundle field");
720 static_assert(!ParsedOptions::HasScalingRatio,
721 "comms::option::def::ScalingRatio option is not applicable to Bundle field");
722 static_assert(!ParsedOptions::HasUnits,
723 "comms::option::def::Units option is not applicable to Bundle field");
724 static_assert(!ParsedOptions::HasOrigDataView,
725 "comms::option::app::OrigDataView option is not applicable to Bundle field");
726 static_assert(!ParsedOptions::HasMultiRangeValidation,
727 "comms::option::def::ValidNumValueRange (or similar) option is not applicable to Bundle field");
728 static_assert(!ParsedOptions::HasVersionsRange,
729 "comms::option::def::ExistsBetweenVersions (or similar) option is not applicable to Bundle field");
730 static_assert(!ParsedOptions::HasInvalidByDefault,
731 "comms::option::def::InvalidByDefault option is not applicable to Bundle field");
732 static_assert(!ParsedOptions::HasMissingOnReadFail,
733 "comms::option::def::MissingOnReadFail option is not applicable to Bundle field");
734 static_assert(!ParsedOptions::HasMissingOnInvalid,
735 "comms::option::def::MissingOnInvalid option is not applicable to Bundle field");
743template <
typename TFieldBase,
typename TMembers,
typename... TOptions>
748 return field1.value() == field2.value();
756template <
typename TFieldBase,
typename TMembers,
typename... TOptions>
761 return field1.value() != field2.value();
768template <
typename TFieldBase,
typename TMembers,
typename... TOptions>
773 return field1.value() < field2.value();
780template <
typename TFieldBase,
typename TMembers,
typename... TOptions>
785 return field1.value() <= field2.value();
792template <
typename TFieldBase,
typename TMembers,
typename... TOptions>
797 return field1.value() > field2.value();
804template <
typename TFieldBase,
typename TMembers,
typename... TOptions>
809 return field1.value() >= field2.value();
820 return std::is_same<typename T::CommsTag, tag::Bundle>::value;
825template <
typename TFieldBase,
typename TMembers,
typename... TOptions>
827Bundle<TFieldBase, TMembers, TOptions...>&
835template <
typename TFieldBase,
typename TMembers,
typename... TOptions>
837const Bundle<TFieldBase, TMembers, TOptions...>&
This file contain definition of error statuses used by comms module.
Contains various tuple type manipulation classes and functions.
Bundles multiple fields into a single field.
Definition Bundle.h:70
ValueType & value()
Get access to the stored tuple of fields.
Definition Bundle.h:171
static constexpr std::size_t maxLengthFromUntil()
Get maximal length that is required to serialise specified bundled fields.
Definition Bundle.h:317
bool operator>(const Bundle< TFieldBase, TMembers, TOptions... > &field1, const Bundle< TFieldBase, TMembers, TOptions... > &field2) noexcept
Equivalence comparison operator.
Definition Bundle.h:793
ErrorStatus readFrom(TIter &iter, std::size_t len)
Read selected number of member fields (from specified index).
Definition Bundle.h:345
static constexpr bool hasNonDefaultRefresh()
Compile time check if this class has non-default refresh functionality.
Definition Bundle.h:660
std::size_t length() const
Get length required to serialise bundled fields.
Definition Bundle.h:201
ErrorStatus readUntil(TIter &iter, std::size_t len)
Read selected number of member fields (until specified index).
Definition Bundle.h:378
Bundle()=default
Default constructor.
typename BaseImpl::ValueType ValueType
Value type.
Definition Bundle.h:105
static constexpr std::size_t minLength()
Get minimal length that is required to serialise all bundled fields.
Definition Bundle.h:246
static constexpr std::size_t maxLength()
Get maximal length that is required to serialise all bundled fields.
Definition Bundle.h:285
Bundle(const ValueType &val)
Constructor.
Definition Bundle.h:117
typename BaseImpl::Endian Endian
Endian used for serialisation.
Definition Bundle.h:91
void readFromUntilNoStatus(TIter &iter)
Read selected member fields from input data sequence without error check and status report.
Definition Bundle.h:500
bool operator>=(const Bundle< TFieldBase, TMembers, TOptions... > &field1, const Bundle< TFieldBase, TMembers, TOptions... > &field2) noexcept
Equivalence comparison operator.
Definition Bundle.h:805
constexpr bool isBundle()
Compile time check function of whether a provided type is any variant of comms::field::Bundle.
Definition Bundle.h:818
std::size_t lengthFrom() const
Get length required to serialise specified bundled member fields.
Definition Bundle.h:213
static constexpr std::size_t minLengthFrom()
Get minimal length that is required to serialise specified bundled fields.
Definition Bundle.h:256
void readNoStatus(TIter &iter)
Read field value from input data sequence without error check and status report.
Definition Bundle.h:452
static constexpr std::size_t maxLengthFrom()
Get maximal length that is required to serialise specified bundled fields.
Definition Bundle.h:295
static constexpr bool hasFailOnInvalid()
Compile time inquiry of whether comms::option::def::FailOnInvalid option has been used.
Definition Bundle.h:130
void writeFromUntilNoStatus(TIter &iter)
Write selected member fields to output data sequence without error check and status report.
Definition Bundle.h:634
bool operator<(const Bundle< TFieldBase, TMembers, TOptions... > &field1, const Bundle< TFieldBase, TMembers, TOptions... > &field2) noexcept
Equivalence comparison operator.
Definition Bundle.h:769
ErrorStatus write(TIter &iter, std::size_t size) const
Write current field value to output data sequence.
Definition Bundle.h:518
TFieldBase FieldBase
Base class provided in the first template parameter.
Definition Bundle.h:88
const ValueType & value() const
Get access to the stored tuple of fields.
Definition Bundle.h:177
bool operator==(const Bundle< TFieldBase, TMembers, TOptions... > &field1, const Bundle< TFieldBase, TMembers, TOptions... > &field2) noexcept
Equality comparison operator.
Definition Bundle.h:744
void readUntilNoStatus(TIter &iter)
Read selected member fields from input data sequence without error check and status report.
Definition Bundle.h:482
static constexpr bool hasWriteNoStatus()
Compile time check of whether the field has proper writeNoStatus() member function.
Definition Bundle.h:576
ErrorStatus writeFromUntil(TIter &iter, std::size_t size) const
Write selected member fields to output data sequence.
Definition Bundle.h:569
static constexpr std::size_t maxLengthUntil()
Get maximal length that is required to serialise specified bundled fields.
Definition Bundle.h:305
VersionType getVersion() const
Get version of the field.
Definition Bundle.h:667
static constexpr bool hasIgnoreInvalid()
Compile time inquiry of whether comms::option::def::IgnoreInvalid option has been used.
Definition Bundle.h:137
typename BaseImpl::CommsTag CommsTag
Tag indicating type of the field.
Definition Bundle.h:100
const ValueType & getValue() const
Get value.
Definition Bundle.h:184
ErrorStatus read(TIter &iter, std::size_t size)
Read field value from input data sequence.
Definition Bundle.h:329
std::size_t lengthUntil() const
Get length required to serialise specified bundled member fields.
Definition Bundle.h:225
bool canWrite() const
Check of whether the field has a consistent value for writing.
Definition Bundle.h:506
bool valid() const
Check validity of all the bundled fields.
Definition Bundle.h:640
typename ParsedOptions::FieldType FieldType
Type of actual extending field specified via comms::option::def::FieldType.
Definition Bundle.h:110
Bundle(ValueType &&val)
Constructor.
Definition Bundle.h:123
bool operator<=(const Bundle< TFieldBase, TMembers, TOptions... > &field1, const Bundle< TFieldBase, TMembers, TOptions... > &field2) noexcept
Equivalence comparison operator.
Definition Bundle.h:781
static constexpr bool isVersionDependent()
Compile time check if this class is version dependent.
Definition Bundle.h:654
static constexpr std::size_t minLengthUntil()
Get minimal length that is required to serialise specified bundled fields.
Definition Bundle.h:266
details::OptionsParser< TOptions... > ParsedOptions
All the options provided to this class bundled into struct.
Definition Bundle.h:97
void setValue(U &&val)
Set value.
Definition Bundle.h:192
ErrorStatus writeUntil(TIter &iter, std::size_t size) const
Write selected member fields to output data sequence.
Definition Bundle.h:550
static constexpr bool hasName()
Compile time inquiry of whether comms::option::def::HasName option has been used.
Definition Bundle.h:165
void writeFromNoStatus(TIter &iter)
Write selected member fields to output data sequence without error check and status report.
Definition Bundle.h:602
void writeNoStatus(TIter &iter) const
Write current field value to output data sequence without error check and status report.
Definition Bundle.h:587
bool setVersion(VersionType version)
Default implementation of version update.
Definition Bundle.h:674
ErrorStatus writeFrom(TIter &iter, std::size_t size) const
Write selected member fields to output data sequence.
Definition Bundle.h:534
void readFromNoStatus(TIter &iter)
Read selected member fields from input data sequence without error check and status report.
Definition Bundle.h:467
static constexpr std::size_t minLengthFromUntil()
Get minimal length that is required to serialise specified bundled fields.
Definition Bundle.h:278
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:395
static constexpr bool hasReadNoStatus()
Compile time check of whether the field has proper readNoStatus() member function (or similar).
Definition Bundle.h:441
ErrorStatus readFromUntil(TIter &iter, std::size_t len)
Read selected number of member fields (between specified indices).
Definition Bundle.h:414
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:434
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:362
std::size_t lengthFromUntil() const
Get length required to serialise specified bundled member fields.
Definition Bundle.h:239
static constexpr bool hasFixedValue()
Compile time inquiry of whether comms::option::def::FixedValue option has been used.
Definition Bundle.h:158
void writeUntilNoStatus(TIter &iter)
Write selected member fields to output data sequence without error check and status report.
Definition Bundle.h:617
typename BaseImpl::VersionType VersionType
Version type.
Definition Bundle.h:94
bool refresh()
Refresh the field's contents.
Definition Bundle.h:648
bool operator!=(const Bundle< TFieldBase, TMembers, TOptions... > &field1, const Bundle< TFieldBase, TMembers, TOptions... > &field2) noexcept
Non-equality comparison operator.
Definition Bundle.h:757
static constexpr bool hasFieldType()
Compile time inquiry of whether comms::option::def::FieldType option has been used.
Definition Bundle.h:151
static constexpr bool hasEmptySerialization()
Compile time inquiry of whether comms::option::def::EmptySerialization option has been used.
Definition Bundle.h:144
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:828
Main namespace for all classes / functions of COMMS library.
ErrorStatus
Error statuses reported by the Communication module.
Definition ErrorStatus.h:19
constexpr unsigned version()
Version of the COMMS library as single numeric value.
Definition version.h:66
Contains definition of all the options used by the COMMS library.
Check whether provided type is a variant of std::tuple.
Definition Tuple.h:39