14#include "comms/field/basic/Bundle.h"
15#include "comms/field/details/AdaptBasicField.h"
57template <
typename TFieldBase,
typename TMembers,
typename... TOptions>
59 details::AdaptBasicFieldT<
62 details::OptionsParser<TOptions...>::ForcedMembersVersionDependency,
68 details::AdaptBasicFieldT<
71 details::OptionsParser<TOptions...>::ForcedMembersVersionDependency,
76 "TMembers is expected to be a tuple of std::tuple<...>");
79 1U <= std::tuple_size<TMembers>::value,
80 "Number of members is expected to be at least 1.");
87 using Endian =
typename BaseImpl::Endian;
120 : BaseImpl(
std::move(val))
128 return ParsedOptions::HasFailOnInvalid;
135 return ParsedOptions::HasIgnoreInvalid;
142 return ParsedOptions::HasEmptySerialization;
149 return ParsedOptions::HasFieldType;
156 return ParsedOptions::HasFixedValue;
163 return ParsedOptions::HasName;
169 return BaseImpl::value();
175 return BaseImpl::value();
182 return BaseImpl::getValue();
187 template <
typename U>
190 BaseImpl::setValue(std::forward<U>(val));
199 return BaseImpl::length();
208 template <std::
size_t TFromIdx>
211 return BaseImpl::template lengthFrom<TFromIdx>();
220 template <std::
size_t TUntilIdx>
223 return BaseImpl::template lengthUntil<TUntilIdx>();
234 template <std::
size_t TFromIdx, std::
size_t TUntilIdx>
237 return BaseImpl::template lengthFromUntil<TFromIdx, TUntilIdx>();
244 return BaseImpl::minLength();
251 template <std::
size_t TFromIdx>
254 return BaseImpl::template minLengthFrom<TFromIdx>();
261 template <std::
size_t TUntilIdx>
264 return BaseImpl::template minLengthUntil<TUntilIdx>();
273 template <std::
size_t TFromIdx, std::
size_t TUntilIdx>
276 return BaseImpl::template minLengthFromUntil<TFromIdx, TUntilIdx>();
283 return BaseImpl::maxLength();
290 template <std::
size_t TFromIdx>
293 return BaseImpl::template maxLengthFrom<TFromIdx>();
300 template <std::
size_t TUntilIdx>
303 return BaseImpl::template maxLengthUntil<TUntilIdx>();
312 template <std::
size_t TFromIdx, std::
size_t TUntilIdx>
315 return BaseImpl::template maxLengthFromUntil<TFromIdx, TUntilIdx>();
324 template <
typename TIter>
327 return BaseImpl::read(iter, size);
340 template <std::
size_t TFromIdx,
typename TIter>
343 return BaseImpl::template readFrom<TFromIdx>(iter, len);
357 template <std::
size_t TFromIdx,
typename TIter>
360 return BaseImpl::template readFromAndUpdateLen<TFromIdx>(iter, len);
373 template <std::
size_t TUntilIdx,
typename TIter>
376 return BaseImpl::template readUntil<TUntilIdx>(iter, len);
390 template <std::
size_t TUntilIdx,
typename TIter>
393 return BaseImpl::template readUntilAndUpdateLen<TUntilIdx>(iter, len);
409 template <std::
size_t TFromIdx, std::
size_t TUntilIdx,
typename TIter>
412 return BaseImpl::template readFromUntil<TFromIdx, TUntilIdx>(iter, len);
429 template <std::
size_t TFromIdx, std::
size_t TUntilIdx,
typename TIter>
432 return BaseImpl::template readFromUntilAndUpdateLen<TFromIdx, TUntilIdx>(iter, len);
439 return BaseImpl::hasReadNoStatus();
447 template <
typename TIter>
450 BaseImpl::readNoStatus(iter);
462 template <std::
size_t TFromIdx,
typename TIter>
465 BaseImpl::template readFromNoStatus<TFromIdx>(iter);
477 template <std::
size_t TUntilIdx,
typename TIter>
480 BaseImpl::template readUntilNoStatus<TUntilIdx>(iter);
495 template <std::
size_t TFromIdx, std::
size_t TUntilIdx,
typename TIter>
498 BaseImpl::template readFromUntilNoStatus<TFromIdx, TUntilIdx>(iter);
504 return BaseImpl::canWrite();
513 template <
typename TIter>
516 return BaseImpl::write(iter, size);
529 template <std::
size_t TFromIdx,
typename TIter>
532 return BaseImpl::template writeFrom<TFromIdx>(iter, size);
545 template <std::
size_t TUntilIdx,
typename TIter>
548 return BaseImpl::template writeUntil<TUntilIdx>(iter, size);
564 template <std::
size_t TFromIdx, std::
size_t TUntilIdx,
typename TIter>
567 return BaseImpl::template writeFromUntil<TFromIdx, TUntilIdx>(iter, size);
574 return BaseImpl::hasWriteNoStatus();
582 template <
typename TIter>
585 BaseImpl::writeNoStatus(iter);
597 template <std::
size_t TFromIdx,
typename TIter>
600 BaseImpl::template writeFromNoStatus<TFromIdx>(iter);
612 template <std::
size_t TUntilIdx,
typename TIter>
615 BaseImpl::template writeUntilNoStatus<TUntilIdx>(iter);
629 template <std::
size_t TFromIdx, std::
size_t TUntilIdx,
typename TIter>
632 BaseImpl::template writeFromUntilNoStatus<TFromIdx, TUntilIdx>(iter);
638 return BaseImpl::valid();
646 return BaseImpl::refresh();
652 return ParsedOptions::HasCustomVersionUpdate || BaseImpl::isVersionDependent();
658 return BaseImpl::hasNonDefaultRefresh();
665 return BaseImpl::getVersion();
672 return BaseImpl::setVersion(
version);
676 using BaseImpl::readData;
677 using BaseImpl::writeData;
680 static_assert(!ParsedOptions::HasSerOffset,
681 "comms::option::def::NumValueSerOffset option is not applicable to Bundle field");
682 static_assert(!ParsedOptions::HasFixedLengthLimit,
683 "comms::option::def::FixedLength option is not applicable to Bundle field");
684 static_assert(!ParsedOptions::HasFixedBitLengthLimit,
685 "comms::option::def::FixedBitLength option is not applicable to Bundle field");
686 static_assert(!ParsedOptions::HasVarLengthLimits,
687 "comms::option::def::VarLength option is not applicable to Bundle field");
688 static_assert(!ParsedOptions::HasAvailableLengthLimit,
689 "comms::option::def::AvailableLengthLimit option is not applicable to Bundle field");
690 static_assert(!ParsedOptions::HasSequenceElemLengthForcing,
691 "comms::option::def::SequenceElemLengthForcingEnabled option is not applicable to Bundle field");
692 static_assert(!ParsedOptions::HasSequenceSizeForcing,
693 "comms::option::def::SequenceSizeForcingEnabled option is not applicable to Bundle field");
694 static_assert(!ParsedOptions::HasSequenceLengthForcing,
695 "comms::option::def::SequenceLengthForcingEnabled option is not applicable to Bundle field");
696 static_assert(!ParsedOptions::HasSequenceFixedSize,
697 "comms::option::def::SequenceFixedSize option is not applicable to Bundle field");
698 static_assert(!ParsedOptions::HasSequenceFixedSizeUseFixedSizeStorage,
699 "comms::option::app::SequenceFixedSizeUseFixedSizeStorage option is not applicable to Bundle field");
700 static_assert(!ParsedOptions::HasSequenceSizeFieldPrefix,
701 "comms::option::def::SequenceSizeFieldPrefix option is not applicable to Bundle field");
702 static_assert(!ParsedOptions::HasSequenceSerLengthFieldPrefix,
703 "comms::option::def::SequenceSerLengthFieldPrefix option is not applicable to Bundle field");
704 static_assert(!ParsedOptions::HasSequenceElemSerLengthFieldPrefix,
705 "comms::option::def::SequenceElemSerLengthFieldPrefix option is not applicable to Bundle field");
706 static_assert(!ParsedOptions::HasSequenceElemFixedSerLengthFieldPrefix,
707 "comms::option::def::SequenceElemSerLengthFixedFieldPrefix option is not applicable to Bundle field");
708 static_assert(!ParsedOptions::HasSequenceTrailingFieldSuffix,
709 "comms::option::def::SequenceTrailingFieldSuffix option is not applicable to Bundle field");
710 static_assert(!ParsedOptions::HasSequenceTerminationFieldSuffix,
711 "comms::option::def::SequenceTerminationFieldSuffix option is not applicable to Bundle field");
712 static_assert(!ParsedOptions::HasFixedSizeStorage,
713 "comms::option::app::FixedSizeStorage option is not applicable to Bundle field");
714 static_assert(!ParsedOptions::HasCustomStorageType,
715 "comms::option::app::CustomStorageType option is not applicable to Bundle field");
716 static_assert(!ParsedOptions::HasScalingRatio,
717 "comms::option::def::ScalingRatio option is not applicable to Bundle field");
718 static_assert(!ParsedOptions::HasUnits,
719 "comms::option::def::Units option is not applicable to Bundle field");
720 static_assert(!ParsedOptions::HasOrigDataView,
721 "comms::option::app::OrigDataView option is not applicable to Bundle field");
722 static_assert(!ParsedOptions::HasMultiRangeValidation,
723 "comms::option::def::ValidNumValueRange (or similar) option is not applicable to Bundle field");
724 static_assert(!ParsedOptions::HasVersionsRange,
725 "comms::option::def::ExistsBetweenVersions (or similar) option is not applicable to Bundle field");
726 static_assert(!ParsedOptions::HasInvalidByDefault,
727 "comms::option::def::InvalidByDefault option is not applicable to Bundle field");
728 static_assert(!ParsedOptions::HasMissingOnReadFail,
729 "comms::option::def::MissingOnReadFail option is not applicable to Bundle field");
730 static_assert(!ParsedOptions::HasMissingOnInvalid,
731 "comms::option::def::MissingOnInvalid option is not applicable to Bundle field");
739template <
typename TFieldBase,
typename TMembers,
typename... TOptions>
744 return field1.value() == field2.value();
752template <
typename TFieldBase,
typename TMembers,
typename... TOptions>
757 return field1.value() != field2.value();
764template <
typename TFieldBase,
typename TMembers,
typename... TOptions>
769 return field1.value() < field2.value();
776template <
typename TFieldBase,
typename TMembers,
typename... TOptions>
781 return field1.value() <= field2.value();
788template <
typename TFieldBase,
typename TMembers,
typename... TOptions>
793 return field1.value() > field2.value();
800template <
typename TFieldBase,
typename TMembers,
typename... TOptions>
805 return field1.value() >= field2.value();
816 return std::is_same<typename T::CommsTag, tag::Bundle>::value;
821template <
typename TFieldBase,
typename TMembers,
typename... TOptions>
823Bundle<TFieldBase, TMembers, TOptions...>&
831template <
typename TFieldBase,
typename TMembers,
typename... TOptions>
833const 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:66
ValueType & value()
Get access to the stored tuple of fields.
Definition Bundle.h:167
static constexpr std::size_t maxLengthFromUntil()
Get maximal length that is required to serialise specified bundled fields.
Definition Bundle.h:313
bool operator>(const Bundle< TFieldBase, TMembers, TOptions... > &field1, const Bundle< TFieldBase, TMembers, TOptions... > &field2) noexcept
Equivalence comparison operator.
Definition Bundle.h:789
ErrorStatus readFrom(TIter &iter, std::size_t len)
Read selected number of member fields (from specified index).
Definition Bundle.h:341
static constexpr bool hasNonDefaultRefresh()
Compile time check if this class has non-default refresh functionality.
Definition Bundle.h:656
std::size_t length() const
Get length required to serialise bundled fields.
Definition Bundle.h:197
ErrorStatus readUntil(TIter &iter, std::size_t len)
Read selected number of member fields (until specified index).
Definition Bundle.h:374
Bundle()=default
Default constructor.
typename BaseImpl::ValueType ValueType
Value type.
Definition Bundle.h:101
static constexpr std::size_t minLength()
Get minimal length that is required to serialise all bundled fields.
Definition Bundle.h:242
static constexpr std::size_t maxLength()
Get maximal length that is required to serialise all bundled fields.
Definition Bundle.h:281
Bundle(const ValueType &val)
Constructor.
Definition Bundle.h:113
typename BaseImpl::Endian Endian
Endian used for serialisation.
Definition Bundle.h:87
void readFromUntilNoStatus(TIter &iter)
Read selected member fields from input data sequence without error check and status report.
Definition Bundle.h:496
bool operator>=(const Bundle< TFieldBase, TMembers, TOptions... > &field1, const Bundle< TFieldBase, TMembers, TOptions... > &field2) noexcept
Equivalence comparison operator.
Definition Bundle.h:801
constexpr bool isBundle()
Compile time check function of whether a provided type is any variant of comms::field::Bundle.
Definition Bundle.h:814
std::size_t lengthFrom() const
Get length required to serialise specified bundled member fields.
Definition Bundle.h:209
static constexpr std::size_t minLengthFrom()
Get minimal length that is required to serialise specified bundled fields.
Definition Bundle.h:252
void readNoStatus(TIter &iter)
Read field value from input data sequence without error check and status report.
Definition Bundle.h:448
static constexpr std::size_t maxLengthFrom()
Get maximal length that is required to serialise specified bundled fields.
Definition Bundle.h:291
static constexpr bool hasFailOnInvalid()
Compile time inquiry of whether comms::option::def::FailOnInvalid option has been used.
Definition Bundle.h:126
void writeFromUntilNoStatus(TIter &iter)
Write selected member fields to output data sequence without error check and status report.
Definition Bundle.h:630
bool operator<(const Bundle< TFieldBase, TMembers, TOptions... > &field1, const Bundle< TFieldBase, TMembers, TOptions... > &field2) noexcept
Equivalence comparison operator.
Definition Bundle.h:765
ErrorStatus write(TIter &iter, std::size_t size) const
Write current field value to output data sequence.
Definition Bundle.h:514
TFieldBase FieldBase
Base class provided in the first template parameter.
Definition Bundle.h:84
const ValueType & value() const
Get access to the stored tuple of fields.
Definition Bundle.h:173
bool operator==(const Bundle< TFieldBase, TMembers, TOptions... > &field1, const Bundle< TFieldBase, TMembers, TOptions... > &field2) noexcept
Equality comparison operator.
Definition Bundle.h:740
void readUntilNoStatus(TIter &iter)
Read selected member fields from input data sequence without error check and status report.
Definition Bundle.h:478
static constexpr bool hasWriteNoStatus()
Compile time check of whether the field has proper writeNoStatus() member function.
Definition Bundle.h:572
ErrorStatus writeFromUntil(TIter &iter, std::size_t size) const
Write selected member fields to output data sequence.
Definition Bundle.h:565
static constexpr std::size_t maxLengthUntil()
Get maximal length that is required to serialise specified bundled fields.
Definition Bundle.h:301
VersionType getVersion() const
Get version of the field.
Definition Bundle.h:663
static constexpr bool hasIgnoreInvalid()
Compile time inquiry of whether comms::option::def::IgnoreInvalid option has been used.
Definition Bundle.h:133
typename BaseImpl::CommsTag CommsTag
Tag indicating type of the field.
Definition Bundle.h:96
const ValueType & getValue() const
Get value.
Definition Bundle.h:180
ErrorStatus read(TIter &iter, std::size_t size)
Read field value from input data sequence.
Definition Bundle.h:325
std::size_t lengthUntil() const
Get length required to serialise specified bundled member fields.
Definition Bundle.h:221
bool canWrite() const
Check of whether the field has a consistent value for writing.
Definition Bundle.h:502
bool valid() const
Check validity of all the bundled fields.
Definition Bundle.h:636
typename ParsedOptions::FieldType FieldType
Type of actual extending field specified via comms::option::def::FieldType.
Definition Bundle.h:106
Bundle(ValueType &&val)
Constructor.
Definition Bundle.h:119
bool operator<=(const Bundle< TFieldBase, TMembers, TOptions... > &field1, const Bundle< TFieldBase, TMembers, TOptions... > &field2) noexcept
Equivalence comparison operator.
Definition Bundle.h:777
static constexpr bool isVersionDependent()
Compile time check if this class is version dependent.
Definition Bundle.h:650
static constexpr std::size_t minLengthUntil()
Get minimal length that is required to serialise specified bundled fields.
Definition Bundle.h:262
details::OptionsParser< TOptions... > ParsedOptions
All the options provided to this class bundled into struct.
Definition Bundle.h:93
void setValue(U &&val)
Set value.
Definition Bundle.h:188
ErrorStatus writeUntil(TIter &iter, std::size_t size) const
Write selected member fields to output data sequence.
Definition Bundle.h:546
static constexpr bool hasName()
Compile time inquiry of whether comms::option::def::HasName option has been used.
Definition Bundle.h:161
void writeFromNoStatus(TIter &iter)
Write selected member fields to output data sequence without error check and status report.
Definition Bundle.h:598
void writeNoStatus(TIter &iter) const
Write current field value to output data sequence without error check and status report.
Definition Bundle.h:583
bool setVersion(VersionType version)
Default implementation of version update.
Definition Bundle.h:670
ErrorStatus writeFrom(TIter &iter, std::size_t size) const
Write selected member fields to output data sequence.
Definition Bundle.h:530
void readFromNoStatus(TIter &iter)
Read selected member fields from input data sequence without error check and status report.
Definition Bundle.h:463
static constexpr std::size_t minLengthFromUntil()
Get minimal length that is required to serialise specified bundled fields.
Definition Bundle.h:274
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:391
static constexpr bool hasReadNoStatus()
Compile time check of whether the field has proper readNoStatus() member function (or similar).
Definition Bundle.h:437
ErrorStatus readFromUntil(TIter &iter, std::size_t len)
Read selected number of member fields (between specified indices).
Definition Bundle.h:410
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:430
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:358
std::size_t lengthFromUntil() const
Get length required to serialise specified bundled member fields.
Definition Bundle.h:235
static constexpr bool hasFixedValue()
Compile time inquiry of whether comms::option::def::FixedValue option has been used.
Definition Bundle.h:154
void writeUntilNoStatus(TIter &iter)
Write selected member fields to output data sequence without error check and status report.
Definition Bundle.h:613
typename BaseImpl::VersionType VersionType
Version type.
Definition Bundle.h:90
bool refresh()
Refresh the field's contents.
Definition Bundle.h:644
bool operator!=(const Bundle< TFieldBase, TMembers, TOptions... > &field1, const Bundle< TFieldBase, TMembers, TOptions... > &field2) noexcept
Non-equality comparison operator.
Definition Bundle.h:753
static constexpr bool hasFieldType()
Compile time inquiry of whether comms::option::def::FieldType option has been used.
Definition Bundle.h:147
static constexpr bool hasEmptySerialization()
Compile time inquiry of whether comms::option::def::EmptySerialization option has been used.
Definition Bundle.h:140
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:824
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