9#include <AH/Containers/CRTP.hpp>
12#include <AH/STL/type_traits>
13#include <AH/STL/utility>
31template <
class Derived>
35#if defined(__GNUC__) && !defined(__clang__)
36#pragma GCC diagnostic push
37#pragma GCC diagnostic ignored "-Wattributes"
59 __attribute__((no_sanitize(
"undefined")))
77#if defined(__GNUC__) && !defined(__clang__)
78#pragma GCC diagnostic pop
85 template <
class... Args>
86 static void __attribute__((always_inline))
87 applyToAll(
void (Derived::*method)(Args...), Args... args) {
89 (el.*method)(args...);
102 ERROR(F(
"Error: This element is already enabled."), 0x1212);
112 ERROR(F(
"Error: This element is already disabled."), 0x1213);
133 template <
class U,
size_t N>
144 template <
class U,
size_t N>
159template <
class Derived>
172template <
class T = NormalUpdatable>
#define CRTP(Derived)
Helper for the Curiously Recurring Template Pattern.
#define BEGIN_AH_NAMESPACE
#define AH_DIAGNOSTIC_POP()
#define AH_DIAGNOSTIC_WERROR()
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.