Magnum::Ui::DataLayer class new in Git master

Data binding layer.

Setting up a data layer instance

If you create a UserInterfaceGL with a theme and don't exclude ThemeFeature::DataLayer, an implicit instance is already provided and available through UserInterface::dataLayer(). Otherwise, the layer doesn't have any shared state or configuration, so it's just about constructing it from a fresh AbstractUserInterface::createLayer() handle and passing it to UserInterface::setDataLayerInstance():

ui.setDataLayerInstance(Containers::pointer<Ui::DataLayer>(ui.createLayer()));

In comparison, if you want to set up a custom data layer that's independent of the one exposed through UserInterface::dataLayer(), pass the newly created instance to AbstractUserInterface::setLayerInstance() instead:

Ui::DataLayer& layer = ui.setLayerInstance(
    Containers::pointer<Ui::DataLayer>(ui.createLayer()));

Afterwards, with either of the above, assuming AbstractUserInterface::draw() is called in an appropriate place, the layer is ready to use.

Base classes

class AbstractLayer new in Git master
Base for data layers.

Constructors, destructors, conversion operators

DataLayer(LayerHandle handle) explicit
Constructor.
DataLayer(const DataLayer&) deleted
Copying is not allowed.
DataLayer(DataLayer&&) noexcept
Move constructor.

Public functions

