From d8601fa7a25d6697a1aca2c58aa59f366ed3e260 Mon Sep 17 00:00:00 2001 From: Alex Robenko Date: Fri, 22 Nov 2024 08:09:28 +1000 Subject: [PATCH] Added support for comms::option::def::HasName option. --- include/comms/Field.h | 7 +++++++ include/comms/field/ArrayList.h | 8 ++++++++ include/comms/field/Bitfield.h | 8 ++++++++ include/comms/field/BitmaskValue.h | 10 +++++++++- include/comms/field/Bundle.h | 8 ++++++++ include/comms/field/EnumValue.h | 10 +++++++++- include/comms/field/FloatValue.h | 8 ++++++++ include/comms/field/IntValue.h | 10 +++++++++- include/comms/field/Optional.h | 8 ++++++++ include/comms/field/String.h | 8 ++++++++ include/comms/field/Variant.h | 10 +++++++++- include/comms/field/details/OptionsParser.h | 10 ++++++++++ 12 files changed, 101 insertions(+), 4 deletions(-) diff --git a/include/comms/Field.h b/include/comms/Field.h index 77f5348..545b129 100644 --- a/include/comms/Field.h +++ b/include/comms/Field.h @@ -111,6 +111,13 @@ class Field : public details::FieldBase return false; } + /// @brief Check of whether the field class defines @b name() function + /// @return Always @b false + static constexpr bool hasName() + { + return false; + } + protected: /// @brief Write data into the output buffer. /// @details Use this function to write data to the the buffer diff --git a/include/comms/field/ArrayList.h b/include/comms/field/ArrayList.h index 5b593fd..d7ab5bc 100644 --- a/include/comms/field/ArrayList.h +++ b/include/comms/field/ArrayList.h @@ -171,6 +171,7 @@ using ArrayListBase = /// @li @ref comms::option::def::FixedValue /// @li @ref comms::option::def::HasCustomRead /// @li @ref comms::option::def::HasCustomRefresh +/// @li @ref comms::option::def::HasName /// @li @ref comms::option::def::IgnoreInvalid /// @li @ref comms::option::def::SequenceElemFixedSerLengthFieldPrefix /// @li @ref comms::option::def::SequenceElemSerLengthFieldPrefix @@ -362,6 +363,13 @@ class ArrayList : public details::ArrayListBasestd::numeric_limits<std::size_t>\::max() is returned. diff --git a/include/comms/field/Bitfield.h b/include/comms/field/Bitfield.h index a43969f..6d50876 100644 --- a/include/comms/field/Bitfield.h +++ b/include/comms/field/Bitfield.h @@ -75,6 +75,7 @@ namespace field /// @li @ref comms::option::def::FixedValue /// @li @ref comms::option::def::HasCustomRead /// @li @ref comms::option::def::HasCustomRefresh +/// @li @ref comms::option::def::HasName /// @li @ref comms::option::def::HasVersionDependentMembers /// @li @ref comms::option::def::VersionStorage @@ -187,6 +188,13 @@ class Bitfield : public return ParsedOptions::HasFixedValue; } + /// @brief Compile time inquiry of whether @ref comms::option::def::HasName option + /// has been used. + static constexpr bool hasName() + { + return ParsedOptions::HasName; + } + /// @brief Retrieve number of bits specified member field consumes. /// @tparam TIdx Index of the member field. /// @return Number of bits, specified with @ref comms::option::def::FixedBitLength option diff --git a/include/comms/field/BitmaskValue.h b/include/comms/field/BitmaskValue.h index f2eb25d..7c263bc 100644 --- a/include/comms/field/BitmaskValue.h +++ b/include/comms/field/BitmaskValue.h @@ -90,6 +90,7 @@ using BitmaskUndertlyingTypeT = /// @li @ref comms::option::def::FixedValue /// @li @ref comms::option::def::HasCustomRead /// @li @ref comms::option::def::HasCustomRefresh +/// @li @ref comms::option::def::HasName /// @li @ref comms::option::def::IgnoreInvalid /// @li @ref comms::option::def::VersionStorage /// @extends comms::Field @@ -194,7 +195,14 @@ class BitmaskValue : public TFieldBase static constexpr bool hasFixedValue() { return ParsedOptions::HasFixedValue; - } + } + + /// @brief Compile time inquiry of whether @ref comms::option::def::HasName option + /// has been used. + static constexpr bool hasName() + { + return ParsedOptions::HasName; + } /// @brief Get access to underlying mask value storage. /// @return Const reference to the underlying stored value. diff --git a/include/comms/field/Bundle.h b/include/comms/field/Bundle.h index 8109973..4d74987 100644 --- a/include/comms/field/Bundle.h +++ b/include/comms/field/Bundle.h @@ -41,6 +41,7 @@ namespace field /// @li @ref comms::option::def::FixedValue /// @li @ref comms::option::def::HasCustomRead /// @li @ref comms::option::def::HasCustomRefresh +/// @li @ref comms::option::def::HasName /// @li @ref comms::option::def::HasVersionDependentMembers /// @li @ref comms::option::def::RemLengthMemberField /// @li @ref comms::option::def::VersionStorage @@ -152,6 +153,13 @@ class Bundle : public return ParsedOptions::HasFixedValue; } + /// @brief Compile time inquiry of whether @ref comms::option::def::HasName option + /// has been used. + static constexpr bool hasName() + { + return ParsedOptions::HasName; + } + /// @brief Get access to the stored tuple of fields. ValueType& value() { diff --git a/include/comms/field/EnumValue.h b/include/comms/field/EnumValue.h index 2234a47..0b4b768 100644 --- a/include/comms/field/EnumValue.h +++ b/include/comms/field/EnumValue.h @@ -59,6 +59,7 @@ namespace field /// @li @ref comms::option::def::FixedValue /// @li @ref comms::option::def::HasCustomRead /// @li @ref comms::option::def::HasCustomRefresh +/// @li @ref comms::option::def::HasName /// @li @ref comms::option::def::IgnoreInvalid /// @li @ref comms::option::def::InvalidByDefault /// @li @ref comms::option::def::NumValueSerOffset @@ -151,7 +152,14 @@ class EnumValue : public details::AdaptBasicFieldT static constexpr bool hasDisplayOffset() { return ParsedOptions::HasDisplayOffset; - } + } + + /// @brief Compile time inquiry of whether @ref comms::option::def::HasName option + /// has been used. + static constexpr bool hasName() + { + return ParsedOptions::HasName; + } /// @brief Scales value according to ratio specified in provided /// @ref comms::option::def::ScalingRatio option. diff --git a/include/comms/field/Optional.h b/include/comms/field/Optional.h index f140050..41ad3a0 100644 --- a/include/comms/field/Optional.h +++ b/include/comms/field/Optional.h @@ -36,6 +36,7 @@ namespace field /// @li @ref comms::option::def::FixedValue /// @li @ref comms::option::def::HasCustomRead /// @li @ref comms::option::def::HasCustomRefresh +/// @li @ref comms::option::def::HasName /// @li @ref comms::option::def::MissingOnInvalid /// @li @ref comms::option::def::MissingOnReadFail /// @li @ref comms::option::def::VersionStorage @@ -141,6 +142,13 @@ class Optional : public details::AdaptBasicFieldT, TOpti return ParsedOptions::HasFixedValue; } + /// @brief Compile time inquiry of whether @ref comms::option::def::HasName option + /// has been used. + static constexpr bool hasName() + { + return ParsedOptions::HasName; + } + /// @brief Check whether mode is equivalent to Mode::Tentative /// @details Convenience wrapper for getMode(), equivalent to /// @code return getMode() == Mode::Tentative; @endcode diff --git a/include/comms/field/String.h b/include/comms/field/String.h index 525de65..9d62bb2 100644 --- a/include/comms/field/String.h +++ b/include/comms/field/String.h @@ -140,6 +140,7 @@ using StringBase = /// @li @ref comms::option::def::FixedValue /// @li @ref comms::option::def::HasCustomRead /// @li @ref comms::option::def::HasCustomRefresh +/// @li @ref comms::option::def::HasName /// @li @ref comms::option::def::IgnoreInvalid /// @li @ref comms::option::def::InvalidByDefault /// @li @ref comms::option::def::SequenceFixedSize @@ -309,6 +310,13 @@ class String : public details::StringBase return ParsedOptions::HasFixedValue; } + /// @brief Compile time inquiry of whether @ref comms::option::def::HasName option + /// has been used. + static constexpr bool hasName() + { + return ParsedOptions::HasName; + } + /// @brief Compile time inquiry of fixed size provided via @ref comms::option::def::SequenceFixedSize option. /// @details If the @ref comms::option::def::SequenceFixedSize option hasn't been used /// std::numeric_limits<std::size_t>\::max() is returned. diff --git a/include/comms/field/Variant.h b/include/comms/field/Variant.h index f00986f..3d94972 100644 --- a/include/comms/field/Variant.h +++ b/include/comms/field/Variant.h @@ -58,6 +58,7 @@ namespace field /// functionality /// @li @ref comms::option::def::HasCustomRefresh - Mark field to have custom /// refresh functionality. +/// @li @ref comms::option::def::HasName /// @li @ref comms::option::def::HasVersionDependentMembers /// @li @ref comms::option::def::VariantHasCustomResetOnDestruct - avoid calling /// default @ref comms::field::Variant::reset() "reset()" on destruction, assume @@ -174,7 +175,14 @@ class Variant : public static constexpr bool hasFixedValue() { return ParsedOptions::HasFixedValue; - } + } + + /// @brief Compile time inquiry of whether @ref comms::option::def::HasName option + /// has been used. + static constexpr bool hasName() + { + return ParsedOptions::HasName; + } /// @brief Get access to the internal storage buffer. /// @details Should not be used in normal operation. diff --git a/include/comms/field/details/OptionsParser.h b/include/comms/field/details/OptionsParser.h index a580180..c20b1fe 100644 --- a/include/comms/field/details/OptionsParser.h +++ b/include/comms/field/details/OptionsParser.h @@ -76,6 +76,7 @@ class OptionsParser<> static constexpr bool HasVersionDependentMembersForced = false; static constexpr bool HasFixedValue = false; static constexpr bool HasDisplayOffset = false; + static constexpr bool HasName = false; using UnitsType = void; using ScalingRatio = std::ratio<1, 1>; @@ -825,6 +826,15 @@ class OptionsParser< using AdaptDisplayOffset = comms::field::adapter::DisplayOffset; }; +template +class OptionsParser< + comms::option::def::HasName, + TOptions...> : public OptionsParser +{ +public: + static constexpr bool HasName = true; +}; + template class OptionsParser< comms::option::app::EmptyOption,