![]() |
Consolix
|
Abstract base class for application components with looping functionality. More...
#include <BaseLoopComponent.hpp>
Public Member Functions | |
| BaseLoopComponent ()=default | |
| Constructs a BaseLoopComponent. | |
| virtual | ~BaseLoopComponent ()=default |
| Destroys the BaseLoopComponent. | |
| virtual bool | on_once ()=0 |
| Called once during component initialization. | |
| virtual void | on_loop ()=0 |
| Called repeatedly during the application's main loop. | |
| virtual void | on_shutdown (int signal)=0 |
| Called when the application shuts down. | |
| 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 final |
| Initializes the component. | |
| bool | is_initialized () const override final |
| Checks if the component has been initialized. | |
| void | process () override final |
| Executes the loop logic for the component. | |
| void | shutdown (int signal) override final |
| Shuts down the component. | |
Private Attributes | |
| std::atomic< bool > | m_is_init {false} |
| Tracks whether the component is initialized. | |
Abstract base class for application components with looping functionality.
This class provides a framework for implementing components that require a continuous execution cycle. Derived classes must define:
Definition at line 23 of file BaseLoopComponent.hpp.
|
default |
Constructs a BaseLoopComponent.
|
virtualdefault |
Destroys the BaseLoopComponent.
|
inlinefinaloverrideprotectedvirtual |
Initializes the component.
Calls on_once() to perform one-time setup and marks the component as initialized if successful.
Implements consolix::IAppComponent.
Definition at line 59 of file BaseLoopComponent.hpp.
|
inlinefinaloverrideprotectedvirtual |
Checks if the component has been initialized.
Implements consolix::IAppComponent.
Definition at line 66 of file BaseLoopComponent.hpp.
|
pure virtual |
Called repeatedly during the application's main loop.
Derived classes should implement this method to define the recurring functionality of the component.
Implemented in CustomLoop.
|
pure virtual |
Called once during component initialization.
Derived classes should implement this method to perform setup operations that need to happen before the main loop starts.
Implemented in CustomLoop.
|
pure virtual |
Called when the application shuts down.
Derived classes should implement this method to release resources or perform cleanup operations before termination. On POSIX, this callback is invoked after the signal handler has requested shutdown, not from the handler itself.
| signal | The signal that triggered the shutdown. |
Implemented in CustomLoop.
|
inlinefinaloverrideprotectedvirtual |
Executes the loop logic for the component.
Calls on_loop() to run the recurring functionality of the component.
Implements consolix::IAppComponent.
Definition at line 73 of file BaseLoopComponent.hpp.
|
inlinefinaloverrideprotectedvirtual |
Shuts down the component.
Calls on_shutdown(signal) to clean up resources or terminate processes.
| signal | The signal that triggered the shutdown. |
Implements consolix::IShutdownable.
Definition at line 81 of file BaseLoopComponent.hpp.
|
private |
Tracks whether the component is initialized.
Definition at line 86 of file BaseLoopComponent.hpp.