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

This class represents a group of devices. More...

#include <group_management.h>

+ Inheritance diagram for HF::Core::GroupManagement::Group:
+ Collaboration diagram for HF::Core::GroupManagement::Group:

Public Member Functions

 Group (uint16_t address=0, std::string name="")
 Constructor. More...
 
const Container & members () const
 Return a reference to the members of the group. More...
 
Container::iterator find_member (const Member &member)
 Find a group member equal to the given member. More...
 
Container::iterator find_member (uint16_t device, uint8_t unit)
 Find a group member equal to the given member. More...
 
bool exists (const Member &member)
 Check if a member equal to the given member already exists in the group. More...
 
bool exists (uint16_t device, uint8_t unit)
 Check if a member equal to the given member already exists in the group. More...
 
bool add (const Member &member)
 Add the given member to the group. More...
 
bool add (uint16_t device, uint8_t unit)
 Add the given member to the group. More...
 
bool reserve ()
 Reserve a member in group members entries. More...
 
bool update (const Member &member)
 Update a reserved entry with the given member. More...
 
bool update (uint16_t device, uint8_t unit)
 Update a reserved entry with the given member. More...
 
bool remove (const Member &member)
 Remove the given member from the entries of the group. More...
 
bool remove (uint16_t device, uint8_t unit)
 Remove the given member from the entries of the group. More...
 
bool operator== (const Group &other) const
 Equals operator.
 
bool operator!= (const Group &other) const
 Not equals operator.
 
