![]() |
Consolix
|
Component for managing a customizable execution loop. More...
#include <LoopComponent.hpp>
Public Member Functions | |
| LoopComponent ()=default | |
| Default constructor. | |
| LoopComponent (std::function< bool()> on_initialize, std::function< void()> on_execute, std::function< void(int)> on_shutdown) | |
| Constructor with customizable callbacks. | |
| virtual | ~LoopComponent () override=default |
| Virtual destructor. | |
| std::function< bool()> & | on_initialize () |
| Access the initialization function. | |
| std::function< void()> & | on_execute () |
| Access the execution function. | |
| std::function< void(int)> & | on_shutdown () |
| Access the shutdown function. | |
Public Member Functions inherited from consolix::IAppComponent | |
| virtual | ~IAppComponent ()=default |
| Virtual destructor for polymorphic usage. | |
Public Member Functions inherited from consolix::IShutdownable | |
| virtual | ~IShutdownable ()=default |
| Virtual destructor for polymorphic use. | |
Protected Member Functions | |
| bool | initialize () override |
| Initializes the component. | |
| bool | is_initialized () override const |
| Checks if the component is initialized. | |
| void | execute () override |
| Executes the main loop logic. | |
| void | shutdown (int signal) override |
| Shuts down the component. | |
Protected Member Functions inherited from consolix::IAppComponent | |
| virtual void | process ()=0 |
| Executes the component's main logic. Called repeatedly during the application's main execution loop. | |
Private Attributes | |
| std::function< bool()> | m_on_initialize |
| Initialization function. | |
| std::function< void()> | m_on_execute |
| Execution function for the loop. | |
| std::function< void(int)> | m_on_shutdown |
| Shutdown function. | |
| std::atomic< bool > | m_is_init {false} |
| Indicates whether the component is initialized. | |
Component for managing a customizable execution loop.
This component allows for running a loop with user-defined behavior. It supports three customizable functions:
on_initialize: Called once during initialization.on_execute: Called repeatedly while the loop is running.on_shutdown: Called during shutdown. Definition at line 24 of file LoopComponent.hpp.
|
default |
Default constructor.
|
inline |
Constructor with customizable callbacks.
| on_initialize | Function to execute during initialization. |
| on_execute | Function to execute in the loop. |
| on_shutdown | Function to execute during shutdown. |
Definition at line 36 of file LoopComponent.hpp.
|
overridevirtualdefault |
Virtual destructor.
|
inlineoverrideprotected |
Executes the main loop logic.
Calls the on_execute function repeatedly. If no function is provided, the loop idles with a short sleep.
Definition at line 97 of file LoopComponent.hpp.
|
inlineoverrideprotectedvirtual |
Initializes the component.
true if initialization succeeds, false otherwise. Implements consolix::IAppComponent.
Definition at line 70 of file LoopComponent.hpp.
|
inlineoverrideprotectedvirtual |
Checks if the component is initialized.
true if the component is initialized, false otherwise. Implements consolix::IAppComponent.
Definition at line 89 of file LoopComponent.hpp.
|
inline |
Access the execution function.
Definition at line 56 of file LoopComponent.hpp.
|
inline |
Access the initialization function.
Definition at line 50 of file LoopComponent.hpp.
|
inline |
Access the shutdown function.
Definition at line 62 of file LoopComponent.hpp.
|
inlineoverrideprotectedvirtual |
Shuts down the component.
| signal | The shutdown signal. |
Implements consolix::IShutdownable.
Definition at line 114 of file LoopComponent.hpp.
|
private |
Indicates whether the component is initialized.
Definition at line 132 of file LoopComponent.hpp.
|
private |
Execution function for the loop.
Definition at line 130 of file LoopComponent.hpp.
|
private |
Initialization function.
Definition at line 129 of file LoopComponent.hpp.
|
private |
Shutdown function.
Definition at line 131 of file LoopComponent.hpp.