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;
39 explicit IntValue(ValueType val)
44 IntValue(
const IntValue&) =
default;
45 IntValue(IntValue&&) =
default;
46 ~IntValue() noexcept = default;
48 IntValue& operator=(const IntValue&) = default;
49 IntValue& operator=(IntValue&&) = default;
51 const ValueType& value()
const
61 const ValueType& getValue()
const
67 void setValue(U&& val)
69 value() =
static_cast<ValueType
>(std::forward<U>(val));
72 static constexpr std::size_t length()
74 return sizeof(SerialisedType);
77 static constexpr std::size_t minLength()
82 static constexpr std::size_t maxLength()
87 static constexpr SerialisedType toSerialised(ValueType val)
89 return static_cast<SerialisedType
>(val);
92 static constexpr ValueType fromSerialised(SerialisedType val)
94 return static_cast<ValueType
>(val);
97 template <
typename TIter>
100 if (size < length()) {
108 template <
typename TIter>
109 void readNoStatus(TIter& iter)
111 auto serialisedValue =
112 BaseImpl::template readData<SerialisedType>(iter);
113 value_ = fromSerialised(serialisedValue);
116 template <
typename TIter>
117 ErrorStatus write(TIter& iter, std::size_t size)
const
119 if (size < length()) {
127 template <
typename TIter>
128 void writeNoStatus(TIter& iter)
const
130 BaseImpl::writeData(toSerialised(value_), iter);
134 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:1504
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.