24template <
typename TFieldBase,
typename T>
25class IntValue :
public TFieldBase
27 static_assert(std::is_integral<T>::value,
"T must be integral value");
29 using BaseImpl = TFieldBase;
33 using SerialisedType = ValueType;
35 using CommsTag = comms::field::tag::Int;
36 using DisplayOffsetType =
typename std::make_signed<ValueType>::type;
40 explicit IntValue(ValueType val)
45 IntValue(
const IntValue&) =
default;
46 IntValue(IntValue&&) =
default;
47 ~IntValue() noexcept = default;
49 IntValue& operator=(const IntValue&) = default;
50 IntValue& operator=(IntValue&&) = default;
52 const ValueType& value()
const
62 const ValueType& getValue()
const
68 void setValue(U&& val)
70 value() =
static_cast<ValueType
>(std::forward<U>(val));
73 static constexpr std::size_t length()
75 return sizeof(SerialisedType);
78 static constexpr std::size_t minLength()
83 static constexpr std::size_t maxLength()
88 static constexpr SerialisedType toSerialised(ValueType val)
90 return static_cast<SerialisedType
>(val);
93 static constexpr ValueType fromSerialised(SerialisedType val)
95 return static_cast<ValueType
>(val);
98 template <
typename TIter>
101 if (size < length()) {
109 template <
typename TIter>
110 void readNoStatus(TIter& iter)
112 auto serialisedValue =
113 BaseImpl::template readData<SerialisedType>(iter);
114 value_ = fromSerialised(serialisedValue);
117 template <
typename TIter>
118 ErrorStatus write(TIter& iter, std::size_t size)
const
120 if (size < length()) {
128 template <
typename TIter>
129 void writeNoStatus(TIter& iter)
const
131 BaseImpl::writeData(toSerialised(value_), iter);
134 static constexpr DisplayOffsetType displayOffset()
136 return static_cast<DisplayOffsetType
>(0);
140 ValueType value_ =
static_cast<ValueType
>(0);
This file contain definition of error statuses used by comms module.
Contains definition of various tag classes.
comms::option::def::ScalingRatio< TNum, TDenom > ScalingRatio
Same as comms::option::def::ScalingRatio.
Definition options.h:1513
Main namespace for all classes / functions of COMMS library.
ErrorStatus
Error statuses reported by the Communication module.
Definition ErrorStatus.h:17
@ Success
Used to indicate successful outcome of the operation.