ESPHome 2026.5.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;
31 if (this->on_begin()) {
33 }
34 break;
35
36// Entity iterator cases (generated from entity_types.h)
37// NOLINTBEGIN(bugprone-macro-parentheses)
38#define ENTITY_TYPE_(type, singular, plural, count, upper) \
39 case IteratorState::upper: \
40 this->process_platform_item_(App.get_##plural(), &ComponentIterator::on_##singular); \
41 break;
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 break;
53#endif
54
55#ifdef USE_CAMERA
57 camera::Camera *camera_instance = camera::Camera::instance();
58 if (camera_instance != nullptr && (!camera_instance->is_internal() || this->include_internal_)) {
59 this->on_camera(camera_instance);
60 }
62 } break;
63#endif
64
66 if (this->on_end()) {
68 }
69 return;
70 }
71}
72
73bool ComponentIterator::on_end() { return true; }
74bool ComponentIterator::on_begin() { return true; }
75#ifdef USE_API_USER_DEFINED_ACTIONS
77#endif
78#ifdef USE_CAMERA
79bool ComponentIterator::on_camera(camera::Camera *camera) { return true; }
80#endif
81} // namespace esphome
void process_platform_item_(const Container &items, bool(ComponentIterator::*on_item)(typename Container::value_type))
void begin(bool include_internal=false)
virtual bool on_service(api::UserServiceDescriptor *service)
virtual bool on_camera(camera::Camera *camera)
bool is_internal() const
Abstract camera base class.
Definition camera.h:115
static Camera * instance()
The singleton instance of the camera implementation.
Definition camera.cpp:19
APIServer * global_api_server
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
static void uint32_t