Skip to content

Commit

Permalink
Added support for comms::option::def::HasName option.
Browse files Browse the repository at this point in the history
  • Loading branch information
arobenko committed Nov 21, 2024
1 parent c93bad4 commit d8601fa
Show file tree
Hide file tree
Showing 12 changed files with 101 additions and 4 deletions.
7 changes: 7 additions & 0 deletions include/comms/Field.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@ class Field : public details::FieldBase<TOptions...>
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
Expand Down
8 changes: 8 additions & 0 deletions include/comms/field/ArrayList.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -362,6 +363,13 @@ class ArrayList : public details::ArrayListBase<TFieldBase, TElement, TOptions..
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
/// <b>std::numeric_limits&lt;std::size_t&gt;\::max()</b> is returned.
Expand Down
8 changes: 8 additions & 0 deletions include/comms/field/Bitfield.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion include/comms/field/BitmaskValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
8 changes: 8 additions & 0 deletions include/comms/field/Bundle.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
{
Expand Down
10 changes: 9 additions & 1 deletion include/comms/field/EnumValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -151,7 +152,14 @@ class EnumValue : public details::AdaptBasicFieldT<basic::EnumValue<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 enum value storage.
const ValueType& value() const
Expand Down
8 changes: 8 additions & 0 deletions include/comms/field/FloatValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,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 @b comms::option::def::Units* - all variants of value units, see
Expand Down Expand Up @@ -145,6 +146,13 @@ class FloatValue : public details::AdaptBasicFieldT<basic::FloatValue<TFieldBase
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 floating point value storage.
const ValueType& value() const
{
Expand Down
10 changes: 9 additions & 1 deletion include/comms/field/IntValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,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
Expand Down Expand Up @@ -191,7 +192,14 @@ class IntValue : public details::AdaptBasicFieldT<basic::IntValue<TFieldBase, T>
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.
Expand Down
8 changes: 8 additions & 0 deletions include/comms/field/Optional.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -141,6 +142,13 @@ class Optional : public details::AdaptBasicFieldT<basic::Optional<TField>, 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
Expand Down
8 changes: 8 additions & 0 deletions include/comms/field/String.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -309,6 +310,13 @@ class String : public details::StringBase<TFieldBase, TOptions...>
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
/// <b>std::numeric_limits&lt;std::size_t&gt;\::max()</b> is returned.
Expand Down
10 changes: 9 additions & 1 deletion include/comms/field/Variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
10 changes: 10 additions & 0 deletions include/comms/field/details/OptionsParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
Expand Down Expand Up @@ -825,6 +826,15 @@ class OptionsParser<
using AdaptDisplayOffset = comms::field::adapter::DisplayOffset<TOffset, TField>;
};

template <typename... TOptions>
class OptionsParser<
comms::option::def::HasName,
TOptions...> : public OptionsParser<TOptions...>
{
public:
static constexpr bool HasName = true;
};

template <typename... TOptions>
class OptionsParser<
comms::option::app::EmptyOption,
Expand Down

0 comments on commit d8601fa

Please sign in to comment.