/** * @file component.h * @author Alexander Klein (alex@kleiax.de) * @brief * @version 0.1 * @date 2023-08-16 * * @copyright Copyright (c) 2023 * */ #pragma once #include #include class Component { public: Component() {} Component(uint16_t loopDelay); void loop(); void deactivate() { this->active = false; } void activate() { this->active = false; } protected: virtual void runAsChild() {} virtual void beforeRun() {} virtual void run() = 0; virtual void afterRun() {} void addChildComponent(Component *child); void removeChildComponent(Component *child); void activateOnlyChilds() { this->onlyChilds = true; } void deactivateOnlyChilds() { this->onlyChilds = false; } void setTimerAfterTask() { this->timeUpdateAfter = true; } uint16_t loopDelay = 0; private: std::list childComponents; bool active = true; bool onlyChilds = false; bool timeUpdateAfter = false; uint32_t lastMillis = 0; };