21#include "cc_tools_qt/details/ToolsFieldBase.h"
22#include "cc_tools_qt/details/ToolsNumericFieldBase.h"
34template <
typename TBase,
typename TField>
35class ToolsNumericFieldImpl :
public ToolsFieldBase<TBase, TField>
37 using Base = ToolsFieldBase<TBase, TField>;
40 using UnderlyingType =
typename Base::UnderlyingType;
41 using SerialisedSeq =
typename Base::SerialisedSeq;
45 using ValueType =
typename Field::ValueType;
47 static_assert(
sizeof(ValueType) <=
sizeof(UnderlyingType),
"This class cannot handle provided field.");
53 explicit ToolsNumericFieldImpl(Field& fieldRef)
57 std::is_base_of_v<ToolsNumericFieldBase<UnderlyingType>, ToolsNumericFieldImpl<TBase, TField>>,
58 "Must inherit from ToolsNumericFieldImpl");
61 ToolsNumericFieldImpl(
const ToolsNumericFieldImpl&) =
default;
62 ToolsNumericFieldImpl(ToolsNumericFieldImpl&&) =
default;
64 ToolsNumericFieldImpl& operator=(
const ToolsNumericFieldImpl&) =
delete;
66 virtual ~ToolsNumericFieldImpl() noexcept = default;
68 virtual UnderlyingType getValueImpl()
const override
70 return static_cast<UnderlyingType
>(Base::field().getValue());
73 virtual void setValueImpl(UnderlyingType value)
override
77 Field::hasFixedValue(),
82 setValueInternal(value, Tag());
85 virtual std::size_t minLengthImpl()
const override
87 return Base::field().minLength();
90 virtual std::size_t maxLengthImpl()
const override
92 return Base::field().maxLength();
96 struct HasFeatureTag {};
97 struct NoFeatureTag {};
99 void setValueInternal(UnderlyingType value, HasFeatureTag)
101 Base::field().setValue(value);
104 void setValueInternal([[maybe_unused]] UnderlyingType value, NoFeatureTag)
106 [[maybe_unused]]
static constexpr bool Must_not_be_called =
false;
107 assert(Must_not_be_called);