29template <
typename TFieldBase,
typename T>
30class IntValue :
public TFieldBase
32 static_assert(std::is_integral<T>::value,
"T must be integral value");
34 using BaseImpl = TFieldBase;
38 using SerialisedType = ValueType;
40 using CommsTag = comms::field::tag::Int;
41 using DisplayOffsetType =
typename std::make_signed<ValueType>::type;
45 explicit IntValue(ValueType val)
50 IntValue(
const IntValue&) =
default;
51 IntValue(IntValue&&) =
default;
52 ~IntValue() noexcept = default;
54 IntValue& operator=(const IntValue&) = default;
55 IntValue& operator=(IntValue&&) = default;
57 const ValueType& value()
const
67 const ValueType& getValue()
const
73 void setValue(U&& val)
75 value() =
static_cast<ValueType
>(std::forward<U>(val));
78 static constexpr std::size_t length()
80 return sizeof(SerialisedType);
83 static constexpr std::size_t minLength()
88 static constexpr std::size_t maxLength()
93 static constexpr SerialisedType toSerialised(ValueType val)
95 return static_cast<SerialisedType
>(val);
98 static constexpr ValueType fromSerialised(SerialisedType val)
100 return static_cast<ValueType
>(val);
103 template <
typename TIter>
106 if (size < length()) {
114 template <
typename TIter>
115 void readNoStatus(TIter& iter)
117 auto serialisedValue =
118 BaseImpl::template readData<SerialisedType>(iter);
119 m_value = fromSerialised(serialisedValue);
122 template <
typename TIter>
123 ErrorStatus write(TIter& iter, std::size_t size)
const
125 if (size < length()) {
133 template <
typename TIter>
134 void writeNoStatus(TIter& iter)
const
136 BaseImpl::writeData(toSerialised(m_value), iter);
139 static constexpr DisplayOffsetType displayOffset()
141 return static_cast<DisplayOffsetType
>(0);
145 ValueType m_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:1557
Main namespace for all classes / functions of COMMS library.
ErrorStatus
Error statuses reported by the Communication module.
Definition ErrorStatus.h:19
@ Success
Used to indicate successful outcome of the operation.