17 #ifndef HF_BIND_MANAGEMENT_H 18 #define HF_BIND_MANAGEMENT_H 114 typedef enum _Attributes
162 uint16_t
size()
const;
249 std::function<
void(
const Entry &)> func)
const = 0;
402 using ServiceRole::payload_size;
548 typedef std::set<Entry> Container;
549 typedef Container::iterator iterator;
550 typedef Container::const_iterator const_iterator;
551 typedef Container::value_type value_type;
553 uint16_t
size()
const;
578 std::function<
void(
const Entry &)> func)
const;
590 const_iterator begin()
const 622 template<
typename Func>
627 for (iterator itr =
db.begin(); itr !=
db.end();)
654 template<
typename _Entries = BindManagement::Entries>
727 return AbstractServer::handle_command(packet, payload, offset);
734 typedef Server<> DefaultServer;
740 inline bool operator==(
const Entry &lhs,
const Entry &rhs)
742 return lhs.source == rhs.source && lhs.destination == rhs.destination &&
746 inline bool operator!=(
const Entry &lhs,
const Entry &rhs)
748 return !(lhs == rhs);
751 inline bool operator<(
const Entry &lhs,
const Entry &rhs)
753 return lhs.source < rhs.source || (lhs.source == rhs.source
754 && (lhs.itf < rhs.itf ||
755 (lhs.itf == rhs.itf &&
756 lhs.destination < rhs.destination)));
794 std::ostream &
operator<<(std::ostream &stream,
Container & entries() const
Reference to the persistent storage implementation.
HF::Devices::Concentrator::IUnit0 & unit0() const
Return a reference to the unit that this service belongs to.
SessionMgr & sessions()
Reference to the session management API.
Destination address is for single device.
Remove bind entry command.
virtual Common::Result add(const Protocol::Address &source, const Protocol::Address &destination, const Common::Interface &itf)=0
Create a new bind entry in the database.
This represent the special unit with ID/UID = 0.
Base(HF::Core::Unit0 &unit)
Constructor.
Bind Management interface : Client side.
Helper template to inject session management functionality into services requiring it - Server side...
SessionMgr & session()
Reference to the session management API.
Message message
Packet message payload;.
Common::Result destroy(const Entry &entry)
Destroy the given entry in the persistent storage.
Helper template to inject session management functionality into services requiring it - Client side...
_Entries _entries
Bind entries database.
void end_session() const
End read entries session.
Default implementation of the bind entries container.
Return all mandatory attributes for the interface.
This file contains the common defines for the HAN-FUN library.
Units::IUnit * unit(uint8_t id) const
Return pointer to the unit with the given id.
This file contains the forward declarations of the core services and interfaces implementing classes...
static constexpr uint16_t min_size
Minimum pack/unpack required data size.
virtual IEntries & entries() const =0
Reference to the persistent storage implementation.
Scheduling::Entry< Interval > Entry
Specific part for the Event Scheduler of the HF::Scheduling::Entry.
Container & entries() const
Return the container for the service entries.
void add(const Protocol::Address &source, const Protocol::Address &destination, const Common::Interface &itf)
Send a ADD_BIND command.
void send(Protocol::Packet &packet)
Send given packet into the HAN-FUN network.
This file contains the definitions for the HAN-FUN protocol messages.
Parent class for the Bind Management interface implementation.
void send(const Protocol::Address &addr, Protocol::Message &message)
Send message msg to the network address given by addr.
Protocol::Address source
Source Address.
EntryPtr find(const Protocol::Address &source, const Common::Interface &itf, const Protocol::Address &destination) const
Return the Bind entry for the given parameters.
Parent class for bind management - server role.
virtual void response(const CMD cmd, const Protocol::Response &response)
This method is called when the response to a command is received.
void for_each(Protocol::Address const &source, Common::Interface const &itf, std::function< void(const Entry &)> func) const
Call the given function for all the entries with given source address and for the given interface ifc...
Common::Interface itf
Destination Interface.
Bind Management persistent storage API.
This file contains the definitions common to all interfaces.
End the session for device.
Device Management interface UID.
Unit 0 interface API for HAN-FUN Concentrators.
IServer(Unit0 &unit)
Constructor.
Unit0 & unit() const
The device this unit is associated with.
Helper class used to implement custom functionality to the bind management server side...
Template for HAN-FUN concentrator devices.
virtual void for_each(Protocol::Address const &source, Common::Interface const &itf, std::function< void(const Entry &)> func) const =0
Call the given function for all the entries with given source address and for the given interface ifc...
This class represents a byte array.
void send(const Protocol::Address &addr, Protocol::Message &message)
Send message msg to the network address given by addr.
This file contains the definitions for the session management functionality.
Entry(Protocol::Address _source, Common::Interface _itf)
Constructor.
uint16_t unpack(const Common::ByteArray &array, uint16_t offset=0)
Read a message from a ByteArray.
HF::Attributes::IAttribute * create_attribute(uint8_t uid)
Create an attribute object that can hold the attribute with the given uid. (HF::Core::BindManagement:...
uint8_t member
Interface destination member.
Container db
Container for the bind entries.
std::ostream & operator<<(std::ostream &stream, const HF::Core::BindManagement::CMD command)
Convert the given command into a string and write it to the given stream.
Entry(Protocol::Address _source, Common::Interface _itf, Protocol::Address _destination)
Constructor.
Start Session Read Registration Info.
virtual uint16_t payload_size(Protocol::Message &message) const
Return the minimal payload size that should be present for the given message.
void start_session() const
Start read entries session.
Session Management API : Server side.
virtual bool any_of(Protocol::Address const &source, Common::Interface const &itf) const =0
Check if entries for the device with given source address and for the given interface ifc exist...
static constexpr uint16_t min_size
Minimum pack/unpack required data size.
uint16_t size() const
Number bytes needed to serialize the message.
Bind Management interface : Server side API.
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.
Interface itf
Interface Address.
bool any_of(Protocol::Address const &source, Common::Interface const &itf) const
Check if entries for the device with given source address and for the given interface ifc exist...
Common::Result destroy(Func func)
Destroy the entries in the persistent storage, for which the given predicate function returns true...
virtual SessionManagement::IServer & sessions()=0
Reference to the session management API.
Interface/Service Attribute API.
Client(HF::Core::Unit0 &unit)
Constructor.
virtual EntryPtr find(const Protocol::Address &source, const Common::Interface &itf, const Protocol::Address &destination) const =0
Return the Bind entry for the given parameters.
This represents a bind entry data structure.
Parent class for the response messages.
Common::Result handle_command(CMD cmd, Protocol::Packet &packet, Common::ByteArray &payload, uint16_t offset=0)
Handle command request/response messages.
Class template for all interfaces role implementations.
Simple raw pointer wrapper.
Type
HAN-FUN Network Destination Address Types.
#define UNUSED(x)
Helper macro to remove warning about unused function/method argument.
void request() const
Helper method to create a session management request.
AbstractServer(Unit0 &unit)
Constructor.
Server(Unit0 &unit)
Constructor.
virtual Common::Result destroy(uint16_t address, Protocol::Address::Type type=Protocol::Address::DEVICE)=0
Destroy the entries in the persistent storage, that refer to the the given address.
Common interface for all Interfaces.
void get_entries(uint16_t offset, uint8_t count=0) const
Read entries.
End Session Read Registration Info.
Class template for all core services implementations.
uint16_t payload_size(CMD cmd) const
Get the minimum number of bytes necessary to pack/unpack a message of the given command.
Result
Commands result codes.
static constexpr uint16_t min_size
Minimum pack/unpack required data size.
Common::Result add(const Protocol::Address &source, const Protocol::Address &destination, const Common::Interface &itf)
Create a new bind entry in the database.
Protocol::Address destination
Destination Address.
uint16_t size() const
Return the number of entries in the container.
HF::Attributes::IAttribute * create_attribute(HF::Core::AttributeReporting::IServer *server, uint8_t uid)
Create an attribute object that can hold the attribute with the given uid.
Number of entries attribute.
Start a new session for a device.
Basic API for persistent storage implementations.
Top-level namespace for the HAN-FUN library.