mirror of
https://github.com/esphome/esphome.git
synced 2025-10-05 19:33:47 +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:
committed by
Andrew Zaborowski
parent
da390d32f8
commit
a62b6548d2
@@ -23,9 +23,9 @@ template<typename... Ts> class ScriptExecuteAction : public Action<Ts...> {
|
||||
public:
|
||||
ScriptExecuteAction(Script *script) : script_(script) {}
|
||||
|
||||
void play(Ts... x) override { this->script_->trigger(); }
|
||||
|
||||
protected:
|
||||
void play_(Ts... x) override { this->script_->trigger(); }
|
||||
|
||||
Script *script_;
|
||||
};
|
||||
|
||||
@@ -33,9 +33,9 @@ template<typename... Ts> class ScriptStopAction : public Action<Ts...> {
|
||||
public:
|
||||
ScriptStopAction(Script *script) : script_(script) {}
|
||||
|
||||
void play(Ts... x) override { this->script_->stop(); }
|
||||
|
||||
protected:
|
||||
void play_(Ts... x) override { this->script_->stop(); }
|
||||
|
||||
Script *script_;
|
||||
};
|
||||
|
||||
@@ -53,14 +53,11 @@ template<typename... Ts> class ScriptWaitAction : public Action<Ts...>, public C
|
||||
public:
|
||||
ScriptWaitAction(Script *script) : script_(script) {}
|
||||
|
||||
void play(Ts... x) override { /* ignore - see play_complex */
|
||||
}
|
||||
|
||||
void play_complex(Ts... x) override {
|
||||
this->num_running_++;
|
||||
// Check if we can continue immediately.
|
||||
if (!this->script_->is_running()) {
|
||||
this->play_next(x...);
|
||||
this->play_next_(x...);
|
||||
return;
|
||||
}
|
||||
this->var_ = std::make_tuple(x...);
|
||||
@@ -74,12 +71,15 @@ template<typename... Ts> class ScriptWaitAction : public Action<Ts...>, public C
|
||||
if (this->script_->is_running())
|
||||
return;
|
||||
|
||||
this->play_next_tuple(this->var_);
|
||||
this->play_next_tuple_(this->var_);
|
||||
}
|
||||
|
||||
float get_setup_priority() const override { return setup_priority::DATA; }
|
||||
|
||||
protected:
|
||||
void play_(Ts... x) override { /* ignore - see play_complex */
|
||||
}
|
||||
|
||||
Script *script_;
|
||||
std::tuple<Ts...> var_{};
|
||||
};
|
||||
|
Reference in New Issue
Block a user