auto operator=(const DataLayer&) -> DataLayer& deleted
Copying is not allowed.
auto operator=(DataLayer&&) -> DataLayer& noexcept
Move assignment.
auto usedAllocatedCount() const -> std::size_t
Count of allocated data update functions.
template<class T>
auto onUpdate(const StorageQuery<T>& query, Containers::Function<void(const T&value)>&& function, NodeHandle node = NodeHandle::Null) -> DataHandle
Bind a function to storage data update.
template<class T>
auto onUpdate(const StorageQuery<T>& query, Containers::Function<void(T value)>&& function, NodeHandle node = NodeHandle::Null) -> DataHandle
template<class T>
auto onUpdate(const StorageQuery<T>& query, Containers::Function<void(T value, T min, T max)>&& function, NodeHandle node = NodeHandle::Null) -> DataHandle
Bind a function to storage data update along with min/max values.
template<class T>
auto onUpdate(const StorageQuery<T>& query, Containers::Function<void(DataHandle handle, const T&value)>&& function, NodeHandle node = NodeHandle::Null) -> DataHandle
Bind a function to storage data update along with the data handle itself.
template<class T>
auto onUpdate(const StorageQuery<T>& query, Containers::Function<void(DataHandle handle, T value)>&& function, NodeHandle node = NodeHandle::Null) -> DataHandle
template<class Storage>
auto onUpdate(const Storage& storage, Containers::Function<void(const typename Storage::Type&value)>&& function, NodeHandle node = NodeHandle::Null) -> DataHandle
Bind a function to storage's implicit data update.
template<class Storage>
auto onUpdate(const Storage& storage, Containers::Function<void(typename Storage::Type value)>&& function, NodeHandle node = NodeHandle::Null) -> DataHandle
template<class Storage>
auto onUpdate(const Storage& storage, Containers::Function<void(typename Storage::Type value, typename Storage::Type min, typename Storage::Type max)>&& function, NodeHandle node = NodeHandle::Null) -> DataHandle
template<class Storage>
auto onUpdate(const Storage& storage, Containers::Function<void(DataHandle, const typename Storage::Type&value)>&& function, NodeHandle node = NodeHandle::Null) -> DataHandle
template<class Storage>
auto onUpdate(const Storage& storage, Containers::Function<void(DataHandle, typename Storage::Type value)>&& function, NodeHandle node = NodeHandle::Null) -> DataHandle
void remove(DataHandle handle)
Remove a data.
void remove(LayerDataHandle handle)
Remove an animation assuming it belongs to this animator.
auto isAllocated(DataHandle handle) const -> bool
Whether given data update function is allocated.
auto isAllocated(LayerDataHandle handle) const -> bool
Whether given data update function is allocated assuming it belongs to this layer.
auto isDirty(DataHandle handle) const -> bool
Whether given data is marked as dirty.
auto isDirty(LayerDataHandle handle) const -> bool
Whether given data is marked as dirty assuming it belongs to this layer.
void setDirty(DataHandle handle)
Mark given data as dirty.
void setDirty(LayerDataHandle handle)
Mark given data as dirty assuming it belongs to this layer.
auto storage(DataHandle handle) const -> StorageHandle
Storage given data is associated with.
auto storage(LayerDataHandle handle) const -> StorageHandle
Storage given data is associated with assuming it belongs to this layer.
auto index(DataHandle handle) const -> Containers::Size3D
Index of data in associated storage.
auto index(LayerDataHandle handle) const -> Containers::Size3D
Index of data in associated storage assuming it belongs to this layer.
void setIndex(DataHandle handle, std::size_t index)
Set data index in associated 1D storage.
void setIndex(LayerDataHandle handle, std::size_t index)
Set data index in associated 1D storage assuming it belongs to this layer.
void setIndex(DataHandle handle, const Containers::Size2D& index)
Set data index in associated 2D storage.
void setIndex(LayerDataHandle handle, const Containers::Size2D& index)
Set data index in associated 2D storage assuming it belongs to this layer.
void setIndex(DataHandle handle, const Containers::Size3D& index)
Set data index in associated 3D storage.
void setIndex(LayerDataHandle handle, const Containers::Size3D& index)
Set data index in associated 3D storage assuming it belongs to this layer.
auto isMutable(DataHandle handle) const -> bool
Whether given data binding is mutable.
auto isMutable(LayerDataHandle handle) const -> bool
Whether given data binding is mutable assuming it belongs to this layer.
auto operations(DataHandle handle) const -> StorageOperations
Available data binding operations.
auto operations(LayerDataHandle handle) const -> StorageOperations
Available data binding operations assuming it belongs to this layer.
template<class T>
auto set(DataHandle handle, const T& value) -> StorageUpdateState
Update the storage value for given data binding.
template<class T>
auto set(LayerDataHandle handle, const T& value) -> StorageUpdateState
Update the storage value for given data binding assuming it belongs to this layer.
void reset(DataHandle handle)
Reset the storage value for given data binding.
void reset(LayerDataHandle handle)
Reset the storage value for given data binding assuming it belongs to this layer.
void toggle(DataHandle handle)
Toggle the storage value for given data binding.
void toggle(LayerDataHandle handle)
Toggle the storage value for given data binding assuming it belongs to this layer.
void increment(DataHandle handle)
Increment the storage value for given data binding.
void increment(LayerDataHandle handle)
Increment the storage value for given data binding assuming it belongs to this layer.
void decrement(DataHandle handle)
Decrement the storage value for given data binding.
void decrement(LayerDataHandle handle)
Decrement the storage value for given data binding assuming it belongs to this layer.
void setToMin(DataHandle handle)
Set the storage value to a minimum for given data binding.
void setToMin(LayerDataHandle handle)
Set the storage value to a minimum for given data binding assuming it belongs to this layer.
void setToMax(DataHandle handle)
Set the storage value to a maximum for given data binding.
void setToMax(LayerDataHandle handle)
Set the storage value to a maximum for given data binding assuming it belongs to this layer.

Storage management

