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)
40 return this->
f_(
x...);
68 std::function<T(X...)>
f_{};
87 return this->
check(std::get<S>(tuple)...);
91template<
typename... Ts>
class Automation;
120template<
typename... Ts>
class ActionList;
143 if (this->
next_ !=
nullptr)
155 if (this->
next_ !=
nullptr) {
169 if (this->
next_ !=
nullptr) {
175 if (this->
next_ ==
nullptr)
198 for (
auto *action : actions) {
228 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... >)
std::function< T(X...)> f_
enum esphome::TemplatableValue::@154 type_
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.
typename std::enable_if< B, T >::type enable_if_t