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

This class represents an empty UID. More...

#include <uids.h>

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

Public Member Functions

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...
 
NONEclone () const
 Create a clone object of the object where this method is being called. More...
 
- Public Member Functions inherited from HF::UID::UID_T
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...
 
- Public Member Functions inherited from HF::Common::Serializable
virtual ~Serializable ()
 Destructor.
 

Additional Inherited Members

- Static Public Attributes inherited from HF::UID::UID_T
static constexpr uint16_t min_size
 Minimum pack/unpack required data size.
 

Detailed Description

This class represents an empty UID.

Definition at line 144 of file uids.h.

Member Function Documentation

◆ clone()

NONE* HF::UID::NONE::clone ( ) const
inlinevirtual

Create a clone object of the object where this method is being called.

Returns
a new object that is a clone of this object.

Implements HF::Common::Cloneable< UID_T >.

Definition at line 178 of file uids.h.

179  {
180  return new NONE(*this);
181  }

◆ pack()

uint16_t HF::UID::NONE::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.

Reimplemented from HF::UID::UID_T.

Definition at line 146 of file uids.h.

References HF_SERIALIZABLE_CHECK, HF::UID::UID_T::min_size, HF::UID::UID_T::pack(), and HF::Common::ByteArray::write().

147  {
148  HF_SERIALIZABLE_CHECK(array, offset, min_size);
149 
150  offset += UID_T::pack(array, offset);
151 
152  array.write(offset, (uint8_t) 0);
153 
154  return min_size;
155  }
#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...
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.
Definition: uids.h:104
static constexpr uint16_t min_size
Minimum pack/unpack required data size.
Definition: uids.h:94
+ Here is the call graph for this function:

◆ unpack()

uint16_t HF::UID::NONE::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.

Reimplemented from HF::UID::UID_T.

Definition at line 157 of file uids.h.

References HF_SERIALIZABLE_CHECK, HF::UID::UID_T::min_size, HF::Common::ByteArray::read(), HF::UID::UID_T::size(), and HF::UID::UID_T::unpack().

158  {
159  HF_SERIALIZABLE_CHECK(array, offset, min_size);
160 
161  uint16_t res = UID_T::unpack(array, offset);
162 
163  if (res == 0)
164  {
165  return 0;
166  }
167 
168  offset += res;
169 
170  uint8_t size;
171  array.read(offset, size);
172 
173  assert(size == 0);
174 
175  return min_size;
176  }
uint16_t unpack(const Common::ByteArray &array, uint16_t offset=0)
Read a message from a ByteArray.
Definition: uids.h:114
#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...
uint16_t size() const
Number bytes needed to serialize the message.
Definition: uids.h:98
static constexpr uint16_t min_size
Minimum pack/unpack required data size.
Definition: uids.h:94
+ Here is the call graph for this function:

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