auto storageCapacity() const -> std::size_t
Current capacity of the storage storage.
auto storageUsedCount() const -> std::size_t
Count of used items in the storage storage.
auto storageUsedAllocatedCount() const -> std::size_t
Count of used allocated items in the storage storage.
auto isHandleValid(DataLayerStorageHandle handle) const -> bool
Whether a storage handle is valid.
auto isHandleValid(StorageHandle handle) const -> bool
Whether a storage handle is valid.
void removeStorage(StorageHandle handle)
Remove a storage.
void removeStorage(DataLayerStorageHandle handle)
Remove a storage assuming it belongs to this layer.
auto isStorageAllocated(StorageHandle handle) const -> bool
Whether given storage is allocated.
auto isStorageAllocated(DataLayerStorageHandle handle) const -> bool
Whether given storage is allocated assuming it belongs to this layer.
auto isStorageDirty(StorageHandle handle) const -> bool
Whether given storage is marked as dirty.
auto isStorageDirty(DataLayerStorageHandle handle) const -> bool
Whether given storage is marked as dirty assuming it belongs to this layer.
void setStorageDirty(StorageHandle handle)
Mark given storage as dirty.
void setStorageDirty(DataLayerStorageHandle handle)
Mark given storage as dirty assuming it belongs to this layer.
auto storageFlags(StorageHandle handle) const -> StorageFlags
Storage flags.
auto storageFlags(DataLayerStorageHandle handle) const -> StorageFlags
Storage flags assuming it belongs to this layer.
auto storageSize(StorageHandle handle) const -> Containers::Size3D
Storage size.
auto storageSize(DataLayerStorageHandle handle) const -> Containers::Size3D
Storage size assuming it belongs to this layer.
auto storageReferenceCount(StorageHandle handle) const -> std::size_t
Storage reference count.
auto storageReferenceCount(DataLayerStorageHandle handle) const -> std::size_t
Storage reference count assuming it belongs to this layer.
template<class Storage>
auto storage(StorageHandle handle) -> Storage
Storage access.
template<class Storage>
auto storage(DataLayerStorageHandle handle) -> Storage
Storage access assuming it belongs to this layer.
auto storageGenerations() const -> Containers::StridedArrayView1D<const UnsignedShort>
Generation counters for all storages.
auto isHandleValid(LayerDataHandle handle) const -> bool
Whether a data handle is valid.
auto isHandleValid(DataHandle handle) const -> bool
Whether a data handle is valid.

Function documentation

Magnum::Ui::DataLayer::DataLayer(LayerHandle handle) explicit

Constructor.

Parameters
handle Layer handle returned from AbstractUserInterface::createLayer()

Magnum::Ui::DataLayer::DataLayer(DataLayer&&) noexcept

Move constructor.

Performs a destructive move, i.e. the original object isn't usable afterwards anymore.

std::size_t Magnum::Ui::DataLayer::usedAllocatedCount() const

Count of allocated data update functions.

Always at most usedCount(). Counts all data update functions that capture non-trivially-copyable state or state that's too large to be stored in-place. The operation is done with a $ \mathcal{O}(n) $ complexity where $ n $ is capacity().

template<class T>
DataHandle Magnum::Ui::DataLayer::onUpdate(const StorageQuery<T>& query, Containers::Function<void(const T&value)>&& function, NodeHandle node = NodeHandle::Null)

Bind a function to storage data update.

Parameters
query Storage query
function Function to call when data get updated
node Node to attach to
Returns New data handle

Expects that query references a valid storage from this layer and function is not nullptr. The function gets called with the result of query with AbstractUserInterface::update() or draw() whenever either the data itself or the storage is marked as dirty. The data is marked as dirty initially.

Delegates to AbstractLayer::create(), see its documentation for detailed description of all constraints. Calling this function causes LayerState::NeedsCommonDataUpdate to be set.

template<class T>
DataHandle Magnum::Ui::DataLayer::onUpdate(const StorageQuery<T>& query, Containers::Function<void(T value)>&& function, NodeHandle node = NodeHandle::Null)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T>
DataHandle Magnum::Ui::DataLayer::onUpdate(const StorageQuery<T>& query, Containers::Function<void(T value, T min, T max)>&& function, NodeHandle node = NodeHandle::Null)

Bind a function to storage data update along with min/max values.

Parameters
query Storage query
function Function to call when data get updated
node Node to attach to
Returns New data handle

Expects that query references a valid storage from this layer, StorageQuery::operations() includes StorageOperation::Min and Max and function is not nullptr. The function gets called with the result of query along with min and max values with AbstractUserInterface::update() or draw() whenever either the data itself or the storage is marked as dirty. The data is marked as dirty initially.

Delegates to AbstractLayer::create(), see its documentation for detailed description of all constraints. Calling this function causes LayerState::NeedsCommonDataUpdate to be set.

template<class T>
DataHandle Magnum::Ui::DataLayer::onUpdate(const StorageQuery<T>& query, Containers::Function<void(DataHandle handle, const T&value)>&& function, NodeHandle node = NodeHandle::Null)

Bind a function to storage data update along with the data handle itself.

Parameters
query Storage query
function Function to call when data get updated
node Node to attach to
Returns New data handle

Like onUpdate(const StorageQuery<T>&, Containers::Function<void(const T& value)>&&, NodeHandle) but with the function additionally taking the DataHandle of the binding itself, allowing it to query additional properties of the data or its associated storage. The handle is guaranteed to be valid in this layer. See documentation of onUpdate(const StorageQuery<T>&, Containers::Function<void(const T& value)>&&, NodeHandle) for more information.

