25template <
typename TFieldBase,
typename T>
26class IntValue :
public TFieldBase
28 static_assert(std::is_integral<T>::value,
"T must be integral value");
30 using BaseImpl = TFieldBase;
34 using SerialisedType = ValueType;
36 using CommsTag = comms::field::tag::Int;
37 using DisplayOffsetType =
typename std::make_signed<ValueType>::type;
41 explicit IntValue(ValueType val)
46 IntValue(
const IntValue&) =
default;
47 IntValue(IntValue&&) =
default;
48 ~IntValue() noexcept = default;
50 IntValue& operator=(const IntValue&) = default;
51 IntValue& operator=(IntValue&&) = default;
53 const ValueType& value()
const
63 const ValueType& getValue()
const
69 void setValue(U&& val)
71 value() =
static_cast<ValueType
>(std::forward<U>(val));
74 static constexpr std::size_t length()
76 return sizeof(SerialisedType);
79 static constexpr std::size_t minLength()
84 static constexpr std::size_t maxLength()
89 static constexpr SerialisedType toSerialised(ValueType val)
91 return static_cast<SerialisedType
>(val);
94 static constexpr ValueType fromSerialised(SerialisedType val)
96 return static_cast<ValueType
>(val);
99 template <
typename TIter>
102 if (size < length()) {
110 template <
typename TIter>
111 void readNoStatus(TIter& iter)
113 auto serialisedValue =
114 BaseImpl::template readData<SerialisedType>(iter);
115 m_value = fromSerialised(serialisedValue);
118 template <
typename TIter>
119 ErrorStatus write(TIter& iter, std::size_t size)
const
121 if (size < length()) {
129 template <
typename TIter>
130 void writeNoStatus(TIter& iter)
const
132 BaseImpl::writeData(toSerialised(m_value), iter);
135 static constexpr DisplayOffsetType displayOffset()
137 return static_cast<DisplayOffsetType
>(0);
141 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:1544
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.