[core] Const-ify some Component fields (#6831)

This commit is contained in:
Jesse Hills 2024-05-30 19:59:15 +12:00 committed by GitHub
parent 9de8eaff24
commit 63fc8ab10a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 6 deletions

View File

@ -1,11 +1,11 @@
#include "esphome/core/component.h"
#include <cinttypes>
#include <utility>
#include "esphome/core/application.h"
#include "esphome/core/hal.h"
#include "esphome/core/helpers.h"
#include "esphome/core/log.h"
#include <utility>
#include <cinttypes>
namespace esphome {
@ -140,8 +140,8 @@ void Component::set_retry(uint32_t initial_wait_time, uint8_t max_attempts, std:
float backoff_increase_factor) { // NOLINT
App.scheduler.set_retry(this, "", initial_wait_time, max_attempts, std::move(f), backoff_increase_factor);
}
bool Component::is_failed() { return (this->component_state_ & COMPONENT_STATE_MASK) == COMPONENT_STATE_FAILED; }
bool Component::is_ready() {
bool Component::is_failed() const { return (this->component_state_ & COMPONENT_STATE_MASK) == COMPONENT_STATE_FAILED; }
bool Component::is_ready() const {
return (this->component_state_ & COMPONENT_STATE_MASK) == COMPONENT_STATE_LOOP ||
(this->component_state_ & COMPONENT_STATE_MASK) == COMPONENT_STATE_SETUP;
}

View File

@ -118,9 +118,9 @@ class Component {
*/
virtual void mark_failed();
bool is_failed();
bool is_failed() const;
bool is_ready();
bool is_ready() const;
virtual bool can_proceed();