template<class T>
DataHandle Magnum::Ui::DataLayer::onUpdate(const StorageQuery<T>& query, Containers::Function<void(DataHandle handle, T value)>&& function, NodeHandle node = NodeHandle::Null)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class Storage>
DataHandle Magnum::Ui::DataLayer::onUpdate(const Storage& storage, Containers::Function<void(const typename Storage::Type&value)>&& function, NodeHandle node = NodeHandle::Null)

Bind a function to storage's implicit data update.

Assuming the storage has a Type typedef which denotes what StorageQuery type the storage is implicitly convertible to, delegates to onUpdate(const StorageQuery<T>&, Containers::Function<void(const T& value)>&&, NodeHandle) and overloads with given type. See their documentation for more information.

template<class Storage>
DataHandle Magnum::Ui::DataLayer::onUpdate(const Storage& storage, Containers::Function<void(typename Storage::Type value)>&& function, NodeHandle node = NodeHandle::Null)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class Storage>
DataHandle Magnum::Ui::DataLayer::onUpdate(const Storage& storage, Containers::Function<void(typename Storage::Type value, typename Storage::Type min, typename Storage::Type max)>&& function, NodeHandle node = NodeHandle::Null)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class Storage>
DataHandle Magnum::Ui::DataLayer::onUpdate(const Storage& storage, Containers::Function<void(DataHandle, const typename Storage::Type&value)>&& function, NodeHandle node = NodeHandle::Null)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class Storage>
DataHandle Magnum::Ui::DataLayer::onUpdate(const Storage& storage, Containers::Function<void(DataHandle, typename Storage::Type value)>&& function, NodeHandle node = NodeHandle::Null)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

void Magnum::Ui::DataLayer::remove(DataHandle handle)

Remove a data.

Expects that handle is valid. Calls a destructor on the captured update function state, if it's not trivially destructible, and decrements reference count on the storage the data was associated with. Delegates to AbstractLayer::remove(DataHandle), see its documentation for detailed description of all constraints.

If the storage the handle was associated with is StorageFlag::ReferenceCounted and its reference count becomes 0 by calling this function, causes LayerState::NeedsCommonDataUpdate to be set on the layer in addition to what AbstractLayer::remove() may have set.

void Magnum::Ui::DataLayer::remove(LayerDataHandle handle)

Remove an animation assuming it belongs to this animator.

Compared to remove(DataHandle) delegates to AbstractLayer::remove(LayerDataHandle) instead.

bool Magnum::Ui::DataLayer::isAllocated(DataHandle handle) const

Whether given data update function is allocated.

Returns true if the update function in given data captures non-trivially-copyable state or state that's too large to be stored in-place, false otherwise. Expects that handle is valid.

bool Magnum::Ui::DataLayer::isAllocated(LayerDataHandle handle) const

Whether given data update function is allocated assuming it belongs to this layer.

Like isAllocated(DataHandle) const but without checking that handle indeed belongs to this layer. See its documentation for more information.

bool Magnum::Ui::DataLayer::isDirty(DataHandle handle) const

Whether given data is marked as dirty.

Returns true if the data update function will be called in the next AbstractUserInterface::update() or draw(), false otherwise. Expects that handle is valid.

All data are marked as dirty upon creation in order to have the update function called at least once, and the dirty bits is reset in the next AbstractUserInterface::update() or draw(). Afterwards, they're themselves marked as dirty only if their properties change such as when setIndex() is called, and there's no way to mark them as dirty explicitly. All other cases where the update function is called are driven by dirty state of the associated storage.

bool Magnum::Ui::DataLayer::isDirty(LayerDataHandle handle) const

Whether given data is marked as dirty assuming it belongs to this layer.

Like isDirty(DataHandle) const but without checking that handle indeed belongs to this layer. See its documentation for more information.

void Magnum::Ui::DataLayer::setDirty(DataHandle handle)

Mark given data as dirty.

Calling this function causes the update function for given data to be called in the next AbstractUserInterface::update() or draw(). Expects that handle is valid. Compared to setStorageDirty(), which affects all data associated with given storage, marking just a single data dirty is useful for example when previous updates were skipped for some reason and the storage itself didn't get dirty since.

