27#include "comms/field/IntValue.h"
28#include "NumericValueWrapper.h"
33namespace field_wrapper
36class CC_API FloatValueWrapper :
public NumericValueWrapper<double>
38 typedef NumericValueWrapper<double> Base;
41 typedef Base::UnderlyingType UnderlyingType;
42 typedef std::unique_ptr<FloatValueWrapper> Ptr;
45 virtual ~FloatValueWrapper() noexcept;
52 bool isMinusInf() const;
54 double getEpsilon() const;
57 virtual Ptr cloneImpl() = 0;
58 virtual
bool isNanImpl() const = 0;
59 virtual
void setNanImpl() = 0;
60 virtual
bool isInfImpl() const = 0;
61 virtual
void setInfImpl() = 0;
62 virtual
bool isMinusInfImpl() const = 0;
63 virtual
void setMinusInfImpl() = 0;
64 virtual
double getEpsilonImpl() const = 0;
66 virtual
void dispatchImpl(FieldWrapperHandler& handler) override;
69template <typename TField>
70class FloatValueWrapperT : public NumericValueWrapperT<FloatValueWrapper, TField>
72 using Base = NumericValueWrapperT<FloatValueWrapper, TField>;
74 static_assert(comms::field::isFloatValue<Field>(),
"Must be of FloatValueField type");
78 typedef typename Base::UnderlyingType UnderlyingType;
79 typedef typename Base::Ptr Ptr;
81 explicit FloatValueWrapperT(Field& fieldRef)
86 FloatValueWrapperT(
const FloatValueWrapperT&) =
default;
87 FloatValueWrapperT(FloatValueWrapperT&&) =
default;
88 virtual ~FloatValueWrapperT() noexcept = default;
90 FloatValueWrapperT& operator=(const FloatValueWrapperT&) = delete;
93 virtual Ptr cloneImpl()
override
95 return Ptr(
new FloatValueWrapperT<TField>(Base::field()));
98 virtual bool isNanImpl()
const override
100 return std::isnan(Base::field().getValue());
103 virtual void setNanImpl()
override
105 Base::field().setValue(std::numeric_limits<typename TField::ValueType>::quiet_NaN());
108 virtual bool isInfImpl()
const override
110 return std::isinf(Base::field().getValue()) && (0 < Base::field().getValue());
113 virtual void setInfImpl()
override
115 Base::field().setValue(std::numeric_limits<typename TField::ValueType>::infinity());
118 virtual bool isMinusInfImpl()
const override
120 return std::isinf(Base::field().getValue()) && (Base::field().getValue() < 0);
123 virtual void setMinusInfImpl()
override
125 Base::field().setValue(-std::numeric_limits<typename TField::ValueType>::infinity());
128 virtual double getEpsilonImpl()
const override
130 return static_cast<double>(std::numeric_limits<typename TField::ValueType>::epsilon());
134using FloatValueWrapperPtr = FloatValueWrapper::Ptr;
136template <
typename TField>
138makeFloatValueWrapper(TField& field)
141 FloatValueWrapperPtr(
142 new FloatValueWrapperT<TField>(field));