template<typename TFieldBase, typename T, typename... TOptions>
class comms::field::IntValue< TFieldBase, T, TOptions >
Field that represent integral value.
- Template Parameters
-
TFieldBase | Base class for this field, expected to be a variant of comms::Field. |
T | Basic underlying integral type. |
TOptions | Zero or more options that modify/refine default behaviour of the field. If no option is provided The field's value is serialised as is.
Base class to all the field classes. Definition Field.h:33
Field that represent integral value. Definition IntValue.h:72
In the example above it will consume 2 bytes (because sizeof(std::uint16_t) == 2) and will be serialised using big endian notation.
Supported options are:
|
|
using | CommsTag = typename BaseImpl::CommsTag |
| Tag indicating type of the field.
|
|
using | Endian = typename BaseImpl::Endian |
| Endian used for serialisation.
|
|
using | FieldBase = TFieldBase |
| Base class provided in the first template parameter.
|
|
using | FieldType = typename ParsedOptions::FieldType |
| Type of actual extending field specified via comms::option::def::FieldType.
|
|
using | ParsedOptions = details::OptionsParser< TOptions... > |
| All the options provided to this class bundled into struct.
|
|
using | ScalingRatio = typename ParsedOptions::ScalingRatio |
| Scaling ratio defined by the comms::option::def::ScalingRatio option.
|
|
using | UnitsRatio = typename ParsedOptions::UnitsRatio |
| Scaling ratio determined by the forced units via the comms::option::def::Units* option.
|
|
using | UnitsType = typename ParsedOptions::UnitsType |
| Units type defined by any of the comms::option::def::Units* option.
|
|
using | ValueType = typename BaseImpl::ValueType |
| Type of underlying integral value.
|
|
using | VersionType = typename BaseImpl::VersionType |
| Version type.
|
|
|
| IntValue ()=default |
| Default constructor.
|
|
| IntValue (const IntValue &)=default |
| Copy constructor.
|
|
| IntValue (const ValueType &val) |
| Constructor.
|
|
| ~IntValue () noexcept=default |
| Destructor.
|
|
bool | canWrite () const |
| Check of whether the field has a consistent value for writing.
|
|
int | getForcedLength () const |
| Get forced serialization length.
|
|
template<typename TRet > |
constexpr TRet | getScaled () const |
| Scales value according to ratio specified in provided comms::option::def::ScalingRatio option.
|
|
const ValueType & | getValue () const |
| Get value.
|
|
VersionType | getVersion () const |
| Get version of the field.
|
|
constexpr std::size_t | length () const |
| Get length required to serialise the current field value.
|
|
IntValue & | operator= (const IntValue &)=default |
| Copy assignment.
|
|
template<typename TIter > |
ErrorStatus | read (TIter &iter, std::size_t size) |
| Read field value from input data sequence.
|
|
template<typename TIter > |
void | readNoStatus (TIter &iter) |
| Read field value from input data sequence without error check and status report.
|
|
bool | refresh () |
| Refresh the field's value.
|
|
template<typename TRet > |
constexpr TRet | scaleAs () const |
| Same as getScaled()
|
|
void | setForcedLength (int len) |
| Force serialization length of the field.
|
|
template<typename TScaled > |
void | setScaled (TScaled val) |
| Opposite operation to getScaled().
|
|
template<typename U > |
void | setValue (U &&val) |
| Set value.
|
|
bool | setVersion (VersionType version) |
| Default implementation of version update.
|
|
bool | valid () const |
| Check validity of the field value.
|
|
ValueType & | value () |
| Get access to integral value storage.
|
|
const ValueType & | value () const |
| Get access to integral value storage.
|
|
template<typename TIter > |
ErrorStatus | write (TIter &iter, std::size_t size) const |
| Write current field value to output data sequence.
|
|
template<typename TIter > |
void | writeNoStatus (TIter &iter) const |
| Write current field value to output data sequence without error check and status report.
|
|
|
static constexpr bool | canWrite () |
| Default check of whether the field has a consistent value for writing.
|
|
static constexpr bool | hasEmptySerialization () |
| Compile time inquiry of whether comms::option::def::EmptySerialization option has been used.
|
|
static constexpr bool | hasFailOnInvalid () |
| Compile time inquiry of whether comms::option::def::FailOnInvalid option has been used.
|
|
static constexpr bool | hasFieldType () |
| Compile time inquiry of whether comms::option::def::FieldType option has been used.
|
|
static constexpr bool | hasIgnoreInvalid () |
| Compile time inquiry of whether comms::option::def::IgnoreInvalid option has been used.
|
|
static constexpr bool | hasNonDefaultRefresh () |
| Compile time check if this class has non-default refresh functionality.
|
|
static constexpr bool | hasReadNoStatus () |
| Compile time check of whether the field has proper readNoStatus() member function.
|
|
static constexpr bool | hasScaling () |
| Compile time inquiry of whether scaling ratio has been provided via comms::option::def::ScalingRatio option.
|
|
static constexpr bool | hasUnits () |
| Compile time inquiry of whether units have been set via any of the comms::option::def::Units* options.
|
|
static constexpr bool | hasVarLength () |
| Compile time inquiry of whether comms::option::def::VarLength option has been used.
|
|
static constexpr bool | hasWriteNoStatus () |
| Compile time check of whether the field has proper writeNoStatus() member function.
|
|
static constexpr bool | isVersionDependent () |
| Compile time check if this class is version dependent.
|
|
static constexpr std::size_t | maxLength () |
| Get maximal length that is required to serialise field of this type.
|
|
static constexpr ValueType | maxValue () |
| Get maximal numeric value the field can hold.
|
|
static constexpr std::size_t | minLength () |
| Get minimal length that is required to serialise field of this type.
|
|
static constexpr ValueType | minValue () |
| Get minimal numeric value the field can hold.
|
|
static constexpr bool | valid () |
| Default validity check.
|
|
|
template<typename T , typename TIter > |
static T | readData (TIter &iter) |
| Read data from input buffer.
|
|
template<typename T , std::size_t TSize, typename TIter > |
static T | readData (TIter &iter) |
| Read partial data from input buffer.
|
|
template<typename T , typename TIter > |
static void | writeData (T value, TIter &iter) |
| Write data into the output buffer.
|
|
template<std::size_t TSize, typename T , typename TIter > |
static void | writeData (T value, TIter &iter) |
| Write partial data into the output buffer.
|
|
|
(Note that these are not member symbols.)
|
template<typename T > |
constexpr bool | isIntValue () |
| Compile time check function of whether a provided type is any variant of comms::field::IntValue.
|
|
template<typename TFieldBase , typename T , typename... TOptions> |
bool | operator!= (const IntValue< TFieldBase, T, TOptions... > &field1, const IntValue< TFieldBase, T, TOptions... > &field2) noexcept |
| Non-equality comparison operator.
|
|
template<typename TFieldBase , typename T , typename... TOptions> |
bool | operator< (const IntValue< TFieldBase, T, TOptions... > &field1, const IntValue< TFieldBase, T, TOptions... > &field2) noexcept |
| Equivalence comparison operator.
|
|
template<typename TFieldBase , typename T , typename... TOptions> |
bool | operator== (const IntValue< TFieldBase, T, TOptions... > &field1, const IntValue< TFieldBase, T, TOptions... > &field2) noexcept |
| Equality comparison operator.
|
|
template<typename TFieldBase , typename T , typename... TOptions> |
const IntValue< TFieldBase, T, TOptions... > & | toFieldBase (const IntValue< TFieldBase, T, TOptions... > &field) |
| Upcast type of the field definition to its parent comms::field::IntValue type in order to have access to its internal types.
|
|
template<typename TFieldBase , typename T , typename... TOptions> |
IntValue< TFieldBase, T, TOptions... > & | toFieldBase (IntValue< TFieldBase, T, TOptions... > &field) |
| Upcast type of the field definition to its parent comms::field::IntValue type in order to have access to its internal types.
|
|
template<typename... TOptions>
template<typename T , typename TIter >
Read data from input buffer.
Use this function to read data from the intput buffer maintained by the caller. The endianness of the data will be as specified in options of the class.
- Template Parameters
-
T | Return type |
TIter | Type of input iterator |
- Parameters
-
[in,out] | iter | Input iterator. |
- Returns
- The integral type value.
- Precondition
- TSize <= sizeof(T)
-
The iterator must be valid and can be successfully dereferenced and incremented at least sizeof(T) times.
- Postcondition
- The iterator is advanced.
- Note
- Thread safety: Safe for distinct stream buffers, unsafe otherwise.
template<typename... TOptions>
template<typename T , std::size_t TSize, typename TIter >
Read partial data from input buffer.
Use this function to read data from the intput buffer maintained by the caller. The endianness of the data will be as specified in options of the class.
- Template Parameters
-
T | Return type |
TSize | number of bytes to read |
TIter | Type of input iterator |
- Parameters
-
[in,out] | iter | Input iterator. |
- Returns
- The integral type value.
- Precondition
- TSize <= sizeof(T)
-
The iterator must be valid and can be successfully dereferenced and incremented at least TSize times.
- Postcondition
- The internal pointer of the stream buffer is advanced.
- Note
- Thread safety: Safe for distinct stream buffers, unsafe otherwise.
template<typename TFieldBase , typename T , typename... TOptions>
template<typename TIter >
Read field value from input data sequence without error check and status report.
Similar to read(), but doesn't perform any correctness checks and doesn't report any failures.
- Parameters
-
[in,out] | iter | Iterator to read the data. |
- Postcondition
- Iterator is advanced.
template<typename TFieldBase , typename T , typename... TOptions>
template<typename TScaled >
Opposite operation to getScaled().
Allows to assign scaled value, assigns "(val * Scaling_Denom) / Scaling_Num" to the value of the field.
- Parameters
-
template<typename... TOptions>
template<typename T , typename TIter >
static void comms::Field< TOptions >::writeData |
( |
T |
value, |
|
|
TIter & |
iter |
|
) |
| |
|
staticprotectedinherited |
Write data into the output buffer.
Use this function to write data to the the buffer maintained by the caller. The endianness of the data will be as specified in the options provided to the class.
- Template Parameters
-
T | Type of the value to write. Must be integral. |
Type | of output iterator |
- Parameters
-
[in] | value | Integral type value to be written. |
[in,out] | iter | Output iterator. |
- Precondition
- The iterator must be valid and can be successfully dereferenced and incremented at least sizeof(T) times.
- Postcondition
- The iterator is advanced.
- Note
- Thread safety: Safe for distinct buffers, unsafe otherwise.
template<typename... TOptions>
template<std::size_t TSize, typename T , typename TIter >
static void comms::Field< TOptions >::writeData |
( |
T |
value, |
|
|
TIter & |
iter |
|
) |
| |
|
staticprotectedinherited |
Write partial data into the output buffer.
Use this function to write partial data to the buffer maintained by the caller. The endianness of the data will be as specified the class options.
- Template Parameters
-
TSize | Length of the value in bytes known in compile time. |
T | Type of the value to write. Must be integral. |
TIter | Type of output iterator |
- Parameters
-
[in] | value | Integral type value to be written. |
[in,out] | iter | Output iterator. |
- Precondition
- TSize <= sizeof(T)
-
The iterator must be valid and can be successfully dereferenced and incremented at least TSize times.
- Postcondition
- The iterator is advanced.
- Note
- Thread safety: Safe for distinct buffers, unsafe otherwise.
template<typename TFieldBase , typename T , typename... TOptions>
template<typename TIter >
Write current field value to output data sequence without error check and status report.
Similar to write(), but doesn't perform any correctness checks and doesn't report any failures.
- Parameters
-
[in,out] | iter | Iterator to write the data. |
- Postcondition
- Iterator is advanced.