Calling this function causes LayerState::NeedsCommonDataUpdate to be set.

void Magnum::Ui::DataLayer::setDirty(LayerDataHandle handle)

Mark given data as dirty assuming it belongs to this layer.

Like setDirty(DataHandle) but without checking that handle indeed belongs to this layer. See its documentation for more information.

StorageHandle Magnum::Ui::DataLayer::storage(DataHandle handle) const

Storage given data is associated with.

Expects that handle is valid. The returned storage handle is always valid and belongs to this layer.

StorageHandle Magnum::Ui::DataLayer::storage(LayerDataHandle handle) const

Storage given data is associated with assuming it belongs to this layer.

Like storage(DataHandle) const but without checking that handle indeed belongs to this layer. See its documentation for more information.

Containers::Size3D Magnum::Ui::DataLayer::index(DataHandle handle) const

Index of data in associated storage.

Expects that handle is valid. If the data was created without specifying an index, with a 1D index or with a 2D index, returns 0 in remaining leading dimensions. For example, if the data was created with a 2D index of {3, 7}, the returned 3D index is going to be {0, 3, 7}.

Containers::Size3D Magnum::Ui::DataLayer::index(LayerDataHandle handle) const

Index of data in associated storage assuming it belongs to this layer.

Like index(DataHandle) const but without checking that handle indeed belongs to this layer. See its documentation for more information.

void Magnum::Ui::DataLayer::setIndex(DataHandle handle, std::size_t index)

Set data index in associated 1D storage.

Expects that handle is valid, size of associated storage is {1, 1, size} and index is less than size. Use setIndex(DataHandle, const Containers::Size2D&) for setting a data index in a 2D storage and setIndex(DataHandle, const Containers::Size3D&) for setting an index in a 3D storage.

If the index is different from the previously used index, calling this function causes the data to be marked as dirty and LayerState::NeedsCommonDataUpdate to be set.

void Magnum::Ui::DataLayer::setIndex(LayerDataHandle handle, std::size_t index)

Set data index in associated 1D storage assuming it belongs to this layer.

Like setIndex(DataHandle, std::size_t) but without checking that handle indeed belongs to this layer. See its documentation for more information.

void Magnum::Ui::DataLayer::setIndex(DataHandle handle, const Containers::Size2D& index)

Set data index in associated 2D storage.

Expects that handle is valid, size of associated storage is {1, size[0], size[1]} and index is less than size. Use setIndex(DataHandle, const Containers::Size3D&) for setting a data index in a 3D storage.

If the index is different from the previously used index, calling this function causes the data to be marked as dirty and LayerState::NeedsCommonDataUpdate to be set.

void Magnum::Ui::DataLayer::setIndex(LayerDataHandle handle, const Containers::Size2D& index)

Set data index in associated 2D storage assuming it belongs to this layer.

Like setIndex(DataHandle, const Containers::Size2D&) but without checking that handle indeed belongs to this layer. See its documentation for more information.

void Magnum::Ui::DataLayer::setIndex(DataHandle handle, const Containers::Size3D& index)

Set data index in associated 3D storage.

Expects that handle is valid and index is less than size of the associated storage.

If the index is different from the previously used index, calling this function causes the data to be marked as dirty and LayerState::NeedsCommonDataUpdate to be set.

void Magnum::Ui::DataLayer::setIndex(LayerDataHandle handle, const Containers::Size3D& index)

Set data index in associated 3D storage assuming it belongs to this layer.

Like setIndex(DataHandle, const Containers::Size3D&) but without checking that handle indeed belongs to this layer. See its documentation for more information.

bool Magnum::Ui::DataLayer::isMutable(DataHandle handle) const

Whether given data binding is mutable.

Expects that handle is valid. Mutable queries allow set(), reset(), toggle(), increment(), decrement(), setToMin() and setToMax() to be called based on which operations() are available. Immutable queries allow only getting the current value through onUpdate(), potentially along with min / max if operations() expose them.

bool Magnum::Ui::DataLayer::isMutable(LayerDataHandle handle) const

Whether given data binding is mutable assuming it belongs to this layer.

Like isMutable(DataHandle) const but without checking that handle indeed belongs to this layer. See its documentation for more information.

