HAN-FUN API  1.5.3
This project provides the common implementation of ULE Alliance's HAN-FUN application protocol.
HF::UID::UID_T Struct Referenceabstract

API for all UIDs. More...

#include <uids.h>

+ Inheritance diagram for HF::UID::UID_T:
+ Collaboration diagram for HF::UID::UID_T:

Public Member Functions

virtual uint8_t type () const =0
 Type of the UID. More...
 
virtual int compare (const UID_T &other) const
 Compare the current UID with the given UID. More...
 
uint16_t size () const
 Number bytes needed to serialize the message. More...
 
uint16_t pack (Common::ByteArray &array, uint16_t offset=0) const
 Write the object on to a ByteArray so it can be sent over the network. More...
 
uint16_t unpack (const Common::ByteArray &array, uint16_t offset=0)
 Read a message from a ByteArray. More...
 
- Public Member Functions inherited from HF::Common::Serializable
virtual ~Serializable ()
 Destructor.
 
- Public Member Functions inherited from HF::Common::Cloneable< UID_T >
virtual UID_T * clone () const=0
 Create a clone object of the object where this method is being called. More...
 

Static Public Attributes

static constexpr uint16_t min_size
 Minimum pack/unpack required data size.
 

Detailed Description

API for all UIDs.

Parent UID class.

Definition at line 55 of file uids.h.

Member Function Documentation

◆ compare()

virtual int HF::UID::UID_T::compare ( const UID_T other) const
inlinevirtual

Compare the current UID with the given UID.

This function returns a value less that 0 if the current UID object order is lower that the given UID, 0 if the UIDs represent the same entity and a value greater that 0 if current UID object is above the given UID.

Parameters
[in]othera pointer to a UID object to compare to.
Return values
<0the current UID is lower that the given UID.
0the current UID is the same as given UID.
>0the current UID is greater that the given UID.

Reimplemented in HF::UID::URI, HF::UID::ByteArray< _Class, _size, _type >, HF::UID::ByteArray< DECT, 5, DECT_UID >, and HF::UID::ByteArray< MAC, 6, MAC_UID >.

Definition at line 88 of file uids.h.

References type().

Referenced by HF::UID::ByteArray< MAC, 6, MAC_UID >::compare(), HF::UID::URI::compare(), and HF::UID::UID::compare().

89  {
90  return (this->type() - other.type());
91  }
virtual uint8_t type() const =0
Type of the UID.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pack()

uint16_t HF::UID::UID_T::pack ( Common::ByteArray array,
uint16_t  offset = 0 
) const
inlinevirtual

Write the object on to a ByteArray so it can be sent over the network.

The buffer passed in MUST have enough size to hold the serialized object, e.g.,

Serializable obj;
ByteArray payload(obj.size());
obj.pack(payload);
Parameters
[in,out]arrayByteArray reference to write the object to.
[in]offsetoffset to start writing to.
Returns
the number of bytes written.

Implements HF::Common::Serializable.

Reimplemented in HF::UID::URI, HF::UID::ByteArray< _Class, _size, _type >, HF::UID::ByteArray< DECT, 5, DECT_UID >, HF::UID::ByteArray< MAC, 6, MAC_UID >, and HF::UID::NONE.

Definition at line 104 of file uids.h.

References HF_SERIALIZABLE_CHECK, min_size, type(), and HF::Common::ByteArray::write().

Referenced by HF::UID::NONE::pack(), HF::UID::ByteArray< MAC, 6, MAC_UID >::pack(), HF::UID::URI::pack(), and HF::UID::UID::pack().

105  {
106  HF_SERIALIZABLE_CHECK(array, offset, min_size);
107 
108  array.write(offset, this->type());
109 
110  return sizeof(uint8_t);
111  }
virtual uint8_t type() const =0
Type of the UID.
#define HF_SERIALIZABLE_CHECK(__array, __offset, __size)
Helper macro to check if the given __array has enough size so __size bytes can be written/read from t...
static constexpr uint16_t min_size
Minimum pack/unpack required data size.
Definition: uids.h:94
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ size()

uint16_t HF::UID::UID_T::size ( ) const
inlinevirtual

Number bytes needed to serialize the message.

Returns
number of bytes the message requires to be serialized.

Implements HF::Common::Serializable.

Reimplemented in HF::UID::URI, HF::UID::ByteArray< _Class, _size, _type >, HF::UID::ByteArray< DECT, 5, DECT_UID >, and HF::UID::ByteArray< MAC, 6, MAC_UID >.

Definition at line 98 of file uids.h.

References min_size.

Referenced by HF::UID::URI::size(), HF::UID::UID::size(), and HF::UID::NONE::unpack().

99  {
100  return min_size;
101  }
static constexpr uint16_t min_size
Minimum pack/unpack required data size.
Definition: uids.h:94
+ Here is the caller graph for this function:

◆ type()

virtual uint8_t HF::UID::UID_T::type ( ) const
pure virtual

Type of the UID.

See also
HF::UID::Type.
Returns
type of the UID.

Implemented in HF::UID::Abstract< _type >, HF::UID::Abstract< URI_UID >, and HF::UID::Abstract< NONE_UID >.

Referenced by compare(), pack(), HF::UID::UID::type(), and unpack().

+ Here is the caller graph for this function:

◆ unpack()

uint16_t HF::UID::UID_T::unpack ( const Common::ByteArray array,
uint16_t  offset = 0 
)
inlinevirtual

Read a message from a ByteArray.

Parameters
[in]arrayByteArray reference to read the message from.
[in]offsetoffset to start reading from.
Returns
the number of bytes read.

Implements HF::Common::Serializable.

Reimplemented in HF::UID::URI, HF::UID::ByteArray< _Class, _size, _type >, HF::UID::ByteArray< DECT, 5, DECT_UID >, HF::UID::ByteArray< MAC, 6, MAC_UID >, and HF::UID::NONE.

Definition at line 114 of file uids.h.

References HF_SERIALIZABLE_CHECK, min_size, HF::Common::ByteArray::read(), and type().

Referenced by HF::UID::NONE::unpack(), HF::UID::ByteArray< MAC, 6, MAC_UID >::unpack(), and HF::UID::URI::unpack().

115  {
116  HF_SERIALIZABLE_CHECK(array, offset, min_size);
117 
118  uint8_t type;
119  array.read(offset, type);
120 
121  assert((type & (~0x80)) == this->type());
122 
123  return sizeof(uint8_t);
124  }
virtual uint8_t type() const =0
Type of the UID.
#define HF_SERIALIZABLE_CHECK(__array, __offset, __size)
Helper macro to check if the given __array has enough size so __size bytes can be written/read from t...
static constexpr uint16_t min_size
Minimum pack/unpack required data size.
Definition: uids.h:94
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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