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

This class the response for a GroupTable::READ_ENTRIES_CMD command. More...

#include <group_table.h>

+ Inheritance diagram for HF::Core::GroupTable::ReadEntriesResponse:
+ Collaboration diagram for HF::Core::GroupTable::ReadEntriesResponse:

Public Member Functions

 ReadEntriesResponse (Common::Result _code=Common::Result::OK, uint8_t _start=0, uint8_t _count=0)
 Constructor. 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::Protocol::Response
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...
 

Data Fields

uint8_t start
 Offset to start reading entries from. More...
 
std::vector< Entryentries
 Vector containing the entries in the response. More...
 

Static Public Attributes

static constexpr uint16_t min_size
 Minimum required data size for pack/unpack.
 
- Static Public Attributes inherited from HF::Protocol::Response
static constexpr uint16_t min_size = sizeof(uint8_t)
 Minimum number of bytes required by this message.
 

Detailed Description

This class the response for a GroupTable::READ_ENTRIES_CMD command.

Definition at line 270 of file group_table.h.

Constructor & Destructor Documentation

◆ ReadEntriesResponse()

HF::Core::GroupTable::ReadEntriesResponse::ReadEntriesResponse ( Common::Result  _code = Common::Result::OK,
uint8_t  _start = 0,
uint8_t  _count = 0 
)
inline

Constructor.

Parameters
[in]_codethe response code for the response.
[in]_startthe offset for the entries in the response.
[in]_countnumber of entries this response will contain.

Definition at line 283 of file group_table.h.

References entries.

284  :
285  Protocol::Response(_code), start(_start)
286  {
287  entries.reserve(_count);
288  }
std::vector< Entry > entries
Vector containing the entries in the response.
Definition: group_table.h:274
uint8_t start
Offset to start reading entries from.
Definition: group_table.h:272

Member Function Documentation

◆ pack()

uint16_t HF::Core::GroupTable::ReadEntriesResponse::pack ( Common::ByteArray array,
uint16_t  offset = 0 
) const
inline

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.

Definition at line 315 of file group_table.h.

References entries, HF_SERIALIZABLE_CHECK, HF::Protocol::Response::pack(), size(), start, and HF::Common::ByteArray::write().

316  {
317  HF_SERIALIZABLE_CHECK(array, offset, size());
318 
319  uint16_t _start = offset;
320 
321  offset += Protocol::Response::pack(array, offset);
322 
323  offset += array.write(offset, start);
324  offset += array.write(offset, (uint8_t) entries.size());
325 
326  std::for_each(entries.begin(), entries.end(),
327  [&array, &offset](const Entry &entry)
328  {
329  offset += entry.pack(array, offset);
330  });
331 
332  return offset - _start;
333  }
Scheduling::Entry< Interval > Entry
Specific part for the Event Scheduler of the HF::Scheduling::Entry.
uint16_t size() const
Number bytes needed to serialize the message.
Definition: group_table.h:300
std::vector< Entry > entries
Vector containing the entries in the response.
Definition: group_table.h:274
#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.
uint8_t start
Offset to start reading entries from.
Definition: group_table.h:272
+ Here is the call graph for this function:

◆ size()

uint16_t HF::Core::GroupTable::ReadEntriesResponse::size ( ) const
inline

Number bytes needed to serialize the message.

Returns
number of bytes the message requires to be serialized.

Definition at line 300 of file group_table.h.

References entries, and HF::Protocol::Response::size().

Referenced by pack().

301  {
302  uint16_t res = Protocol::Response::size()
303  + sizeof(uint8_t)
304  + sizeof(uint8_t);
305 
306  std::for_each(entries.begin(), entries.end(), [&res](const Entry &entry)
307  {
308  res += entry.size();
309  });
310 
311  return res;
312  }
Scheduling::Entry< Interval > Entry
Specific part for the Event Scheduler of the HF::Scheduling::Entry.
std::vector< Entry > entries
Vector containing the entries in the response.
Definition: group_table.h:274
uint16_t size() const
Number bytes needed to serialize the message.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unpack()

uint16_t HF::Core::GroupTable::ReadEntriesResponse::unpack ( const Common::ByteArray array,
uint16_t  offset = 0 
)
inline

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.

Definition at line 336 of file group_table.h.

References entries, HF_SERIALIZABLE_CHECK, HF::Core::GroupTable::Entry::min_size, min_size, HF::Common::ByteArray::read(), start, HF::Core::GroupTable::Entry::unpack(), and HF::Protocol::Response::unpack().

337  {
338  HF_SERIALIZABLE_CHECK(array, offset, min_size);
339 
340  uint16_t _start = offset;
341 
342  offset += Protocol::Response::unpack(array, offset);
343 
344  offset += array.read(offset, start);
345 
346  uint8_t count = 0;
347  offset += array.read(offset, count);
348 
349  HF_SERIALIZABLE_CHECK(array, offset, count * Entry::min_size);
350 
351  entries.reserve(count * Entry::min_size);
352 
353  for (int i = 0; i < count; ++i)
354  {
355  Entry entry;
356  offset += entry.unpack(array, offset);
357  entries.push_back(entry);
358  }
359 
360  return offset - _start;
361  }
Scheduling::Entry< Interval > Entry
Specific part for the Event Scheduler of the HF::Scheduling::Entry.
static constexpr uint16_t min_size
Minimum pack/unpack required data size.
Definition: group_table.h:94
std::vector< Entry > entries
Vector containing the entries in the response.
Definition: group_table.h:274
#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 required data size for pack/unpack.
Definition: group_table.h:295
uint8_t start
Offset to start reading entries from.
Definition: group_table.h:272
uint16_t unpack(const Common::ByteArray &array, uint16_t offset=0)
Read a message from a ByteArray.
+ Here is the call graph for this function:

Field Documentation

◆ entries

std::vector<Entry> HF::Core::GroupTable::ReadEntriesResponse::entries

Vector containing the entries in the response.

Definition at line 274 of file group_table.h.

Referenced by pack(), ReadEntriesResponse(), size(), and unpack().

◆ start

uint8_t HF::Core::GroupTable::ReadEntriesResponse::start

Offset to start reading entries from.

Definition at line 272 of file group_table.h.

Referenced by pack(), and unpack().


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