StorageOperations Magnum::Ui::DataLayer::operations(DataHandle handle) const

Available data binding operations.

Expects that handle is valid.

StorageOperations Magnum::Ui::DataLayer::operations(LayerDataHandle handle) const

Available data binding operations assuming it belongs to this layer.

Like operations(DataHandle) const but without checking that handle indeed belongs to this layer. See its documentation for more information.

template<class T>
StorageUpdateState Magnum::Ui::DataLayer::set(DataHandle handle, const T& value)

Update the storage value for given data binding.

Expects that handle is valid, mutable and operations() list StorageOperation::Set. It's the user responsibility to ensure that T matches the StorageQuery type that was passed to onUpdate() the handle is coming from.

Calling this function causes the storage to get marked as dirty and LayerState::NeedsCommonDataUpdate to be set if the stored value actually changed.

template<class T>
StorageUpdateState Magnum::Ui::DataLayer::set(LayerDataHandle handle, const T& value)

Update the storage value for given data binding assuming it belongs to this layer.

Like set(DataHandle, const T&) but without checking that handle indeed belongs to this layer. See its documentation for more information.

void Magnum::Ui::DataLayer::reset(DataHandle handle)

Reset the storage value for given data binding.

Expects that handle is valid, mutable and operations() list StorageOperation::Reset.

Calling this function causes the storage to get marked as dirty and LayerState::NeedsCommonDataUpdate to be set if the stored value actually changed.

void Magnum::Ui::DataLayer::reset(LayerDataHandle handle)

Reset the storage value for given data binding assuming it belongs to this layer.

Like reset(DataHandle) but without checking that handle indeed belongs to this layer. See its documentation for more information.

void Magnum::Ui::DataLayer::toggle(DataHandle handle)

Toggle the storage value for given data binding.

Expects that handle is valid, mutable and operations() list StorageOperation::Toggle.

Calling this function causes the storage to get marked as dirty and LayerState::NeedsCommonDataUpdate to be set if the stored value actually changed.

void Magnum::Ui::DataLayer::toggle(LayerDataHandle handle)

Toggle the storage value for given data binding assuming it belongs to this layer.

Like toggle(DataHandle) but without checking that handle indeed belongs to this layer. See its documentation for more information.

void Magnum::Ui::DataLayer::increment(DataHandle handle)

Increment the storage value for given data binding.

Expects that handle is valid, mutable and operations() list StorageOperation::Increment.

Calling this function causes the storage to get marked as dirty and LayerState::NeedsCommonDataUpdate to be set if the stored value actually changed.

void Magnum::Ui::DataLayer::increment(LayerDataHandle handle)

Increment the storage value for given data binding assuming it belongs to this layer.

Like increment(DataHandle) but without checking that handle indeed belongs to this layer. See its documentation for more information.

void Magnum::Ui::DataLayer::decrement(DataHandle handle)

Decrement the storage value for given data binding.

Expects that handle is valid, mutable and operations() list StorageOperation::Decrement.

Calling this function causes the storage to get marked as dirty and LayerState::NeedsCommonDataUpdate to be set if the stored value actually changed.

void Magnum::Ui::DataLayer::decrement(LayerDataHandle handle)

Decrement the storage value for given data binding assuming it belongs to this layer.

Like decrement(DataHandle) but without checking that handle indeed belongs to this layer. See its documentation for more information.

void Magnum::Ui::DataLayer::setToMin(DataHandle handle)

Set the storage value to a minimum for given data binding.

Expects that handle is valid, mutable and operations() list StorageOperation::Min. Note that unlike with StorageQuery::min() there's no way to query the minimum allowed value from the DataLayer — instead use onUpdate(const StorageQuery<T>&, Containers::Function<void(T value, T min, T max)>&&, NodeHandle) to have the min and max value passed to the data binding on update.

Calling this function causes the storage to get marked as dirty and LayerState::NeedsCommonDataUpdate to be set on the layer if appropriate.

void Magnum::Ui::DataLayer::setToMin(LayerDataHandle handle)

Set the storage value to a minimum for given data binding assuming it belongs to this layer.

Like setToMin(DataHandle) but without checking that handle indeed belongs to this layer. See its documentation for more information.

void Magnum::Ui::DataLayer::setToMax(DataHandle handle)

