12#define LOG_SELECT(prefix, type, obj) \
13 if (log_entity_header(TAG, prefix, LOG_STR_LITERAL(type), (obj))) { \
14 LOG_ENTITY_ICON(TAG, prefix, *(obj)); \
17#define SUB_SELECT(name) \
19 select::Select *name##_select_{nullptr}; \
22 void set_##name##_select(select::Select *select) { this->name##_select_ = select; }
60 optional<size_t>
index_of(
const char *option,
size_t len)
const;
61 optional<size_t>
index_of(
const std::string &option)
const {
return this->
index_of(option.data(), option.size()); }
62 optional<size_t>
index_of(
const char *option)
const {
return this->
index_of(option, strlen(option)); }
68 optional<std::string>
at(
size_t index)
const;
71 const char *
option_at(
size_t index)
const;
104 virtual void control(
const std::string &value) {
106 if (index.has_value()) {
121 void control(
size_t index)
override { Fn(
this, index); }
constexpr size_t size() const
StringRef is a reference to a string owned by something else.
Calls the codegen-generated Fn(this, index) on a new index; the hub and any publish are baked into Fn...
void control(size_t index) override
Base-class for all selects.
void add_on_state_callback(F &&callback)
const char * option_at(size_t index) const
Return the option value at the provided index offset (as const char* from flash).
SelectCall make_call()
Instantiate a SelectCall object to modify this select component's state.
virtual void control(size_t index)
Set the value of the select by index, this is an optional virtual method.
optional< size_t > active_index() const
Return the (optional) index offset of the currently active option.
LazyCallbackManager< void(size_t)> state_callback_
size_t size() const
Return the number of options in this select component.
bool has_option(const char *option) const
optional< size_t > index_of(const std::string &option) const
optional< std::string > at(size_t index) const
Return the (optional) option value at the provided index offset.
bool has_option(const std::string &option) const
Return whether this select component contains the provided option.
optional< size_t > index_of(const char *option, size_t len) const
Find the (optional) index offset of the provided option value.
bool has_index(size_t index) const
Return whether this select component contains the provided index offset.
virtual void control(const std::string &value)
Set the value of the select, this is a virtual method that each select integration can implement.
optional< size_t > index_of(const char *option) const
StringRef current_option() const
Return the currently selected option, or empty StringRef if no state.
void publish_state(const std::string &state)
const SelectOptions & get_options() const