A super class for object that have to be updated regularly. More...
#include <AH/Containers/Updatable.hpp>
Public Types | |
using | Mutex = typename std::conditional< ThreadSafe, DefaultMutEx, EmptyMutex >::type |
using | LockGuard = typename std::conditional< ThreadSafe, DefaultLockGuard< Mutex >, EmptyLockGuard< Mutex > >::type |
Public Member Functions | |
virtual | ~UpdatableCRTP () __attribute__((no_sanitize("undefined"))) |
Destructor: remove the updatable from the linked list of instances. More... | |
Static Public Member Functions | |
static Mutex & | getMutex () |
Protected Member Functions | |
UpdatableCRTP () __attribute__((no_sanitize("undefined"))) | |
Constructor: create an Updatable and add it to the linked list of instances. More... | |
Protected Attributes | |
Derived * | next |
Derived * | previous |
Static Protected Attributes | |
static DoublyLinkedList< Derived > | updatables |
static Mutex | mutex |
Main initialization and updating methods | |
template<class... Args> | |
static void | applyToAll (const LockGuard &, void(Derived::*method)(Args &&...), Args &&... args) |
template<class... Args> | |
static void | applyToAll (void(Derived::*method)(Args &&...), Args &&... args) |
Enabling and disabling updatables | |
void | enable (const LockGuard &lock) |
Enable this updatable: insert it into the linked list of instances, so it gets updated automatically. More... | |
void | enable () |
Enable this updatable: insert it into the linked list of instances, so it gets updated automatically. More... | |
void | disable (const LockGuard &lock) |
Disable this updatable: remove it from the linked list of instances, so it no longer gets updated automatically. More... | |
void | disable () |
Disable this updatable: remove it from the linked list of instances, so it no longer gets updated automatically. More... | |
bool | isEnabled (const LockGuard &) const |
Check if this updatable is enabled. More... | |
bool | isEnabled () |
Check if this updatable is enabled. More... | |
void | moveDown (const LockGuard &) |
Move down this element in the list. More... | |
void | moveDown () |
Move down this element in the list. More... | |
static void | enable (UpdatableCRTP *element) |
Enable this updatable: insert it into the linked list of instances, so it gets updated automatically. More... | |
static void | enable (UpdatableCRTP &element) |
Enable this updatable: insert it into the linked list of instances, so it gets updated automatically. More... | |
template<class U , size_t N> | |
static void | enable (U(&array)[N]) |
Enable this updatable: insert it into the linked list of instances, so it gets updated automatically. More... | |
static void | disable (UpdatableCRTP *element) |
Disable this updatable: remove it from the linked list of instances, so it no longer gets updated automatically. More... | |
static void | disable (UpdatableCRTP &element) |
Disable this updatable: remove it from the linked list of instances, so it no longer gets updated automatically. More... | |
template<class U , size_t N> | |
static void | disable (U(&array)[N]) |
Disable this updatable: remove it from the linked list of instances, so it no longer gets updated automatically. More... | |
A super class for object that have to be updated regularly.
All instances of this class are kept in a linked list, so it's easy to iterate over all of them to update them.
This version uses static polymorphism using the Curiously Recurring Template Pattern. This requires less virtual function calls.
(Only the destructor is virtual.)
Definition at line 33 of file Updatable.hpp.
using Mutex = typename std::conditional<ThreadSafe, DefaultMutEx, EmptyMutex>::type |
Definition at line 36 of file Updatable.hpp.
using LockGuard = typename std::conditional<ThreadSafe, DefaultLockGuard<Mutex>, EmptyLockGuard<Mutex> >::type |
Definition at line 38 of file Updatable.hpp.
|
inlineprotected |
Constructor: create an Updatable and add it to the linked list of instances.
Definition at line 61 of file Updatable.hpp.
|
inlinevirtual |
Destructor: remove the updatable from the linked list of instances.
Definition at line 68 of file Updatable.hpp.
|
inlinestatic |
Definition at line 79 of file Updatable.hpp.
|
inlinestatic |
Definition at line 85 of file Updatable.hpp.
|
inlinestatic |
Definition at line 93 of file Updatable.hpp.
|
inline |
Enable this updatable: insert it into the linked list of instances, so it gets updated automatically.
Definition at line 106 of file Updatable.hpp.
|
inline |
Enable this updatable: insert it into the linked list of instances, so it gets updated automatically.
Definition at line 115 of file Updatable.hpp.
|
inline |
Disable this updatable: remove it from the linked list of instances, so it no longer gets updated automatically.
Definition at line 119 of file Updatable.hpp.
|
inline |
Disable this updatable: remove it from the linked list of instances, so it no longer gets updated automatically.
Definition at line 128 of file Updatable.hpp.
|
inline |
Check if this updatable is enabled.
Definition at line 136 of file Updatable.hpp.
|
inline |
Check if this updatable is enabled.
Definition at line 141 of file Updatable.hpp.
|
inlinestatic |
Enable this updatable: insert it into the linked list of instances, so it gets updated automatically.
Definition at line 144 of file Updatable.hpp.
|
inlinestatic |
Enable this updatable: insert it into the linked list of instances, so it gets updated automatically.
Definition at line 146 of file Updatable.hpp.
|
inlinestatic |
Enable this updatable: insert it into the linked list of instances, so it gets updated automatically.
Definition at line 149 of file Updatable.hpp.
|
inlinestatic |
Disable this updatable: remove it from the linked list of instances, so it no longer gets updated automatically.
Definition at line 155 of file Updatable.hpp.
|
inlinestatic |
Disable this updatable: remove it from the linked list of instances, so it no longer gets updated automatically.
Definition at line 157 of file Updatable.hpp.
|
inlinestatic |
Disable this updatable: remove it from the linked list of instances, so it no longer gets updated automatically.
Definition at line 160 of file Updatable.hpp.
|
inline |
Move down this element in the list.
Definition at line 166 of file Updatable.hpp.
|
inline |
Move down this element in the list.
Definition at line 168 of file Updatable.hpp.
|
staticprotected |
Definition at line 173 of file Updatable.hpp.
|
staticprotected |
Definition at line 174 of file Updatable.hpp.
|
protectedinherited |
Definition at line 323 of file LinkedList.hpp.
|
protectedinherited |
Definition at line 324 of file LinkedList.hpp.