![]() |
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. | |
![]() | |
virtual | ~IAppComponent ()=default |
Virtual destructor for polymorphic usage. | |
![]() | |
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:
on_once()
for one-time initialization logic.on_loop()
for the recurring loop logic.on_shutdown(signal)
for handling cleanup when the application shuts down. 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.
true
if initialization succeeds, false
otherwise. Implements consolix::IAppComponent.
Definition at line 58 of file BaseLoopComponent.hpp.
|
inlinefinaloverrideprotectedvirtual |
Checks if the component has been initialized.
true
if the component is initialized, false
otherwise. Implements consolix::IAppComponent.
Definition at line 65 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.
true
if initialization succeeds, false
otherwise. 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.
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 72 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 80 of file BaseLoopComponent.hpp.
|
private |
Tracks whether the component is initialized.
Definition at line 85 of file BaseLoopComponent.hpp.