17#define LOG_EVENT(prefix, type, obj) \
18 if (log_entity_header(TAG, prefix, LOG_STR_LITERAL(type), (obj))) { \
19 LOG_ENTITY_ICON(TAG, prefix, *(obj)); \
20 LOG_ENTITY_DEVICE_CLASS(TAG, prefix, *(obj)); \
26 void trigger(
const char *event_type);
27 void trigger(
const std::string &event_type) { this->
trigger(event_type.c_str()); }
32 this->last_event_type_ =
nullptr;
63 if (this->last_event_type_ ==
nullptr)
64 return std::numeric_limits<uint8_t>::max();
67 for (uint8_t i = 0; i <
size; i++) {
68 if (this->
types_[i] == this->last_event_type_)
71 return std::numeric_limits<uint8_t>::max();
75 bool has_event()
const {
return this->last_event_type_ !=
nullptr; }
90 const char *last_event_type_{
nullptr};
constexpr size_t size() const
Fixed-capacity vector - sized once through init() or try_init(); push_back never reallocates This avo...
StringRef is a reference to a string owned by something else.
static StringRef from_maybe_nullptr(const char *s)
LazyCallbackManager< void(StringRef event_type)> event_callback_
void set_event_types(std::initializer_list< const char * > event_types)
Runtime lists are copied; the strings must still outlive the event.
bool has_event() const
Check if an event has been triggered.
void set_event_types(std::initializer_list< std::string > event_types)=delete
void trigger(const char *event_type)
Trigger an event; the type is matched against the configured types by string compare.
void set_event_types(const FixedVector< std::string > &event_types)=delete
void set_event_types(const FixedVector< const char * > &event_types)
const EventTypes & get_event_types() const
Return the event types supported by this event.
void set_event_types_static(const char *const *event_types, size_t count)
Codegen only: points at a table that outlives the event (see ConstVector::assign_static).
uint8_t get_last_event_type_index() const
Return index of last triggered event type, or max uint8_t if no event triggered yet.
void set_event_types(const EventTypes &event_types)
Copy the event types of another event, for components that wrap one.
void trigger(const std::string &event_type)
StringRef get_last_event_type() const
Return the last triggered event type, or empty StringRef if no event triggered yet.
void set_event_types_copy_(const char *const *event_types, size_t count)
const char * get_event_type(uint8_t index) const
Return event type by index, or nullptr if index is out of bounds.
void add_on_event_callback(F &&callback)