ESPHome 2026.10.0-dev
Loading...
Searching...
No Matches
esphome::ComponentIterator Class Reference

#include <component_iterator.h>

Inheritance diagram for esphome::ComponentIterator:
esphome::api::InitialStateIterator esphome::api::ListEntitiesIterator esphome::web_server::ListEntitiesIterator

Public Member Functions

void begin (bool include_internal=false)
 
ESPHOME_ALWAYS_INLINE void try_advance (size_t max_steps)
 Run up to max_steps iteration steps; stops early when iteration completes or a callback refuses (that step is retried on the next call).
 
 ESPDEPRECATED ("Use try_advance() instead. Removed in 2027.3.0", "2026.8.1") void advance()
 
bool completed () const
 
virtual bool on_begin ()
 
virtual bool on_service (api::UserServiceDescriptor *service)
 
virtual bool on_camera (camera::Camera *camera)
 
virtual bool on_end ()
 

Protected Types

enum class  IteratorState : uint8_t {
  NONE = 0 , BEGIN , ENTITY_TYPE_ , ENTITY_CONTROLLER_TYPE_ ,
  SERVICE , CAMERA , MAX
}
 

Protected Member Functions

void yield_after_step_ ()
 End the current try_advance() pass after this step; lets callbacks that write directly to the socket cap direct writes per pass.
 
template<typename Container >
bool process_platform_item_ (const Container &items, bool(ComponentIterator::*on_item)(typename Container::value_type))
 
bool advance_step_ ()
 One iteration step; false if no progress was made (callback refused or iterator not running).
 
void advance_platform_ ()
 

Protected Attributes

uint16_t at_ {0}
 
IteratorState state_ {IteratorState::NONE}
 
bool yield_requested_: 1 {false}
 
bool include_internal_: 1 {false}
 

Detailed Description

Definition at line 30 of file component_iterator.h.

Member Enumeration Documentation

◆ IteratorState

enum class esphome::ComponentIterator::IteratorState : uint8_t
strongprotected
Enumerator
NONE 
BEGIN 
ENTITY_TYPE_ 
ENTITY_CONTROLLER_TYPE_ 
SERVICE 
CAMERA 
MAX 

Definition at line 73 of file component_iterator.h.

Member Function Documentation

◆ advance_platform_()

void esphome::ComponentIterator::advance_platform_ ( )
protected

Definition at line 20 of file component_iterator.cpp.

◆ advance_step_()

bool esphome::ComponentIterator::advance_step_ ( )
protected

One iteration step; false if no progress was made (callback refused or iterator not running).

Definition at line 25 of file component_iterator.cpp.

◆ begin()

void esphome::ComponentIterator::begin ( bool include_internal = false)

Definition at line 14 of file component_iterator.cpp.

◆ completed()

bool esphome::ComponentIterator::completed ( ) const
inline

Definition at line 50 of file component_iterator.h.

◆ ESPDEPRECATED()

esphome::ComponentIterator::ESPDEPRECATED ( "Use try_advance() instead. Removed in 2027.3.0" ,
"2026.8.1"  )
inline

Definition at line 48 of file component_iterator.h.

◆ on_begin()

bool esphome::ComponentIterator::on_begin ( )
virtual

Definition at line 77 of file component_iterator.cpp.

◆ on_camera()

bool esphome::ComponentIterator::on_camera ( camera::Camera * camera)
virtual

Reimplemented in esphome::api::ListEntitiesIterator.

Definition at line 82 of file component_iterator.cpp.

◆ on_end()

bool esphome::ComponentIterator::on_end ( )
virtual

Reimplemented in esphome::api::ListEntitiesIterator.

Definition at line 76 of file component_iterator.cpp.

◆ on_service()

bool esphome::ComponentIterator::on_service ( api::UserServiceDescriptor * service)
virtual

Reimplemented in esphome::api::ListEntitiesIterator.

Definition at line 79 of file component_iterator.cpp.

◆ process_platform_item_()

template<typename Container >
bool esphome::ComponentIterator::process_platform_item_ ( const Container & items,
bool(ComponentIterator::* on_item )(typename Container::value_type) )
inlineprotected

Definition at line 102 of file component_iterator.h.

◆ try_advance()

ESPHOME_ALWAYS_INLINE void esphome::ComponentIterator::try_advance ( size_t max_steps)
inline

Run up to max_steps iteration steps; stops early when iteration completes or a callback refuses (that step is retried on the next call).

Inline so an idle (completed) iterator costs one compare, no call.

Definition at line 36 of file component_iterator.h.

◆ yield_after_step_()

void esphome::ComponentIterator::yield_after_step_ ( )
inlineprotected

End the current try_advance() pass after this step; lets callbacks that write directly to the socket cap direct writes per pass.

Definition at line 94 of file component_iterator.h.

Field Documentation

◆ at_

uint16_t esphome::ComponentIterator::at_ {0}
protected

Definition at line 96 of file component_iterator.h.

◆ include_internal_

bool esphome::ComponentIterator::include_internal_
protected

Definition at line 99 of file component_iterator.h.

◆ state_

IteratorState esphome::ComponentIterator::state_ {IteratorState::NONE}
protected

Definition at line 97 of file component_iterator.h.

◆ yield_requested_

bool esphome::ComponentIterator::yield_requested_
protected

Definition at line 98 of file component_iterator.h.


The documentation for this class was generated from the following files: