Abstract base class for registries. More...
#include <ogdf/basic/RegisteredArray.h>
Public Types | |
using | iterator_type = Iterator |
using | key_type = Key |
using | registered_array_type = internal::RegisteredArrayBase< Registry > |
using | registration_iterator_type = typename registration_list_type::iterator |
using | registration_list_type = std::list< registered_array_type *, OGDFAllocator< registered_array_type * > > |
using | registry_type = Registry |
Public Member Functions | |
RegistryBase (const RegistryBase ©)=delete | |
RegistryBase (RegistryBase &&move) noexcept=delete | |
virtual | ~RegistryBase () noexcept |
Destructor. Unregisters all associated arrays. More... | |
void | copyArrayEntries (int toIndex, int fromIndex) |
Copies the entry from fromIndex to toIndex in all registered arrays. More... | |
int | getArraySize () const |
Returns the current size of all registered arrays. More... | |
const registration_list_type & | getRegisteredArrays () const |
Returns a reference to the list of all registered arrays. More... | |
bool | isAutoShrink () const |
Returns whether the registry allows arrays to shrink when keys are removed. More... | |
void | keyAdded (Key key) |
Records the addition of a new key and resizes all registered arrays if necessary. More... | |
void | keyRemoved (Key key) |
Records the deletion of a key and resizes all registered arrays if auto shrink is enabled. More... | |
void | keysCleared () |
Records that all keys have been cleared. If auto shrink is enabled, all arrays are cleared and resized to 0. More... | |
void | moveRegisterArray (registration_iterator_type it, registered_array_type *pArray) const |
Stores array pArray at position it in the list of registered arrays. More... | |
RegistryBase & | operator= (const RegistryBase &other)=delete |
RegistryBase & | operator= (RegistryBase &&other) noexcept=delete |
OGDF_NODISCARD registration_iterator_type | registerArray (registered_array_type *pArray) const |
Registers a new array with this registry. More... | |
void | reserveSpace (int new_keys) |
Resizes all arrays to make space of new_keys new keys. More... | |
void | resizeArrays () |
Resizes all arrays to the size requested by calculateArraySize(). Only shrinks the arrays if auto shrink is enabled. More... | |
void | resizeArrays (int size) |
Resizes all arrays to size . Only shrinks the arrays if auto shrink is enabled. More... | |
void | resizeArrays (int size, bool shrink) |
Resizes all arrays to size . If shrink is true , the arrays may also shrink. More... | |
void | setAutoShrink (bool mAutoShrink) |
Specifies whether the registry allows arrays to shrink when keys are removed. More... | |
void | swapArrayEntries (int index1, int index2) |
Swaps the entries at index1 and index2 in all registered arrays. More... | |
void | unregisterArray (registration_iterator_type it) const noexcept |
Unregisters an array associated with this registry. More... | |
void | unregisterArrays () noexcept |
Unregister all associated arrays. More... | |
Protected Member Functions | |
RegistryBase ()=default | |
Private Attributes | |
bool | m_autoShrink = false |
std::mutex | m_mutexRegArrays |
registration_list_type | m_registeredArrays |
int | m_size = 0 |
Abstract base class for registries.
Defines the interface for event handling regarding the indexed keys. A registry manages one key type and stores all registered arrays associated with that key. It determines the new size of all registered arrays when keys are added or removed.
The following methods must be implemented by all subclasses as they are used via the CRTP:
Key | The key type the registry manages. |
Registry | The class that implements the interface defined in RegistryBase. |
Iterator | An iterator for all managed keys. Can be void if iterating the keys through the registered array is not required. To allow iterating over all keys, define begin() and end() methods. |
Definition at line 95 of file RegisteredArray.h.
using ogdf::RegistryBase< Key, Registry, Iterator >::iterator_type = Iterator |
Definition at line 100 of file RegisteredArray.h.
using ogdf::RegistryBase< Key, Registry, Iterator >::key_type = Key |
Definition at line 98 of file RegisteredArray.h.
using ogdf::RegistryBase< Key, Registry, Iterator >::registered_array_type = internal::RegisteredArrayBase<Registry> |
Definition at line 97 of file RegisteredArray.h.
using ogdf::RegistryBase< Key, Registry, Iterator >::registration_iterator_type = typename registration_list_type::iterator |
Definition at line 103 of file RegisteredArray.h.
using ogdf::RegistryBase< Key, Registry, Iterator >::registration_list_type = std::list<registered_array_type*, OGDFAllocator<registered_array_type*> > |
Definition at line 102 of file RegisteredArray.h.
using ogdf::RegistryBase< Key, Registry, Iterator >::registry_type = Registry |
Definition at line 99 of file RegisteredArray.h.
|
protecteddefault |
|
inlinevirtualnoexcept |
Destructor. Unregisters all associated arrays.
Definition at line 119 of file RegisteredArray.h.
|
delete |
|
deletenoexcept |
|
inline |
Copies the entry from fromIndex
to toIndex
in all registered arrays.
Definition at line 209 of file RegisteredArray.h.
|
inline |
Returns the current size of all registered arrays.
Definition at line 236 of file RegisteredArray.h.
|
inline |
Returns a reference to the list of all registered arrays.
Definition at line 227 of file RegisteredArray.h.
|
inline |
Returns whether the registry allows arrays to shrink when keys are removed.
Definition at line 230 of file RegisteredArray.h.
|
inline |
Records the addition of a new key and resizes all registered arrays if necessary.
Definition at line 162 of file RegisteredArray.h.
|
inline |
Records the deletion of a key and resizes all registered arrays if auto shrink is enabled.
Definition at line 169 of file RegisteredArray.h.
|
inline |
Records that all keys have been cleared. If auto shrink is enabled, all arrays are cleared and resized to 0.
Definition at line 176 of file RegisteredArray.h.
|
inline |
Stores array pArray
at position it
in the list of registered arrays.
Definition at line 154 of file RegisteredArray.h.
|
delete |
|
deletenoexcept |
|
inline |
Registers a new array with this registry.
pArray | A pointer to the registered array. |
Definition at line 135 of file RegisteredArray.h.
|
inline |
Resizes all arrays to make space of new_keys
new keys.
Definition at line 197 of file RegisteredArray.h.
|
inline |
Resizes all arrays to the size requested by calculateArraySize(). Only shrinks the arrays if auto shrink is enabled.
Definition at line 180 of file RegisteredArray.h.
|
inline |
Resizes all arrays to size
. Only shrinks the arrays if auto shrink is enabled.
Definition at line 183 of file RegisteredArray.h.
|
inline |
Resizes all arrays to size
. If shrink
is true
, the arrays may also shrink.
Definition at line 186 of file RegisteredArray.h.
|
inline |
Specifies whether the registry allows arrays to shrink when keys are removed.
Definition at line 233 of file RegisteredArray.h.
|
inline |
Swaps the entries at index1
and index2
in all registered arrays.
Definition at line 202 of file RegisteredArray.h.
|
inlinenoexcept |
Unregisters an array associated with this registry.
it | An iterator pointing to the entry of the array in the list of all registered arrays. |
Definition at line 146 of file RegisteredArray.h.
|
inlinenoexcept |
Unregister all associated arrays.
Definition at line 216 of file RegisteredArray.h.
|
private |
Definition at line 107 of file RegisteredArray.h.
|
mutableprivate |
Definition at line 111 of file RegisteredArray.h.
|
mutableprivate |
Definition at line 106 of file RegisteredArray.h.
|
private |
Definition at line 108 of file RegisteredArray.h.