26template <
typename TFieldBase,
typename T>
27class IntValue :
public TFieldBase
29 static_assert(std::is_integral<T>::value,
"T must be integral value");
31 using BaseImpl = TFieldBase;
35 using SerialisedType = ValueType;
37 using CommsTag = comms::field::tag::Int;
38 using DisplayOffsetType =
typename std::make_signed<ValueType>::type;
42 explicit IntValue(ValueType val)
47 IntValue(
const IntValue&) =
default;
48 IntValue(IntValue&&) =
default;
49 ~IntValue() noexcept = default;
51 IntValue& operator=(const IntValue&) = default;
52 IntValue& operator=(IntValue&&) = default;
54 const ValueType& value()
const
64 const ValueType& getValue()
const
70 void setValue(U&& val)
72 value() =
static_cast<ValueType
>(std::forward<U>(val));
75 static constexpr std::size_t length()
77 return sizeof(SerialisedType);
80 static constexpr std::size_t minLength()
85 static constexpr std::size_t maxLength()
90 static constexpr SerialisedType toSerialised(ValueType val)
92 return static_cast<SerialisedType
>(val);
95 static constexpr ValueType fromSerialised(SerialisedType val)
97 return static_cast<ValueType
>(val);
100 template <
typename TIter>
103 if (size < length()) {
111 template <
typename TIter>
112 void readNoStatus(TIter& iter)
114 auto serialisedValue =
115 BaseImpl::template readData<SerialisedType>(iter);
116 m_value = fromSerialised(serialisedValue);
119 template <
typename TIter>
120 ErrorStatus write(TIter& iter, std::size_t size)
const
122 if (size < length()) {
130 template <
typename TIter>
131 void writeNoStatus(TIter& iter)
const
133 BaseImpl::writeData(toSerialised(m_value), iter);
136 static constexpr DisplayOffsetType displayOffset()
138 return static_cast<DisplayOffsetType
>(0);
142 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.