25#include "comms/field/IntValue.h"
26#include "NumericValueWrapper.h"
31namespace field_wrapper
34class CC_API UnsignedLongValueWrapper :
public NumericValueWrapper<long long unsigned>
36 typedef NumericValueWrapper<long long unsigned> Base;
39 typedef Base::UnderlyingType UnderlyingType;
40 typedef std::unique_ptr<UnsignedLongValueWrapper> Ptr;
42 UnsignedLongValueWrapper();
43 virtual ~UnsignedLongValueWrapper() 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 UnsignedLongValueWrapperT : public NumericValueWrapperT<UnsignedLongValueWrapper, TField>
77 using Base = NumericValueWrapperT<UnsignedLongValueWrapper, 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 UnsignedLongValueWrapperT(Field& fieldRef)
91 UnsignedLongValueWrapperT(
const UnsignedLongValueWrapperT&) =
default;
92 UnsignedLongValueWrapperT(UnsignedLongValueWrapperT&&) =
default;
93 virtual ~UnsignedLongValueWrapperT() noexcept = default;
95 UnsignedLongValueWrapperT& operator=(const UnsignedLongValueWrapperT&) = 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 UnsignedLongValueWrapperT<TField>(Base::field()));
141using UnsignedLongValueWrapperPtr = UnsignedLongValueWrapper::Ptr;
143template <
typename TField>
144UnsignedLongValueWrapperPtr
145makeUnsignedLongValueWrapper(TField& field)
148 UnsignedLongValueWrapperPtr(
149 new UnsignedLongValueWrapperT<TField>(field));