- Public Member Functions inherited from HF::Core::GroupManagement::GroupAddress
 GroupAddress (uint16_t address=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...
 

Data Fields

std::string name
 Group Name
 
- Data Fields inherited from HF::Core::GroupManagement::GroupAddress
uint16_t address
 Group Address
 

Protected Attributes

Container _members
 Group Members
 

Additional Inherited Members

- Static Public Attributes inherited from HF::Core::GroupManagement::GroupAddress
static constexpr uint16_t NO_ADDR = 0x0000
 Empty Group Address. More...
 
static constexpr uint16_t START_ADDR = 0x0001
 First HAN-FUN Group Address. More...
 
static constexpr uint16_t END_ADDR = 0x7FFF
 Last HAN-FUN Group Address. More...
 
static constexpr uint16_t min_size = sizeof(uint16_t)
 Minimum pack/unpack required data size.
 

Detailed Description

This class represents a group of devices.

Definition at line 145 of file group_management.h.

Constructor & Destructor Documentation

◆ Group()

HF::Core::GroupManagement::Group::Group ( uint16_t  address = 0,
std::string  name = "" 
)
inline

Constructor.

Parameters
[in]addressthe group's address.
[in]namethe group's name.

Definition at line 166 of file group_management.h.

166  :
168  {}
GroupAddress(uint16_t address=0)
Constructor.

Member Function Documentation

◆ add() [1/2]

bool HF::Core::GroupManagement::Group::add ( const Member member)

Add the given member to the group.

Parameters
[in]memberreference to a member to add to the group.
Return values
trueif the member was added;
falseotherwise.

Referenced by add().

+ Here is the caller graph for this function:

◆ add() [2/2]

bool HF::Core::GroupManagement::Group::add ( uint16_t  device,
uint8_t  unit 
)
inline

Add the given member to the group.

Parameters
[in]devicedevice address for the new member to add.
[in]unitunit ID for the new member to add.
Return values
trueif the member was added;
falseotherwise.

Definition at line 259 of file group_management.h.

References add().

260  {
261  const Member member(device, unit);
262 
263  return add(member);
264  }
bool add(const Member &member)
Add the given member to the group.
Protocol::Address Member
This class represents a member of a group.
+ Here is the call graph for this function:

◆ exists() [1/2]

bool HF::Core::GroupManagement::Group::exists ( const Member member)
inline

Check if a member equal to the given member already exists in the group.

Parameters
[in]memberreference to the member to check presence of.
Return values
trueif the member is already present in the group;
falseotherwise.

Definition at line 219 of file group_management.h.

References find_member(), and members().

220  {
221  return !(find_member(member) == members().end());
222  }
Container::iterator find_member(const Member &member)
Find a group member equal to the given member.
const Container & members() const
Return a reference to the members of the group.
+ Here is the call graph for this function:

◆ exists() [2/2]

bool HF::Core::GroupManagement::Group::exists ( uint16_t  device,
uint8_t  unit 
)
inline

Check if a member equal to the given member already exists in the group.

Parameters
[in]devicedevice address to check the existence for.
[in]unitunit ID to check the existence for.
Return values
trueif the member is already present in the group;
falseotherwise.

Definition at line 233 of file group_management.h.

References find_member(), and members().

234  {
235  const Member member(device, unit);
236 
237  return !(find_member(member) == members().end());
238  }
Container::iterator find_member(const Member &member)
Find a group member equal to the given member.
const Container & members() const
Return a reference to the members of the group.
Protocol::Address Member
This class represents a member of a group.
+ Here is the call graph for this function:

◆ find_member() [1/2]

Container::iterator HF::Core::GroupManagement::Group::find_member ( const Member member)

Find a group member equal to the given member.

Parameters
[in]memberreference to a Member instance to look for.
Return values
iteratorto the element in the Container if exists,
Container::end()otherwise.

Referenced by exists(), and find_member().

+ Here is the caller graph for this function:

◆ find_member() [2/2]

Container::iterator HF::Core::GroupManagement::Group::find_member ( uint16_t  device,
uint8_t  unit 
)
inline

Find a group member equal to the given member.

Parameters
[in]devicedevice address for the member to look for.
[in]unitunit ID for the member to look for.
Return values
iteratorto the element in the Container if exists,
Container::end()otherwise.

Definition at line 203 of file group_management.h.

References find_member().

204  {
205  const Member member(device, unit);
206 
207  return find_member(member);
208  }
Container::iterator find_member(const Member &member)
Find a group member equal to the given member.
Protocol::Address Member
This class represents a member of a group.
+ Here is the call graph for this function:

◆ members()

const Container& HF::Core::GroupManagement::Group::members ( ) const
inline

Return a reference to the members of the group.

Returns
reference to the members of the group.

Definition at line 179 of file group_management.h.

References _members.

Referenced by exists(), and reserve().

180  {
181  return _members;
182  }
Container _members
Group Members
+ Here is the caller graph for this function:

◆ remove() [1/2]

bool HF::Core::GroupManagement::Group::remove ( const Member member)

Remove the given member from the entries of the group.

Parameters
[in]memberreference to the member to remove from the group.
Return values
trueif the entry was removed;
falseotherwise.

◆ remove() [2/2]

bool HF::Core::GroupManagement::Group::remove ( uint16_t  device,
uint8_t  unit 
)
inline

Remove the given member from the entries of the group.

Parameters
devicedevice address of the member to remove.
unitunit ID of the member to remove.
Return values
trueif the entry was removed;
falseotherwise.

Definition at line 324 of file group_management.h.

325  {
326  const Member member(device, unit);
327 
328  return remove(member);
329  }
Protocol::Address Member
This class represents a member of a group.

◆ reserve()

bool HF::Core::GroupManagement::Group::reserve ( )
inline

Reserve a member in group members entries.

Return values
trueif the entry was reserved;
falseotherwise.

Definition at line 272 of file group_management.h.

References _members, HF_ASSERT, members(), and HF::Core::GroupManagement::GroupAddress::size().

273  {
274  HF_ASSERT(members().size() < MAX_MEMBERS, {return false;});
275  _members.push_back(Member());
276  return true;
277  }
#define HF_ASSERT(_expr, _block)
Helper macro to check for correct assumptions.
const Container & members() const
Return a reference to the members of the group.
uint16_t size() const
Number bytes needed to serialize the message.
Container _members
Group Members
Protocol::Address Member
This class represents a member of a group.
+ Here is the call graph for this function:

◆ update() [1/2]

bool HF::Core::GroupManagement::Group::update ( const Member member)

Update a reserved entry with the given member.

Parameters
[in]memberreference to the member to update the reserved entry to.
Return values
trueif the entry was updated;
falseotherwise.

Referenced by update().

+ Here is the caller graph for this function:

◆ update() [2/2]

bool HF::Core::GroupManagement::Group::update ( uint16_t  device,
uint8_t  unit 
)
inline

Update a reserved entry with the given member.

Parameters
devicedevice address to update the reserved entry with.
unitunit ID to update the reserved entry with.
Return values
trueif the entry was updated;
falseotherwise.

Definition at line 298 of file group_management.h.

References update().

299  {
300  const Member member(device, unit);
301 
302  return update(member);
303  }
bool update(const Member &member)
Update a reserved entry with the given member.
Protocol::Address Member
This class represents a member of a group.
+ Here is the call graph for this function:

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