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 | |
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 ListPure< TObserver * > & | getObservers () const |
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... | |
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 Types | |
using | Obs = Observable< RegisteredObserver< Registry >, Registry > |
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 61 of file RegisteredArray.h.
using ogdf::RegistryBase< Key, Registry, Iterator >::iterator_type = Iterator |
Definition at line 144 of file RegisteredArray.h.
using ogdf::RegistryBase< Key, Registry, Iterator >::key_type = Key |
Definition at line 142 of file RegisteredArray.h.
|
private |
Definition at line 150 of file RegisteredArray.h.
using ogdf::RegistryBase< Key, Registry, Iterator >::registered_array_type = internal::RegisteredArrayBase<Registry> |
Definition at line 141 of file RegisteredArray.h.
using ogdf::RegistryBase< Key, Registry, Iterator >::registration_iterator_type = typename registration_list_type::iterator |
Definition at line 147 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 146 of file RegisteredArray.h.
using ogdf::RegistryBase< Key, Registry, Iterator >::registry_type = Registry |
Definition at line 143 of file RegisteredArray.h.
|
protecteddefault |
|
inlinevirtualnoexcept |
Destructor. Unregisters all associated arrays.
Definition at line 165 of file RegisteredArray.h.
|
inline |
Copies the entry from fromIndex
to toIndex
in all registered arrays.
Definition at line 264 of file RegisteredArray.h.
|
inline |
Returns the current size of all registered arrays.
Definition at line 294 of file RegisteredArray.h.
|
inline |
Definition at line 206 of file Observer.h.
|
inline |
Returns a reference to the list of all registered arrays.
Definition at line 285 of file RegisteredArray.h.
|
inline |
Returns whether the registry allows arrays to shrink when keys are removed.
Definition at line 288 of file RegisteredArray.h.
|
inline |
Records the addition of a new key and resizes all registered arrays if necessary.
Definition at line 203 of file RegisteredArray.h.
|
inline |
Records the deletion of a key and resizes all registered arrays if auto shrink is enabled.
Definition at line 213 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 223 of file RegisteredArray.h.
|
inline |
Stores array pArray
at position it
in the list of registered arrays.
Definition at line 195 of file RegisteredArray.h.
|
inline |
Registers a new array with this registry.
pArray | A pointer to the registered array. |
Definition at line 176 of file RegisteredArray.h.
|
inline |
Resizes all arrays to make space of new_keys
new keys.
Definition at line 249 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 232 of file RegisteredArray.h.
|
inline |
Resizes all arrays to size
. Only shrinks the arrays if auto shrink is enabled.
Definition at line 235 of file RegisteredArray.h.
|
inline |
Resizes all arrays to size
. If shrink
is true
, the arrays may also shrink.
Definition at line 238 of file RegisteredArray.h.
|
inline |
Specifies whether the registry allows arrays to shrink when keys are removed.
Definition at line 291 of file RegisteredArray.h.
|
inline |
Swaps the entries at index1
and index2
in all registered arrays.
Definition at line 254 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 187 of file RegisteredArray.h.
|
inlinenoexcept |
Unregister all associated arrays.
Definition at line 274 of file RegisteredArray.h.
|
private |
Definition at line 153 of file RegisteredArray.h.
|
mutableprivate |
Definition at line 157 of file RegisteredArray.h.
|
mutableprivate |
Definition at line 152 of file RegisteredArray.h.
|
private |
Definition at line 154 of file RegisteredArray.h.