COMMS
Template library intended to help with implementation of communication protocols.
Public Types | Static Public Member Functions | Static Protected Member Functions | List of all members
comms::Field< TOptions > Class Template Reference

#include "comms/Field.h"

Detailed Description

template<typename... TOptions>
class comms::Field< TOptions >

Base class to all the field classes.

Every custom "field" class should inherit from this one.

Template Parameters
TOptionsZero or more options. The supported options are:
Inheritance diagram for comms::Field< TOptions >:
comms::field::IntValue< TFieldBase, IntValueType, TOptions... > comms::field::ArrayList< TFieldBase, TElement, TOptions > comms::field::Bitfield< TFieldBase, TMembers, TOptions > comms::field::BitmaskValue< TFieldBase, TOptions > comms::field::Bundle< TFieldBase, TMembers, TOptions > comms::field::EnumValue< TFieldBase, TEnum, TOptions > comms::field::FloatValue< TFieldBase, T, TOptions > comms::field::IntValue< TFieldBase, T, TOptions > comms::field::Optional< TField, TOptions > comms::field::String< TFieldBase, TOptions > comms::field::Variant< TFieldBase, TMembers, TOptions >

Public Types

using Endian = typename BaseImpl::Endian
 Endian type. More...
 
using VersionType = typename BaseImpl::VersionType
 Version type.
 

Static Public Member Functions

static constexpr bool canWrite ()
 Default check of whether the field has a consistent value for writing. More...
 
static constexpr bool hasNonDefaultRefresh ()
 Default check of whether the field has defines refresh functionality. More...
 
static constexpr bool hasReadNoStatus ()
 Default check of whether the field has readNoStatus() member function. More...
 
static constexpr bool hasVarLength ()
 Default check of whether the field has variable length definition via comms::option::def::VarLength option. More...
 
static constexpr bool hasWriteNoStatus ()
 Default check of whether the field has writeNoStatus() member function. More...
 
static constexpr bool isVersionDependent ()
 Default check of whether the field is version dependent. More...
 
static constexpr bool refresh ()
 Default refresh functionality. More...
 
static constexpr bool setVersion (VersionType)
 Default version update functionality. More...
 
static constexpr bool valid ()
 Default validity check. More...
 

Static Protected Member Functions

template<typename T , typename TIter >
static T readData (TIter &iter)
 Read data from input buffer. More...
 
template<typename T , std::size_t TSize, typename TIter >
static T readData (TIter &iter)
 Read partial data from input buffer. More...
 
template<typename T , typename TIter >
static void writeData (T value, TIter &iter)
 Write data into the output buffer. More...
 
template<std::size_t TSize, typename T , typename TIter >
static void writeData (T value, TIter &iter)
 Write partial data into the output buffer. More...
 

Member Typedef Documentation

◆ Endian

template<typename... TOptions>
using comms::Field< TOptions >::Endian = typename BaseImpl::Endian

Member Function Documentation

◆ canWrite()

template<typename... TOptions>
static constexpr bool comms::Field< TOptions >::canWrite ( )
staticconstexpr

Default check of whether the field has a consistent value for writing.

Returns
Always true.

◆ hasNonDefaultRefresh()

template<typename... TOptions>
static constexpr bool comms::Field< TOptions >::hasNonDefaultRefresh ( )
staticconstexpr

Default check of whether the field has defines refresh functionality.

Returns
Always false.

◆ hasReadNoStatus()

template<typename... TOptions>
static constexpr bool comms::Field< TOptions >::hasReadNoStatus ( )
staticconstexpr

Default check of whether the field has readNoStatus() member function.

Returns
Always true.

◆ hasVarLength()

template<typename... TOptions>
static constexpr bool comms::Field< TOptions >::hasVarLength ( )
staticconstexpr

Default check of whether the field has variable length definition via comms::option::def::VarLength option.

Returns
Always false.

◆ hasWriteNoStatus()

template<typename... TOptions>
static constexpr bool comms::Field< TOptions >::hasWriteNoStatus ( )
staticconstexpr

Default check of whether the field has writeNoStatus() member function.

Returns
Always true.

◆ isVersionDependent()

template<typename... TOptions>
static constexpr bool comms::Field< TOptions >::isVersionDependent ( )
staticconstexpr

Default check of whether the field is version dependent.

Returns
Always false.

◆ readData() [1/2]

template<typename... TOptions>
template<typename T , typename TIter >
static T comms::Field< TOptions >::readData ( TIter &  iter)
staticprotected

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
TReturn type
TIterType of input iterator
Parameters
[in,out]iterInput 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.

◆ readData() [2/2]

template<typename... TOptions>
template<typename T , std::size_t TSize, typename TIter >
static T comms::Field< TOptions >::readData ( TIter &  iter)
staticprotected

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
TReturn type
TSizenumber of bytes to read
TIterType of input iterator
Parameters
[in,out]iterInput 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.

◆ refresh()

template<typename... TOptions>
static constexpr bool comms::Field< TOptions >::refresh ( )
staticconstexpr

Default refresh functionality.

Does nothing and returns false, can be overriden by the derived class

Returns
Always false

◆ setVersion()

template<typename... TOptions>
static constexpr bool comms::Field< TOptions >::setVersion ( VersionType  )
staticconstexpr

Default version update functionality.

Does nothing and returns false, can be overriden by the derived class

Returns
Always false

◆ valid()

template<typename... TOptions>
static constexpr bool comms::Field< TOptions >::valid ( )
staticconstexpr

Default validity check.

Always returns true, can be overriden by the derived class

Returns
Always true

◆ writeData() [1/2]

template<typename... TOptions>
template<typename T , typename TIter >
static void comms::Field< TOptions >::writeData ( value,
TIter &  iter 
)
staticprotected

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
TType of the value to write. Must be integral.
Typeof output iterator
Parameters
[in]valueIntegral type value to be written.
[in,out]iterOutput 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.

◆ writeData() [2/2]

template<typename... TOptions>
template<std::size_t TSize, typename T , typename TIter >
static void comms::Field< TOptions >::writeData ( value,
TIter &  iter 
)
staticprotected

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
TSizeLength of the value in bytes known in compile time.
TType of the value to write. Must be integral.
TIterType of output iterator
Parameters
[in]valueIntegral type value to be written.
[in,out]iterOutput 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.

The documentation for this class was generated from the following file: