clangtidy corrections part 1

This commit is contained in:
2023-10-11 17:35:40 +02:00
parent 77a52b82c3
commit 23d854a826
36 changed files with 2383 additions and 1165 deletions
+22 -8
View File
@@ -1,25 +1,35 @@
#include "component.h"
Component::Component(uint16_t loopDelay) {
this->loopDelay = loopDelay;
Component::Component(uint16_t loopDelay) : loopDelay{loopDelay}
{
}
void Component::loop() {
void Component::loop()
{
if (!this->active)
{
return;
}
if (this->childComponents.size()){
std::list<Component*>::iterator it;
if (this->childComponents.size())
{
std::list<Component *>::iterator it;
for (it = this->childComponents.begin(); it != this->childComponents.end(); it++)
{
(*it)->loop();
}
}
this->runAsChild();
if (this->onlyChilds)
{
return;
}
if (this->loopDelay && millis() - this->lastMillis < this->loopDelay)
if (static_cast<bool>(this->loopDelay) && millis() - this->lastMillis < this->loopDelay)
{
return;
}
this->lastMillis = millis();
@@ -28,13 +38,17 @@ void Component::loop() {
this->afterRun();
if (this->timeUpdateAfter)
{
this->lastMillis = millis();
}
}
void Component::addChildComponent(Component* child) {
void Component::addChildComponent(Component *child)
{
this->childComponents.push_back(child);
}
void Component::removeChildComponent(Component* child) {
void Component::removeChildComponent(Component *child)
{
this->childComponents.remove(child);
}
+30 -29
View File
@@ -1,12 +1,12 @@
/**
* @file component.h
* @author Alexander Klein (alex@kleiax.de)
* @brief
* @brief
* @version 0.1
* @date 2023-08-16
*
*
* @copyright Copyright (c) 2023
*
*
*/
#pragma once
@@ -15,37 +15,38 @@
#include <list>
class Component {
public:
Component() {}
Component(uint16_t loopDelay);
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 loop();
void addChildComponent(Component* child);
void removeChildComponent(Component* child);
void deactivate() { this->active = false; }
void activate() { this->active = false; }
void activateOnlyChilds() { this->onlyChilds = true; }
void deactivateOnlyChilds() { this->onlyChilds = false; }
protected:
virtual void runAsChild() {}
virtual void beforeRun() {}
virtual void run() = 0;
virtual void afterRun() {}
void setTimerAfterTask() { this->timeUpdateAfter = true; }
void addChildComponent(Component *child);
void removeChildComponent(Component *child);
uint16_t loopDelay = 0;
void activateOnlyChilds() { this->onlyChilds = true; }
void deactivateOnlyChilds() { this->onlyChilds = false; }
private:
std::list<Component*> childComponents;
void setTimerAfterTask() { this->timeUpdateAfter = true; }
bool active = true;
bool onlyChilds = false;
bool timeUpdateAfter = false;
uint32_t lastMillis = 0;
uint16_t loopDelay = 0;
private:
std::list<Component *> childComponents;
bool active = true;
bool onlyChilds = false;
bool timeUpdateAfter = false;
uint32_t lastMillis = 0;
};