20#include "cc_tools_qt/details/ToolsFieldBase.h"
21#include "cc_tools_qt/details/ToolsNumericFieldBase.h"
33template <
typename TBase,
typename TField>
34class ToolsNumericFieldImpl :
public ToolsFieldBase<TBase, TField>
36 using Base = ToolsFieldBase<TBase, TField>;
39 using UnderlyingType =
typename Base::UnderlyingType;
40 using SerialisedSeq =
typename Base::SerialisedSeq;
44 using ValueType =
typename Field::ValueType;
46 static_assert(
sizeof(ValueType) <=
sizeof(UnderlyingType),
"This class cannot handle provided field.");
52 explicit ToolsNumericFieldImpl(Field& fieldRef)
56 std::is_base_of_v<ToolsNumericFieldBase<UnderlyingType>, ToolsNumericFieldImpl<TBase, TField>>,
57 "Must inherit from ToolsNumericFieldImpl");
60 ToolsNumericFieldImpl(
const ToolsNumericFieldImpl&) =
default;
61 ToolsNumericFieldImpl(ToolsNumericFieldImpl&&) =
default;
63 ToolsNumericFieldImpl& operator=(
const ToolsNumericFieldImpl&) =
delete;
65 virtual ~ToolsNumericFieldImpl() noexcept = default;
67 virtual UnderlyingType getValueImpl()
const override
69 return static_cast<UnderlyingType
>(Base::field().getValue());
72 virtual void setValueImpl(UnderlyingType value)
override
76 Field::hasFixedValue(),
81 setValueInternal(value, Tag());
84 virtual std::size_t minLengthImpl()
const override
86 return Base::field().minLength();
89 virtual std::size_t maxLengthImpl()
const override
91 return Base::field().maxLength();
95 struct HasFeatureTag {};
96 struct NoFeatureTag {};
98 void setValueInternal(UnderlyingType value, HasFeatureTag)
100 Base::field().setValue(value);
103 void setValueInternal([[maybe_unused]] UnderlyingType value, NoFeatureTag)
105 [[maybe_unused]]
static constexpr bool Must_not_be_called =
false;
106 assert(Must_not_be_called);