Set the storage value to a maximum for given data binding.

Expects that handle is valid, mutable and operations() list StorageOperation::Max. Note that unlike with StorageQuery::max() there's no way to query the maximum allowed value from the DataLayer — instead use onUpdate(const StorageQuery<T>&, Containers::Function<void(T value, T min, T max)>&&, NodeHandle) to have the min and max value passed to the data binding on update.

Calling this function causes the storage to get marked as dirty and LayerState::NeedsCommonDataUpdate to be set on the layer if appropriate.

void Magnum::Ui::DataLayer::setToMax(LayerDataHandle handle)

Set the storage value to a maximum for given data binding assuming it belongs to this layer.

Like setToMax(DataHandle) but without checking that handle indeed belongs to this layer. See its documentation for more information.

std::size_t Magnum::Ui::DataLayer::storageCapacity() const

Current capacity of the storage storage.

Can be at most 1048576. If an AbstractStorage subclass instance is constructed and there's no free slots left, the internal storage gets grown.

std::size_t Magnum::Ui::DataLayer::storageUsedCount() const

Count of used items in the storage storage.

Always at most storageCapacity(). Expired handles are counted among used as well. The operation is done with a $ \mathcal{O}(n) $ complexity where $ n $ is storageCapacity().

std::size_t Magnum::Ui::DataLayer::storageUsedAllocatedCount() const

Count of used allocated items in the storage storage.

Always at most storageUsedCount(). Counts all storages that have non-trivially-copyable state or state that's too large to be stored in-place. The operation is done with a $ \mathcal{O}(n) $ complexity where $ n $ is storageCapacity().

bool Magnum::Ui::DataLayer::isHandleValid(DataLayerStorageHandle handle) const

Whether a storage handle is valid.

A handle is valid if it has been created via an AbstractStorage subclass constructor and removeStorage() wasn't called on it yet. For DataLayerStorageHandle::Null always returns false.

bool Magnum::Ui::DataLayer::isHandleValid(StorageHandle handle) const

Whether a storage handle is valid.

A shorthand for extracting a LayerHandle from handle using storageHandleLayer(), comparing it to handle() and if it's the same, calling isHandleValid(DataLayerStorageHandle) const with a DataLayerStorageHandle extracted from handle using storageHandleStorage(). See these functions for more information. For StorageHandle::Null, LayerHandle::Null or DataLayerStorageHandle::Null always returns false.

void Magnum::Ui::DataLayer::removeStorage(StorageHandle handle)

Remove a storage.

Expects that handle is valid and the storage isn't referenced by any data. Calls a deleter on the storage if it's allocated.

void Magnum::Ui::DataLayer::removeStorage(DataLayerStorageHandle handle)

Remove a storage assuming it belongs to this layer.

Like removeStorage(StorageHandle) but without checking that handle indeed belongs to this layer. See its documentation for more information.

bool Magnum::Ui::DataLayer::isStorageAllocated(StorageHandle handle) const

Whether given storage is allocated.

Returns true if given storage has a non-trivially-copyable type or its size is too large to be stored in-place, false otherwise. Expects that handle is valid.

bool Magnum::Ui::DataLayer::isStorageAllocated(DataLayerStorageHandle handle) const

Whether given storage is allocated assuming it belongs to this layer.

Like isStorageAllocated(StorageHandle) const but without checking that handle indeed belongs to this layer. See its documentation for more information.

bool Magnum::Ui::DataLayer::isStorageDirty(StorageHandle handle) const

Whether given storage is marked as dirty.

Returns true if data update functions for given storage will be called in the next AbstractUserInterface::update() or draw(), false otherwise. Expects that handle is valid.

The storage is not marked as dirty upon creation, the data themselves however are marked as dirty when created in order to have their update function called at least once.

bool Magnum::Ui::DataLayer::isStorageDirty(DataLayerStorageHandle handle) const

Whether given storage is marked as dirty assuming it belongs to this layer.

Like isStorageDirty(StorageHandle) const but without checking that handle indeed belongs to this layer. See its documentation for more information.

void Magnum::Ui::DataLayer::setStorageDirty(StorageHandle handle)

Mark given storage as dirty.

