25#include "comms/field/IntValue.h"
26#include "NumericValueWrapper.h"
31namespace field_wrapper
34class CC_API IntValueWrapper :
public NumericValueWrapper<long long int>
36 typedef NumericValueWrapper<long long int> Base;
39 typedef Base::UnderlyingType UnderlyingType;
40 typedef std::unique_ptr<IntValueWrapper> Ptr;
43 virtual ~IntValueWrapper() noexcept;
45 UnderlyingType minValue() const;
47 UnderlyingType maxValue() const;
49 double getScaled() const;
51 void setScaled(
double value);
53 double scaleValue(UnderlyingType value) const;
55 bool isSigned() const;
57 std::
size_t valueTypeSize() const;
62 virtual UnderlyingType minValueImpl() const = 0;
63 virtual UnderlyingType maxValueImpl() const = 0;
64 virtual
double getScaledImpl() const = 0;
65 virtual
void setScaledImpl(
double value) = 0;
66 virtual
double scaleValueImpl(UnderlyingType value) const = 0;
67 virtual
bool isSignedImpl() const = 0;
68 virtual std::
size_t valueTypeSizeImpl() const = 0;
69 virtual Ptr cloneImpl() = 0;
71 void dispatchImpl(FieldWrapperHandler& handler);
74template <typename TField>
75class IntValueWrapperT : public NumericValueWrapperT<IntValueWrapper, TField>
77 using Base = NumericValueWrapperT<IntValueWrapper, TField>;
79 static_assert(comms::field::isIntValue<Field>(),
"Must be of IntValueField type");
83 typedef typename Base::UnderlyingType UnderlyingType;
84 typedef typename Base::Ptr Ptr;
86 explicit IntValueWrapperT(Field& fieldRef)
91 IntValueWrapperT(
const IntValueWrapperT&) =
default;
92 IntValueWrapperT(IntValueWrapperT&&) =
default;
93 virtual ~IntValueWrapperT() noexcept = default;
95 IntValueWrapperT& operator=(const IntValueWrapperT&) = delete;
98 virtual UnderlyingType minValueImpl()
const override
100 return std::numeric_limits<typename Field::ValueType>::min();
103 virtual UnderlyingType maxValueImpl()
const override
105 return std::numeric_limits<typename Field::ValueType>::max();
108 virtual double getScaledImpl()
const override
110 return Base::field().template scaleAs<double>();
113 virtual void setScaledImpl(
double value)
override
115 Base::field().setScaled(value);
118 virtual double scaleValueImpl(UnderlyingType value)
const override
121 fieldTmp.setValue(value);
122 return fieldTmp.template scaleAs<double>();
125 virtual bool isSignedImpl()
const override
127 return std::is_signed<typename Field::ValueType>::value;
130 virtual std::size_t valueTypeSizeImpl()
const override
132 return sizeof(
typename Field::ValueType);
135 virtual Ptr cloneImpl()
override
137 return Ptr(
new IntValueWrapperT<TField>(Base::field()));
141using IntValueWrapperPtr = IntValueWrapper::Ptr;
143template <
typename TField>
145makeIntValueWrapper(TField& field)
149 new IntValueWrapperT<TField>(field));