Skip to content

Commit

Permalink
Refactor widget header files for pragma once directive
Browse files Browse the repository at this point in the history
- Replace ifndef/define with pragma once in BaseWidget.h, BaseWidgetValue.h, WidgetBool.h, and WidgetRange.h to prevent multiple inclusion issues.
  • Loading branch information
forntoh committed Oct 23, 2024
1 parent 8d3d28c commit 3f39ec8
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 27 deletions.
12 changes: 6 additions & 6 deletions src/ItemWidget.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef ITEM_WIDGET_H
#define ITEM_WIDGET_H
#pragma once

#include "BaseItemManyWidgets.h"
#include "widget/BaseWidgetValue.h"
Expand Down Expand Up @@ -77,8 +76,9 @@ template <typename... Ts>
* @param callback reference to callback function to call when the value of the item is changed
* @param widgetPtrs pointers to the widgets associated with this item
*/
inline MenuItem* ITEM_WIDGET(const char* text, typename ItemWidget<Ts...>::CallbackType callback, BaseWidgetValue<Ts>*... widgetPtrs) {
inline MenuItem* ITEM_WIDGET(
const char* text,
typename ItemWidget<Ts...>::CallbackType callback,
BaseWidgetValue<Ts>*... widgetPtrs) {
return new ItemWidget<Ts...>(text, widgetPtrs..., callback);
}

#endif // ITEM_WIDGET_H
}
8 changes: 2 additions & 6 deletions src/widget/BaseWidget.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// Creator: @ShishkinDmitriy

#ifndef BASE_WIDGET_H
#define BASE_WIDGET_H
#pragma once

#ifndef ARDUINO_ARCH_ESP32
#ifndef ARDUINO_ARCH_ESP8266
Expand Down Expand Up @@ -57,6 +55,4 @@ class BaseWidget {

public:
virtual ~BaseWidget() = default;
};

#endif
};
7 changes: 2 additions & 5 deletions src/widget/BaseWidgetValue.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Creator: @ShishkinDmitriy
#ifndef BASE_WIDGET_VALUE_H
#define BASE_WIDGET_VALUE_H
#pragma once

#include "BaseWidget.h"

Expand Down Expand Up @@ -72,6 +71,4 @@ class BaseWidgetValue : public BaseWidget {

public:
~BaseWidgetValue() override = default;
};

#endif // BASE_WIDGET_VALUE_H
};
7 changes: 2 additions & 5 deletions src/widget/WidgetBool.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Creator: @ShishkinDmitriy
#ifndef WIDGET_BOOL_H
#define WIDGET_BOOL_H
#pragma once

#include "BaseWidgetValue.h"

Expand Down Expand Up @@ -70,6 +69,4 @@ inline BaseWidgetValue<bool>* WIDGET_BOOL(
const uint8_t cursorOffset = 0,
void (*callback)(const bool&) = nullptr) {
return new WidgetBool(value, textOn, textOff, format, cursorOffset, callback);
}

#endif
}
7 changes: 2 additions & 5 deletions src/widget/WidgetRange.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Creator: @ShishkinDmitriy
#ifndef WIDGET_RANGE_H
#define WIDGET_RANGE_H
#pragma once

#include "BaseWidgetValue.h"

Expand Down Expand Up @@ -120,6 +119,4 @@ inline BaseWidgetValue<T>* WIDGET_RANGE(
bool cycle = false,
void (*callback)(const T&) = nullptr) {
return new WidgetRange<T>(value, step, min, max, format, cursorOffset, cycle, callback);
}

#endif
}

0 comments on commit 3f39ec8

Please sign in to comment.