8#include <AH/STL/type_traits>
9#include <AH/STL/utility>
27template <
class Derived>
31#if defined(__GNUC__) && !defined(__clang__)
32#pragma GCC diagnostic push
33#pragma GCC diagnostic ignored "-Wattributes"
73#if defined(__GNUC__) && !defined(__clang__)
74#pragma GCC diagnostic pop
81 template <
class...
Args>
84 for (
auto &
el : updatables)
98 ERROR(F(
"Error: This element is already enabled."), 0x1212);
108 ERROR(F(
"Error: This element is already disabled."), 0x1213);
121 return updatables.couldContain(
CRTP(
const Derived));
129 template <
class U,
size_t N>
140 template <
class U,
size_t N>
155template <
class Derived>
168template <
class T = NormalUpdatable>
182 static void beginAll() { Updatable::applyToAll(&Updatable::begin); }
186 static void updateAll() { Updatable::applyToAll(&Updatable::update); }
#define BEGIN_AH_NAMESPACE
#define CRTP(Derived)
Helper for the Curiously Recurring Template Pattern.
A class for serial-in/parallel-out shift registers, like the 74HC595 that are connected to the SPI bu...
A super class for object that have to be updated regularly.
static void enable(UpdatableCRTP &element)
Enable this updatable: insert it into the linked list of instances, so it gets updated automatically.
UpdatableCRTP(UpdatableCRTP &&) __attribute__((no_sanitize("undefined")))
static void enable(U(&array)[N])
Enable this updatable: insert it into the linked list of instances, so it gets updated automatically.
UpdatableCRTP & operator=(UpdatableCRTP &&)
UpdatableCRTP(const UpdatableCRTP &) __attribute__((no_sanitize("undefined")))
UpdatableCRTP() __attribute__((no_sanitize("undefined")))
Constructor: create an Updatable and add it to the linked list of instances.
void moveDown()
Move down this element in the list.
void enable()
Enable this updatable: insert it into the linked list of instances, so it gets updated automatically.
static DoublyLinkedList< Derived > updatables
static void disable(UpdatableCRTP &element)
Disable this updatable: remove it from the linked list of instances, so it no longer gets updated aut...
UpdatableCRTP & operator=(const UpdatableCRTP &)
virtual ~UpdatableCRTP() __attribute__((no_sanitize("undefined")))
Destructor: remove the updatable from the linked list of instances.
void disable()
Disable this updatable: remove it from the linked list of instances, so it no longer gets updated aut...
bool isEnabled() const
Check if this updatable is enabled.
static void disable(UpdatableCRTP *element)
Disable this updatable: remove it from the linked list of instances, so it no longer gets updated aut...
static void disable(U(&array)[N])
Disable this updatable: remove it from the linked list of instances, so it no longer gets updated aut...
static void enable(UpdatableCRTP *element)
Enable this updatable: insert it into the linked list of instances, so it gets updated automatically.
A super class for object that have to be updated regularly.
static void updateAll()
Update all enabled instances of this class.
static void beginAll()
Begin all enabled instances of this class.
virtual void update()=0
Update this updatable.
virtual void begin()=0
Initialize this updatable.
A class that can be inherited from to allow inserting into a DoublyLinkedList.