Control Surface main
MIDI Control Surface library for Arduino
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
UpdatableCRTP< Derived > Class Template Reference

#include <AH/Containers/Updatable.hpp>

Detailed Description

template<class Derived>
class AH::UpdatableCRTP< Derived >

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 28 of file Updatable.hpp.

+ Inheritance diagram for UpdatableCRTP< Derived >:
+ Collaboration diagram for UpdatableCRTP< Derived >:

Enabling and disabling updatables

void enable ()
 Enable this updatable: insert it into the linked list of instances, so it gets updated automatically.
 
void disable ()
 Disable this updatable: remove it from the linked list of instances, so it no longer gets updated automatically.
 
bool isEnabled () const
 Check if this updatable is enabled.
 
void moveDown ()
 Move down this element in the list.
 
static void enable (UpdatableCRTP *element)
 Enable this updatable: insert it into the linked list of instances, so it gets updated automatically.
 
static void enable (UpdatableCRTP &element)
 Enable this updatable: insert it into the linked list of instances, so it gets updated automatically.
 
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.
 
static void disable (UpdatableCRTP *element)
 Disable this updatable: remove it from the linked list of instances, so it no longer gets updated automatically.
 
static void disable (UpdatableCRTP &element)
 Disable this updatable: remove it from the linked list of instances, so it no longer gets updated automatically.
 
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.
 

Public Member Functions

virtual ~UpdatableCRTP () __attribute__((no_sanitize("undefined")))
 Destructor: remove the updatable from the linked list of instances.
 

Protected Member Functions

 UpdatableCRTP () __attribute__((no_sanitize("undefined")))
 Constructor: create an Updatable and add it to the linked list of instances.
 
 UpdatableCRTP (const UpdatableCRTP &) __attribute__((no_sanitize("undefined")))
 
UpdatableCRTPoperator= (const UpdatableCRTP &)
 
 UpdatableCRTP (UpdatableCRTP &&) __attribute__((no_sanitize("undefined")))
 
UpdatableCRTPoperator= (UpdatableCRTP &&)
 

Protected Attributes

Derivednext
 
Derivedprevious
 

Static Protected Attributes

static DoublyLinkedList< Derivedupdatables
 

Constructor & Destructor Documentation

◆ UpdatableCRTP() [1/3]

template<class Derived >
UpdatableCRTP ( )
inlineprotected

Constructor: create an Updatable and add it to the linked list of instances.

Definition at line 50 of file Updatable.hpp.

◆ UpdatableCRTP() [2/3]

template<class Derived >
UpdatableCRTP ( const UpdatableCRTP< Derived > & )
inlineprotected

Definition at line 54 of file Updatable.hpp.

◆ UpdatableCRTP() [3/3]

template<class Derived >
UpdatableCRTP ( UpdatableCRTP< Derived > && )
inlineprotected

Definition at line 61 of file Updatable.hpp.

◆ ~UpdatableCRTP()

template<class Derived >
virtual ~UpdatableCRTP ( )
inlinevirtual

Destructor: remove the updatable from the linked list of instances.

Definition at line 68 of file Updatable.hpp.

Member Function Documentation

◆ operator=() [1/2]

template<class Derived >
UpdatableCRTP & operator= ( const UpdatableCRTP< Derived > & )
inlineprotected

Definition at line 59 of file Updatable.hpp.

◆ operator=() [2/2]

template<class Derived >
UpdatableCRTP & operator= ( UpdatableCRTP< Derived > && )
inlineprotected

Definition at line 64 of file Updatable.hpp.

◆ enable() [1/4]

template<class Derived >
void enable ( )
inline

Enable this updatable: insert it into the linked list of instances, so it gets updated automatically.

Definition at line 96 of file Updatable.hpp.

◆ disable() [1/4]

template<class Derived >
void disable ( )
inline

Disable this updatable: remove it from the linked list of instances, so it no longer gets updated automatically.

Definition at line 106 of file Updatable.hpp.

◆ isEnabled()

template<class Derived >
bool isEnabled ( ) const
inline

Check if this updatable is enabled.

Note
Assumes that the updatable is not added to a different linked list by the user.

Definition at line 120 of file Updatable.hpp.

◆ enable() [2/4]

template<class Derived >
static void enable ( UpdatableCRTP< Derived > * element)
inlinestatic

Enable this updatable: insert it into the linked list of instances, so it gets updated automatically.

Definition at line 125 of file Updatable.hpp.

◆ enable() [3/4]

template<class Derived >
static void enable ( UpdatableCRTP< Derived > & element)
inlinestatic

Enable this updatable: insert it into the linked list of instances, so it gets updated automatically.

Definition at line 127 of file Updatable.hpp.

◆ enable() [4/4]

template<class Derived >
template<class U , size_t N>
static void enable ( U(&) array[N])
inlinestatic

Enable this updatable: insert it into the linked list of instances, so it gets updated automatically.

Definition at line 130 of file Updatable.hpp.

◆ disable() [2/4]

template<class Derived >
static void disable ( UpdatableCRTP< Derived > * element)
inlinestatic

Disable this updatable: remove it from the linked list of instances, so it no longer gets updated automatically.

Definition at line 136 of file Updatable.hpp.

◆ disable() [3/4]

template<class Derived >
static void disable ( UpdatableCRTP< Derived > & element)
inlinestatic

Disable this updatable: remove it from the linked list of instances, so it no longer gets updated automatically.

Definition at line 138 of file Updatable.hpp.

◆ disable() [4/4]

template<class Derived >
template<class U , size_t N>
static void disable ( U(&) array[N])
inlinestatic

Disable this updatable: remove it from the linked list of instances, so it no longer gets updated automatically.

Definition at line 141 of file Updatable.hpp.

◆ moveDown()

template<class Derived >
void moveDown ( )
inline

Move down this element in the list.

Definition at line 147 of file Updatable.hpp.

Member Data Documentation

◆ updatables

template<class Derived >
DoublyLinkedList< Derived > updatables
staticprotected

Definition at line 152 of file Updatable.hpp.

◆ next

Derived * next
protectedinherited

Definition at line 320 of file LinkedList.hpp.

◆ previous

Derived * previous
protectedinherited

Definition at line 321 of file LinkedList.hpp.


The documentation for this class was generated from the following file: