esphome-api-client 0.5.0
Modern C++17 client for the ESPHome native API (plaintext + Noise)
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
esphome::api::MessageRegistry Class Reference

Maps the protocol's numeric message ids (the proto (id) option) to and from concrete message types. More...

#include <message_registry.hpp>

Public Member Functions

 MessageRegistry (const MessageRegistry &)=delete
 
MessageRegistryoperator= (const MessageRegistry &)=delete
 

Static Public Member Functions

static const MessageRegistryinstance ()
 The process-wide registry (constructed on first use).
 
static std::unique_ptr< ProtoMessagecreate (std::uint32_t id)
 Create a default-constructed message for id, or nullptr if no message type carries that id.
 
static std::unique_ptr< ProtoMessagecreate (MessageId id)
 
static bool contains (std::uint32_t id)
 Whether a message type with id exists.
 
static std::size_t size () noexcept
 Number of registered message types.
 
static std::uint32_t id_of (const ProtoMessage &msg)
 The message id of a concrete message instance (0 if it carries none).
 

Detailed Description

Maps the protocol's numeric message ids (the proto (id) option) to and from concrete message types.

Backed by a generated id<->type table (see api_registry.cpp) — no runtime reflection. The encode direction (id_of) reads the message's own id; the decode direction (create) is a generated switch.

Constructor & Destructor Documentation

◆ MessageRegistry()

esphome::api::MessageRegistry::MessageRegistry ( const MessageRegistry )
delete

Member Function Documentation

◆ contains()

static bool esphome::api::MessageRegistry::contains ( std::uint32_t  id)
static

Whether a message type with id exists.

◆ create() [1/2]

static std::unique_ptr< ProtoMessage > esphome::api::MessageRegistry::create ( MessageId  id)
static

◆ create() [2/2]

static std::unique_ptr< ProtoMessage > esphome::api::MessageRegistry::create ( std::uint32_t  id)
static

Create a default-constructed message for id, or nullptr if no message type carries that id.

◆ id_of()

static std::uint32_t esphome::api::MessageRegistry::id_of ( const ProtoMessage msg)
static

The message id of a concrete message instance (0 if it carries none).

◆ instance()

static const MessageRegistry & esphome::api::MessageRegistry::instance ( )
static

The process-wide registry (constructed on first use).

◆ operator=()

MessageRegistry & esphome::api::MessageRegistry::operator= ( const MessageRegistry )
delete

◆ size()

static std::size_t esphome::api::MessageRegistry::size ( )
staticnoexcept

Number of registered message types.


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