ESPHome 2026.10.0-dev
Loading...
Searching...
No Matches
component_iterator.cpp
Go to the documentation of this file.
2
4
5#ifdef USE_API
7#endif
8#ifdef USE_API_USER_DEFINED_ACTIONS
10#endif
11
12namespace esphome {
13
14void ComponentIterator::begin(bool include_internal) {
16 this->at_ = 0;
17 this->include_internal_ = include_internal;
18}
19
21 this->state_ = static_cast<IteratorState>(static_cast<uint32_t>(this->state_) + 1);
22 this->at_ = 0;
23}
24
26 switch (this->state_) {
28 // not started
29 return false;
31 if (this->on_begin()) {
33 return true;
34 }
35 return false;
36
37// Entity iterator cases (generated from entity_types.h)
38// NOLINTBEGIN(bugprone-macro-parentheses)
39#define ENTITY_TYPE_(type, singular, plural, count, upper) \
40 case IteratorState::upper: \
41 return this->process_platform_item_(App.get_##plural(), &ComponentIterator::on_##singular);
42#define ENTITY_CONTROLLER_TYPE_(type, singular, plural, count, upper, callback) \
43 ENTITY_TYPE_(type, singular, plural, count, upper)
45#undef ENTITY_TYPE_
46#undef ENTITY_CONTROLLER_TYPE_
47 // NOLINTEND(bugprone-macro-parentheses)
48
49#ifdef USE_API_USER_DEFINED_ACTIONS
52#endif
53
54#ifdef USE_CAMERA
56 camera::Camera *camera_instance = camera::Camera::instance();
57 if (camera_instance != nullptr && (!camera_instance->is_internal() || this->include_internal_) &&
58 !this->on_camera(camera_instance)) {
59 return false;
60 }
62 return true;
63 }
64#endif
65
67 if (this->on_end()) {
69 return true;
70 }
71 return false;
72 }
73 return false;
74}
75
76bool ComponentIterator::on_end() { return true; }
77bool ComponentIterator::on_begin() { return true; }
78#ifdef USE_API_USER_DEFINED_ACTIONS
80#endif
81#ifdef USE_CAMERA
82bool ComponentIterator::on_camera(camera::Camera *camera) { return true; }
83#endif
84} // namespace esphome
bool advance_step_()
One iteration step; false if no progress was made (callback refused or iterator not running).
void begin(bool include_internal=false)
virtual bool on_service(api::UserServiceDescriptor *service)
virtual bool on_camera(camera::Camera *camera)
bool process_platform_item_(const Container &items, bool(ComponentIterator::*on_item)(typename Container::value_type))
bool is_internal() const
Definition entity_base.h:89
Abstract camera base class.
Definition camera.h:115
static Camera * instance()
The singleton instance of the camera implementation.
Definition camera.cpp:18
APIServer * global_api_server
static void uint32_t