14#include "comms/field/basic/Bundle.h"
15#include "comms/field/details/AdaptBasicField.h"
55template <
typename TFieldBase,
typename TMembers,
typename... TOptions>
57 details::AdaptBasicFieldT<
60 details::OptionsParser<TOptions...>::ForcedMembersVersionDependency,
66 details::AdaptBasicFieldT<
69 details::OptionsParser<TOptions...>::ForcedMembersVersionDependency,
74 "TMembers is expected to be a tuple of std::tuple<...>");
77 1U <= std::tuple_size<TMembers>::value,
78 "Number of members is expected to be at least 1.");
85 using Endian =
typename BaseImpl::Endian;
118 : BaseImpl(
std::move(val))
126 return ParsedOptions::HasFailOnInvalid;
133 return ParsedOptions::HasIgnoreInvalid;
140 return ParsedOptions::HasEmptySerialization;
147 return ParsedOptions::HasFieldType;
154 return ParsedOptions::HasFixedValue;
161 return ParsedOptions::HasName;
167 return BaseImpl::value();
173 return BaseImpl::value();
180 return BaseImpl::getValue();
185 template <
typename U>
188 BaseImpl::setValue(std::forward<U>(val));
197 return BaseImpl::length();
206 template <std::
size_t TFromIdx>
209 return BaseImpl::template lengthFrom<TFromIdx>();
218 template <std::
size_t TUntilIdx>
221 return BaseImpl::template lengthUntil<TUntilIdx>();
232 template <std::
size_t TFromIdx, std::
size_t TUntilIdx>
235 return BaseImpl::template lengthFromUntil<TFromIdx, TUntilIdx>();
242 return BaseImpl::minLength();
249 template <std::
size_t TFromIdx>
252 return BaseImpl::template minLengthFrom<TFromIdx>();
259 template <std::
size_t TUntilIdx>
262 return BaseImpl::template minLengthUntil<TUntilIdx>();
271 template <std::
size_t TFromIdx, std::
size_t TUntilIdx>
274 return BaseImpl::template minLengthFromUntil<TFromIdx, TUntilIdx>();
281 return BaseImpl::maxLength();
288 template <std::
size_t TFromIdx>
291 return BaseImpl::template maxLengthFrom<TFromIdx>();
298 template <std::
size_t TUntilIdx>
301 return BaseImpl::template maxLengthUntil<TUntilIdx>();
310 template <std::
size_t TFromIdx, std::
size_t TUntilIdx>
313 return BaseImpl::template maxLengthFromUntil<TFromIdx, TUntilIdx>();
322 template <
typename TIter>
325 return BaseImpl::read(iter, size);
338 template <std::
size_t TFromIdx,
typename TIter>
341 return BaseImpl::template readFrom<TFromIdx>(iter, len);
355 template <std::
size_t TFromIdx,
typename TIter>
358 return BaseImpl::template readFromAndUpdateLen<TFromIdx>(iter, len);
371 template <std::
size_t TUntilIdx,
typename TIter>
374 return BaseImpl::template readUntil<TUntilIdx>(iter, len);
388 template <std::
size_t TUntilIdx,
typename TIter>
391 return BaseImpl::template readUntilAndUpdateLen<TUntilIdx>(iter, len);
407 template <std::
size_t TFromIdx, std::
size_t TUntilIdx,
typename TIter>
410 return BaseImpl::template readFromUntil<TFromIdx, TUntilIdx>(iter, len);
427 template <std::
size_t TFromIdx, std::
size_t TUntilIdx,
typename TIter>
430 return BaseImpl::template readFromUntilAndUpdateLen<TFromIdx, TUntilIdx>(iter, len);
437 return BaseImpl::hasReadNoStatus();
445 template <
typename TIter>
448 BaseImpl::readNoStatus(iter);
460 template <std::
size_t TFromIdx,
typename TIter>
463 BaseImpl::template readFromNoStatus<TFromIdx>(iter);
475 template <std::
size_t TUntilIdx,
typename TIter>
478 BaseImpl::template readUntilNoStatus<TUntilIdx>(iter);
493 template <std::
size_t TFromIdx, std::
size_t TUntilIdx,
typename TIter>
496 BaseImpl::template readFromUntilNoStatus<TFromIdx, TUntilIdx>(iter);
502 return BaseImpl::canWrite();
511 template <
typename TIter>
514 return BaseImpl::write(iter, size);
527 template <std::
size_t TFromIdx,
typename TIter>
530 return BaseImpl::template writeFrom<TFromIdx>(iter, size);
543 template <std::
size_t TUntilIdx,
typename TIter>
546 return BaseImpl::template writeUntil<TUntilIdx>(iter, size);
562 template <std::
size_t TFromIdx, std::
size_t TUntilIdx,
typename TIter>
565 return BaseImpl::template writeFromUntil<TFromIdx, TUntilIdx>(iter, size);
572 return BaseImpl::hasWriteNoStatus();
580 template <
typename TIter>
583 BaseImpl::writeNoStatus(iter);
595 template <std::
size_t TFromIdx,
typename TIter>
598 BaseImpl::template writeFromNoStatus<TFromIdx>(iter);
610 template <std::
size_t TUntilIdx,
typename TIter>
613 BaseImpl::template writeUntilNoStatus<TUntilIdx>(iter);
627 template <std::
size_t TFromIdx, std::
size_t TUntilIdx,
typename TIter>
630 BaseImpl::template writeFromUntilNoStatus<TFromIdx, TUntilIdx>(iter);
636 return BaseImpl::valid();
644 return BaseImpl::refresh();
650 return ParsedOptions::HasCustomVersionUpdate || BaseImpl::isVersionDependent();
656 return BaseImpl::hasNonDefaultRefresh();
663 return BaseImpl::getVersion();
670 return BaseImpl::setVersion(
version);
674 using BaseImpl::readData;
675 using BaseImpl::writeData;
678 static_assert(!ParsedOptions::HasSerOffset,
679 "comms::option::def::NumValueSerOffset option is not applicable to Bundle field");
680 static_assert(!ParsedOptions::HasFixedLengthLimit,
681 "comms::option::def::FixedLength option is not applicable to Bundle field");
682 static_assert(!ParsedOptions::HasFixedBitLengthLimit,
683 "comms::option::def::FixedBitLength option is not applicable to Bundle field");
684 static_assert(!ParsedOptions::HasVarLengthLimits,
685 "comms::option::def::VarLength option is not applicable to Bundle field");
686 static_assert(!ParsedOptions::HasAvailableLengthLimit,
687 "comms::option::def::AvailableLengthLimit option is not applicable to Bundle field");
688 static_assert(!ParsedOptions::HasSequenceElemLengthForcing,
689 "comms::option::def::SequenceElemLengthForcingEnabled option is not applicable to Bundle field");
690 static_assert(!ParsedOptions::HasSequenceSizeForcing,
691 "comms::option::def::SequenceSizeForcingEnabled option is not applicable to Bundle field");
692 static_assert(!ParsedOptions::HasSequenceLengthForcing,
693 "comms::option::def::SequenceLengthForcingEnabled option is not applicable to Bundle field");
694 static_assert(!ParsedOptions::HasSequenceFixedSize,
695 "comms::option::def::SequenceFixedSize option is not applicable to Bundle field");
696 static_assert(!ParsedOptions::HasSequenceFixedSizeUseFixedSizeStorage,
697 "comms::option::app::SequenceFixedSizeUseFixedSizeStorage option is not applicable to Bundle field");
698 static_assert(!ParsedOptions::HasSequenceSizeFieldPrefix,
699 "comms::option::def::SequenceSizeFieldPrefix option is not applicable to Bundle field");
700 static_assert(!ParsedOptions::HasSequenceSerLengthFieldPrefix,
701 "comms::option::def::SequenceSerLengthFieldPrefix option is not applicable to Bundle field");
702 static_assert(!ParsedOptions::HasSequenceElemSerLengthFieldPrefix,
703 "comms::option::def::SequenceElemSerLengthFieldPrefix option is not applicable to Bundle field");
704 static_assert(!ParsedOptions::HasSequenceElemFixedSerLengthFieldPrefix,
705 "comms::option::def::SequenceElemSerLengthFixedFieldPrefix option is not applicable to Bundle field");
706 static_assert(!ParsedOptions::HasSequenceTrailingFieldSuffix,
707 "comms::option::def::SequenceTrailingFieldSuffix option is not applicable to Bundle field");
708 static_assert(!ParsedOptions::HasSequenceTerminationFieldSuffix,
709 "comms::option::def::SequenceTerminationFieldSuffix option is not applicable to Bundle field");
710 static_assert(!ParsedOptions::HasFixedSizeStorage,
711 "comms::option::app::FixedSizeStorage option is not applicable to Bundle field");
712 static_assert(!ParsedOptions::HasCustomStorageType,
713 "comms::option::app::CustomStorageType option is not applicable to Bundle field");
714 static_assert(!ParsedOptions::HasScalingRatio,
715 "comms::option::def::ScalingRatio option is not applicable to Bundle field");
716 static_assert(!ParsedOptions::HasUnits,
717 "comms::option::def::Units option is not applicable to Bundle field");
718 static_assert(!ParsedOptions::HasOrigDataView,
719 "comms::option::app::OrigDataView option is not applicable to Bundle field");
720 static_assert(!ParsedOptions::HasMultiRangeValidation,
721 "comms::option::def::ValidNumValueRange (or similar) option is not applicable to Bundle field");
722 static_assert(!ParsedOptions::HasVersionsRange,
723 "comms::option::def::ExistsBetweenVersions (or similar) option is not applicable to Bundle field");
724 static_assert(!ParsedOptions::HasInvalidByDefault,
725 "comms::option::def::InvalidByDefault option is not applicable to Bundle field");
726 static_assert(!ParsedOptions::HasMissingOnReadFail,
727 "comms::option::def::MissingOnReadFail option is not applicable to Bundle field");
728 static_assert(!ParsedOptions::HasMissingOnInvalid,
729 "comms::option::def::MissingOnInvalid option is not applicable to Bundle field");
737template <
typename TFieldBase,
typename TMembers,
typename... TOptions>
742 return field1.value() == field2.value();
750template <
typename TFieldBase,
typename TMembers,
typename... TOptions>
755 return field1.value() != field2.value();
762template <
typename TFieldBase,
typename TMembers,
typename... TOptions>
767 return field1.value() < field2.value();
774template <
typename TFieldBase,
typename TMembers,
typename... TOptions>
779 return field1.value() <= field2.value();
786template <
typename TFieldBase,
typename TMembers,
typename... TOptions>
791 return field1.value() > field2.value();
798template <
typename TFieldBase,
typename TMembers,
typename... TOptions>
803 return field1.value() >= field2.value();
814 return std::is_same<typename T::CommsTag, tag::Bundle>::value;
819template <
typename TFieldBase,
typename TMembers,
typename... TOptions>
821Bundle<TFieldBase, TMembers, TOptions...>&
829template <
typename TFieldBase,
typename TMembers,
typename... TOptions>
831const 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:64
ValueType & value()
Get access to the stored tuple of fields.
Definition Bundle.h:165
static constexpr std::size_t maxLengthFromUntil()
Get maximal length that is required to serialise specified bundled fields.
Definition Bundle.h:311
bool operator>(const Bundle< TFieldBase, TMembers, TOptions... > &field1, const Bundle< TFieldBase, TMembers, TOptions... > &field2) noexcept
Equivalence comparison operator.
Definition Bundle.h:787
ErrorStatus readFrom(TIter &iter, std::size_t len)
Read selected number of member fields (from specified index).
Definition Bundle.h:339
static constexpr bool hasNonDefaultRefresh()
Compile time check if this class has non-default refresh functionality.
Definition Bundle.h:654
std::size_t length() const
Get length required to serialise bundled fields.
Definition Bundle.h:195
ErrorStatus readUntil(TIter &iter, std::size_t len)
Read selected number of member fields (until specified index).
Definition Bundle.h:372
Bundle()=default
Default constructor.
typename BaseImpl::ValueType ValueType
Value type.
Definition Bundle.h:99
static constexpr std::size_t minLength()
Get minimal length that is required to serialise all bundled fields.
Definition Bundle.h:240
static constexpr std::size_t maxLength()
Get maximal length that is required to serialise all bundled fields.
Definition Bundle.h:279
Bundle(const ValueType &val)
Constructor.
Definition Bundle.h:111
typename BaseImpl::Endian Endian
Endian used for serialisation.
Definition Bundle.h:85
void readFromUntilNoStatus(TIter &iter)
Read selected member fields from input data sequence without error check and status report.
Definition Bundle.h:494
bool operator>=(const Bundle< TFieldBase, TMembers, TOptions... > &field1, const Bundle< TFieldBase, TMembers, TOptions... > &field2) noexcept
Equivalence comparison operator.
Definition Bundle.h:799
constexpr bool isBundle()
Compile time check function of whether a provided type is any variant of comms::field::Bundle.
Definition Bundle.h:812
std::size_t lengthFrom() const
Get length required to serialise specified bundled member fields.
Definition Bundle.h:207
static constexpr std::size_t minLengthFrom()
Get minimal length that is required to serialise specified bundled fields.
Definition Bundle.h:250
void readNoStatus(TIter &iter)
Read field value from input data sequence without error check and status report.
Definition Bundle.h:446
static constexpr std::size_t maxLengthFrom()
Get maximal length that is required to serialise specified bundled fields.
Definition Bundle.h:289
static constexpr bool hasFailOnInvalid()
Compile time inquiry of whether comms::option::def::FailOnInvalid option has been used.
Definition Bundle.h:124
void writeFromUntilNoStatus(TIter &iter)
Write selected member fields to output data sequence without error check and status report.
Definition Bundle.h:628
bool operator<(const Bundle< TFieldBase, TMembers, TOptions... > &field1, const Bundle< TFieldBase, TMembers, TOptions... > &field2) noexcept
Equivalence comparison operator.
Definition Bundle.h:763
ErrorStatus write(TIter &iter, std::size_t size) const
Write current field value to output data sequence.
Definition Bundle.h:512
TFieldBase FieldBase
Base class provided in the first template parameter.
Definition Bundle.h:82
const ValueType & value() const
Get access to the stored tuple of fields.
Definition Bundle.h:171
bool operator==(const Bundle< TFieldBase, TMembers, TOptions... > &field1, const Bundle< TFieldBase, TMembers, TOptions... > &field2) noexcept
Equality comparison operator.
Definition Bundle.h:738
void readUntilNoStatus(TIter &iter)
Read selected member fields from input data sequence without error check and status report.
Definition Bundle.h:476
static constexpr bool hasWriteNoStatus()
Compile time check of whether the field has proper writeNoStatus() member function.
Definition Bundle.h:570
ErrorStatus writeFromUntil(TIter &iter, std::size_t size) const
Write selected member fields to output data sequence.
Definition Bundle.h:563
static constexpr std::size_t maxLengthUntil()
Get maximal length that is required to serialise specified bundled fields.
Definition Bundle.h:299
VersionType getVersion() const
Get version of the field.
Definition Bundle.h:661
static constexpr bool hasIgnoreInvalid()
Compile time inquiry of whether comms::option::def::IgnoreInvalid option has been used.
Definition Bundle.h:131
typename BaseImpl::CommsTag CommsTag
Tag indicating type of the field.
Definition Bundle.h:94
const ValueType & getValue() const
Get value.
Definition Bundle.h:178
ErrorStatus read(TIter &iter, std::size_t size)
Read field value from input data sequence.
Definition Bundle.h:323
std::size_t lengthUntil() const
Get length required to serialise specified bundled member fields.
Definition Bundle.h:219
bool canWrite() const
Check of whether the field has a consistent value for writing.
Definition Bundle.h:500
bool valid() const
Check validity of all the bundled fields.
Definition Bundle.h:634
typename ParsedOptions::FieldType FieldType
Type of actual extending field specified via comms::option::def::FieldType.
Definition Bundle.h:104
Bundle(ValueType &&val)
Constructor.
Definition Bundle.h:117
bool operator<=(const Bundle< TFieldBase, TMembers, TOptions... > &field1, const Bundle< TFieldBase, TMembers, TOptions... > &field2) noexcept
Equivalence comparison operator.
Definition Bundle.h:775
static constexpr bool isVersionDependent()
Compile time check if this class is version dependent.
Definition Bundle.h:648
static constexpr std::size_t minLengthUntil()
Get minimal length that is required to serialise specified bundled fields.
Definition Bundle.h:260
details::OptionsParser< TOptions... > ParsedOptions
All the options provided to this class bundled into struct.
Definition Bundle.h:91
void setValue(U &&val)
Set value.
Definition Bundle.h:186
ErrorStatus writeUntil(TIter &iter, std::size_t size) const
Write selected member fields to output data sequence.
Definition Bundle.h:544
static constexpr bool hasName()
Compile time inquiry of whether comms::option::def::HasName option has been used.
Definition Bundle.h:159
void writeFromNoStatus(TIter &iter)
Write selected member fields to output data sequence without error check and status report.
Definition Bundle.h:596
void writeNoStatus(TIter &iter) const
Write current field value to output data sequence without error check and status report.
Definition Bundle.h:581
bool setVersion(VersionType version)
Default implementation of version update.
Definition Bundle.h:668
ErrorStatus writeFrom(TIter &iter, std::size_t size) const
Write selected member fields to output data sequence.
Definition Bundle.h:528
void readFromNoStatus(TIter &iter)
Read selected member fields from input data sequence without error check and status report.
Definition Bundle.h:461
static constexpr std::size_t minLengthFromUntil()
Get minimal length that is required to serialise specified bundled fields.
Definition Bundle.h:272
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:389
static constexpr bool hasReadNoStatus()
Compile time check of whether the field has proper readNoStatus() member function (or similar).
Definition Bundle.h:435
ErrorStatus readFromUntil(TIter &iter, std::size_t len)
Read selected number of member fields (between specified indices).
Definition Bundle.h:408
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:428
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:356
std::size_t lengthFromUntil() const
Get length required to serialise specified bundled member fields.
Definition Bundle.h:233
static constexpr bool hasFixedValue()
Compile time inquiry of whether comms::option::def::FixedValue option has been used.
Definition Bundle.h:152
void writeUntilNoStatus(TIter &iter)
Write selected member fields to output data sequence without error check and status report.
Definition Bundle.h:611
typename BaseImpl::VersionType VersionType
Version type.
Definition Bundle.h:88
bool refresh()
Refresh the field's contents.
Definition Bundle.h:642
bool operator!=(const Bundle< TFieldBase, TMembers, TOptions... > &field1, const Bundle< TFieldBase, TMembers, TOptions... > &field2) noexcept
Non-equality comparison operator.
Definition Bundle.h:751
static constexpr bool hasFieldType()
Compile time inquiry of whether comms::option::def::FieldType option has been used.
Definition Bundle.h:145
static constexpr bool hasEmptySerialization()
Compile time inquiry of whether comms::option::def::EmptySerialization option has been used.
Definition Bundle.h:138
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:822
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