Calling this function causes update functions for data associated with this storage to be called in the next AbstractUserInterface::update() or draw(). Expects that handle is valid. See also setDirty() which can be used to force an update of just a single data.

Calling this function causes LayerState::NeedsCommonDataUpdate to be set, unless the storage has a zero reference count and thus no update functions need to be called.

void Magnum::Ui::DataLayer::setStorageDirty(DataLayerStorageHandle handle)

Mark given storage as dirty assuming it belongs to this layer.

Like setStorageDirty(StorageHandle) but without checking that handle indeed belongs to this layer. See its documentation for more information.

StorageFlags Magnum::Ui::DataLayer::storageFlags(StorageHandle handle) const

Storage flags.

Expects that handle is valid.

StorageFlags Magnum::Ui::DataLayer::storageFlags(DataLayerStorageHandle handle) const

Storage flags assuming it belongs to this layer.

Like storageFlags(StorageHandle) const but without checking that handle indeed belongs to this layer. See its documentation for more information.

Containers::Size3D Magnum::Ui::DataLayer::storageSize(StorageHandle handle) const

Storage size.

Expects that handle is valid. If the storage was created without specifying a size, with a 1D size or with a 2D size, returns 1 in remaining leading dimensions. For example, if the storage was created with a 2D size of {4, 12}, the returned 3D size is going to be {1, 4, 12}.

Containers::Size3D Magnum::Ui::DataLayer::storageSize(DataLayerStorageHandle handle) const

Storage size assuming it belongs to this layer.

Like storageSize(StorageHandle) const but without checking that handle indeed belongs to this layer. See its documentation for more information.

std::size_t Magnum::Ui::DataLayer::storageReferenceCount(StorageHandle handle) const

Storage reference count.

Expects that handle is valid. Initially 0, is incremented after every onUpdate() call referencing given handle and decremented after every remove() of data referencing given handle, or when a node the data is attached to is removed along with all attachments. Can be at most usedCount(). It's only allowed to removeStorage() with a zero reference count.

std::size_t Magnum::Ui::DataLayer::storageReferenceCount(DataLayerStorageHandle handle) const

Storage reference count assuming it belongs to this layer.

Like storageReferenceCount(StorageHandle) const but without checking that handle indeed belongs to this layer. See its documentation for more information.

template<class Storage>
Storage Magnum::Ui::DataLayer::storage(StorageHandle handle)

Storage access.

Expects that handle is valid, it's user responsibility to ensure that Storage is matching the AbstractStorage subclass used for creating the storage with given handle.

Note that because the returned instance generally allows unconditionally mutating the storage contents, there's no const overload of this function.

template<class Storage>
Storage Magnum::Ui::DataLayer::storage(DataLayerStorageHandle handle)

Storage access assuming it belongs to this layer.

Like storage(StorageHandle) but without checking that handle indeed belongs to this layer. See its documentation for more information.

Containers::StridedArrayView1D<const UnsignedShort> Magnum::Ui::DataLayer::storageGenerations() const

Generation counters for all storages.

Meant to be used by code that only gets storage IDs or masks but needs the full handle, or for various diagnostic purposes such as tracking handle recycling. Size of the returned view is the same as storageCapacity(), individual items correspond to generations of particular storage IDs. All values fit into the StorageHandle / DataLayerStorageHandle generation bits, 0 denotes an expired generation counter.

Passing an ID along with the corresponding generation to dataLayerStorageHandle() produces a DataLayerStorageHandle, passing that along with handle() to storageHandle() produces a StorageHandle. Use isHandleValid(DataLayerStorageHandle) const / isHandleValid(StorageHandle) const to determine whether given slot is actually used.

bool Magnum::Ui::DataLayer::isHandleValid(LayerDataHandle handle) const

Whether a data handle is valid.

A handle is valid if it has been returned from create() before and remove() wasn't called on it yet. For LayerDataHandle::Null always returns false.

bool Magnum::Ui::DataLayer::isHandleValid(DataHandle handle) const

Whether a data handle is valid.

A shorthand for extracting a LayerHandle from handle using dataHandleLayer(), comparing it to handle() and if it's the same, calling isHandleValid(LayerDataHandle) const with a LayerDataHandle extracted from handle using dataHandleData(). See these functions for more information. For DataHandle::Null, LayerHandle::Null or LayerDataHandle::Null always returns false.