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"
55 __attribute__((no_sanitize(
"undefined")))
73#if defined(__GNUC__) && !defined(__clang__)
74#pragma GCC diagnostic pop
81 template <
class... Args>
82 static void __attribute__((always_inline))
83 applyToAll(
void (Derived::*method)(Args...), Args... args) {
85 (el.*method)(args...);
98 ERROR(F(
"Error: This element is already enabled."), 0x1212);
108 ERROR(F(
"Error: This element is already disabled."), 0x1213);
129 template <
class U,
size_t N>
140 template <
class U,
size_t N>
155template <
class Derived>
168template <
class T = NormalUpdatable>
#define CRTP(Derived)
Helper for the Curiously Recurring Template Pattern.
#define BEGIN_AH_NAMESPACE
A class that can be inherited from to allow inserting into a DoublyLinkedList.
void append(Node *node)
Append a node to a linked list.
bool couldContain(const Node *node) const
Check if the linked list could contain the given node.
void remove(Node *node)
Remove a node from the linked list.
void moveDown(Node *node)
Move down the given node in the linked list.
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.
#define ERROR(msg, errc)
Print the error message and error code, and stop the execution if FATAL_ERRORS are enabled.