13template<
int...>
struct seq {};
14template<
int N,
int... S>
struct gens :
gens<N - 1, N - 1, S...> {};
15template<
int... S>
struct gens<0, S...> {
using type =
seq<S...>; };
17#define TEMPLATABLE_VALUE_(type, name) \
19 TemplatableValue<type, Ts...> name##_{}; \
22 template<typename V> void set_##name(V name) { this->name##_ = name; }
24#define TEMPLATABLE_VALUE(type, name) TEMPLATABLE_VALUE_(type, name)
35 this->
f_ =
new std::function<T(X...)>(std::move(f));
43 this->
f_ =
new std::function<T(X...)>(*other.
f_);
50 new (&this->
value_) T(std::move(other.value_));
87 return (*this->
f_)(
x...);
102 return default_value;
116 std::function<T(X...)> *
f_;
136 return this->
check(std::get<S>(tuple)...);
140template<
typename... Ts>
class Automation;
169template<
typename... Ts>
class ActionList;
192 if (this->
next_ !=
nullptr)
204 if (this->
next_ !=
nullptr) {
218 if (this->
next_ !=
nullptr) {
224 if (this->
next_ ==
nullptr)
247 for (
auto *action : actions) {
277 this->
play(std::get<S>(tuple)...);
virtual bool is_running()
Check if this or any of the following actions are currently running.
virtual void play_complex(Ts... x)
void play_next_tuple_(const std::tuple< Ts... > &tuple, seq< S... >)
virtual void stop_complex()
void play_next_tuple_(const std::tuple< Ts... > &tuple)
int num_running_
The number of instances of this sequence in the list of actions that is currently being executed.
int num_running_total()
The total number of actions that are currently running in this plus any of the following actions in t...
virtual void play(Ts... x)=0
void add_action(Action< Ts... > *action)
Action< Ts... > * actions_end_
void play_tuple(const std::tuple< Ts... > &tuple)
bool is_running()
Check if any action in this action list is currently running.
void add_actions(const std::vector< Action< Ts... > * > &actions)
void play_tuple_(const std::tuple< Ts... > &tuple, seq< S... >)
Action< Ts... > * actions_begin_
int num_running()
Return the number of actions in this action list that are currently running.
void add_action(Action< Ts... > *action)
Trigger< Ts... > * trigger_
void add_actions(const std::vector< Action< Ts... > * > &actions)
int num_running()
Return the number of actions in the action part of this automation that are currently running.
Automation(Trigger< Ts... > *trigger)
ActionList< Ts... > actions_
Base class for all automation conditions.
bool check_tuple(const std::tuple< Ts... > &tuple)
Call check with a tuple of values as parameter.
virtual bool check(Ts... x)=0
Check whether this condition passes. This condition check must be instant, and not cause any delays.
bool check_tuple_(const std::tuple< Ts... > &tuple, seq< S... >)
TemplatableValue(const TemplatableValue &other)
std::function< T(X...)> * f_
TemplatableValue & operator=(TemplatableValue &&other) noexcept
TemplatableValue(TemplatableValue &&other) noexcept
enum esphome::TemplatableValue::@159 type_
TemplatableValue & operator=(const TemplatableValue &other)
T value_or(X... x, T default_value)
TemplatableValue(F value)
optional< T > optional_value(X... x)
Automation< Ts... > * automation_parent_
void stop_action()
Stop any action connected to this trigger.
bool is_action_running()
Returns true if any action connected to this trigger is running.
void trigger(Ts... x)
Inform the parent automation that the event has triggered.
void set_automation_parent(Automation< Ts... > *automation_parent)
Providing packet encoding functions for exchanging data with a remote host.