22#include "cc_tools_qt/details/ToolsFieldBase.h"
23#include "cc_tools_qt/details/ToolsNumericFieldBase.h"
35template <
typename TBase,
typename TField>
36class ToolsNumericFieldImpl :
public ToolsFieldBase<TBase, TField>
38 using Base = ToolsFieldBase<TBase, TField>;
41 using UnderlyingType =
typename Base::UnderlyingType;
42 using SerialisedSeq =
typename Base::SerialisedSeq;
46 using ValueType =
typename Field::ValueType;
48 static_assert(
sizeof(ValueType) <=
sizeof(UnderlyingType),
"This class cannot handle provided field.");
54 explicit ToolsNumericFieldImpl(Field& fieldRef)
58 std::is_base_of_v<ToolsNumericFieldBase<UnderlyingType>, ToolsNumericFieldImpl<TBase, TField>>,
59 "Must inherit from ToolsNumericFieldImpl");
62 ToolsNumericFieldImpl(
const ToolsNumericFieldImpl&) =
default;
63 ToolsNumericFieldImpl(ToolsNumericFieldImpl&&) =
default;
65 ToolsNumericFieldImpl& operator=(
const ToolsNumericFieldImpl&) =
delete;
67 virtual ~ToolsNumericFieldImpl() noexcept = default;
69 virtual UnderlyingType getValueImpl()
const override
71 return static_cast<UnderlyingType
>(Base::field().getValue());
74 virtual void setValueImpl(UnderlyingType value)
override
78 Field::hasFixedValue(),
83 setValueInternal(value, Tag());
86 virtual std::size_t minLengthImpl()
const override
88 return Base::field().minLength();
91 virtual std::size_t maxLengthImpl()
const override
93 return Base::field().maxLength();
97 struct HasFeatureTag {};
98 struct NoFeatureTag {};
100 void setValueInternal(UnderlyingType value, HasFeatureTag)
102 Base::field().setValue(value);
105 void setValueInternal([[maybe_unused]] UnderlyingType value, NoFeatureTag)
107 [[maybe_unused]]
static constexpr bool Must_not_be_called =
false;
108 assert(Must_not_be_called);