1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-06 13:22:19 +01:00

Make some Action methods protected

Apparently play()/stop() etc. are not meant to be called directly by
users of the class and if they're called directly that would not give
the expected result for the classes that have an empty play().

Make all methods except play_complex, stop_comples and is_running
protected.  While there also make RemoteTransmitterActionBase::encode
protected.
This commit is contained in:
Andrew Zaborowski
2020-05-01 12:38:34 +02:00
committed by Andrew Zaborowski
parent da390d32f8
commit a62b6548d2
42 changed files with 250 additions and 203 deletions

View File

@@ -11,9 +11,9 @@ template<typename... Ts> class TurnOnAction : public Action<Ts...> {
public:
explicit TurnOnAction(Switch *a_switch) : switch_(a_switch) {}
void play(Ts... x) override { this->switch_->turn_on(); }
protected:
void play_(Ts... x) override { this->switch_->turn_on(); }
Switch *switch_;
};
@@ -21,9 +21,9 @@ template<typename... Ts> class TurnOffAction : public Action<Ts...> {
public:
explicit TurnOffAction(Switch *a_switch) : switch_(a_switch) {}
void play(Ts... x) override { this->switch_->turn_off(); }
protected:
void play_(Ts... x) override { this->switch_->turn_off(); }
Switch *switch_;
};
@@ -31,9 +31,9 @@ template<typename... Ts> class ToggleAction : public Action<Ts...> {
public:
explicit ToggleAction(Switch *a_switch) : switch_(a_switch) {}
void play(Ts... x) override { this->switch_->toggle(); }
protected:
void play_(Ts... x) override { this->switch_->toggle(); }
Switch *switch_;
};
@@ -73,9 +73,9 @@ template<typename... Ts> class SwitchPublishAction : public Action<Ts...> {
public:
SwitchPublishAction(Switch *a_switch) : switch_(a_switch) {}
TEMPLATABLE_VALUE(bool, state)
void play(Ts... x) override { this->switch_->publish_state(this->state_.value(x...)); }
protected:
void play_(Ts... x) override { this->switch_->publish_state(this->state_.value(x...)); }
Switch *switch_;
};