template<class T>
Magnum::Ui::StorageQuery class new in Git master

DataLayer storage query

Returned from AbstractStorage implementations, meant to be passed to DataLayer::onUpdate() along with an update function.

Base classes

class AbstractStorageQuery new in Git master
Base for DataLayer storage queries.

Constructors, destructors, conversion operators

template<class Storage>
StorageQuery(const Storage& storage, StorageOperations operations, T(*)(const Storage&storage, StorageOperation operation) query, StorageUpdateState(*)(const Storage&storage, StorageOperation operation, const T*value) updater = nullptr)
Create a query to a single-item storage.
template<class Storage>
StorageQuery(const Storage& storage, std::size_t index, StorageOperations operations, T(*)(const Storage&storage, std::size_t index, StorageOperation operation) query, StorageUpdateState(*)(const Storage&storage, std::size_t index, StorageOperation operation, const T*value) updater = nullptr)
Create a query to a 1D storage.
template<class Storage>
StorageQuery(const Storage& storage, const Containers::Size1D& index, StorageOperations operations, T(*)(const Storage&storage, const Containers::Size1D&index, StorageOperation operation) query, StorageUpdateState(*)(const Storage&storage, const Containers::Size1D&index, StorageOperation operation, const T*value) updater = nullptr)
Create a query to a 1D storage.
template<class Storage>
StorageQuery(const Storage& storage, const Containers::Size2D& index, StorageOperations operations, T(*)(const Storage&storage, const Containers::Size2D&index, StorageOperation operation) query, StorageUpdateState(*)(const Storage&storage, const Containers::Size2D&index, StorageOperation operation, const T*value) updater = nullptr)
Create a query to a 2D storage.
template<class Storage>
StorageQuery(const Storage& storage, const Containers::Size3D& index, StorageOperations operations, T(*)(const Storage&storage, const Containers::Size3D&index, StorageOperation operation) query, StorageUpdateState(*)(const Storage&storage, const Containers::Size3D&index, StorageOperation operation, const T*value) updater = nullptr)
Create a query to a 3D storage.
operator T() const
Storage value.

Public functions

auto set(const T& value) const -> StorageUpdateState
Update the storage value.
auto min() const -> T
Minimum allowed storage value.
auto max() const -> T
Maximum allowed storage value.

Function documentation

template<class T> template<class Storage>
Magnum::Ui::StorageQuery<T>::StorageQuery(const Storage& storage, StorageOperations operations, T(*)(const Storage&storage, StorageOperation operation) query, StorageUpdateState(*)(const Storage&storage, StorageOperation operation, const T*value) updater = nullptr)

Create a query to a single-item storage.

Parameters
storage Storage instance
operations Operations supported by query and updater
query Lambda to call on the storage to retrieve the desired value for given operation
updater Lambda to call to update the storage value based on supplied operation and value or nullptr if the storage isn't mutable.

Expects that storage is valid in the layer it's associated with and is single-item, i.e. with a size of {1, 1, 1}. The query and updater is expected to be a non-capturing lambda with given signature, not a function pointer.

The operations are expected to be set according to constraints specified in particular StorageOperation values. If operations contain StorageOperation::Min / Max, passing either of them to query should return a min / max allowed storage value, otherwise query is expected to return the currently stored value. If updater is not nullptr, operations are expected to be either empty or contain StorageOperation::Min / Max. The updater return value should follow StorageUpdateState value documentation.

template<class T> template<class Storage>
Magnum::Ui::StorageQuery<T>::StorageQuery(const Storage& storage, std::size_t index, StorageOperations operations, T(*)(const Storage&storage, std::size_t index, StorageOperation operation) query, StorageUpdateState(*)(const Storage&storage, std::size_t index, StorageOperation operation, const T*value) updater = nullptr)

Create a query to a 1D storage.

Parameters
storage Storage instance
index Value index to query
operations Operations supported by query and updater
query Lambda to call on the storage to retrieve the desired value for given operation
updater Lambda to call to update the storage value based on supplied operation and value or nullptr if the storage isn't mutable.

Expects that storage is valid in the layer it's associated with, is 1D, i.e. with a size of {1, 1, size}, and index is not larger than size. The query and updater is expected to be a non-capturing lambda with given signature, not a function pointer.

The operations are expected to be set according to constraints specified in particular StorageOperation values. If operations contain StorageOperation::Min / Max, passing either of them to query should return a min / max allowed storage value, otherwise query is expected to return the currently stored value. If updater is not nullptr, operations are expected to be either empty or contain StorageOperation::Min / Max. The updater return value should follow StorageUpdateState value documentation.

template<class T> template<class Storage>
Magnum::Ui::StorageQuery<T>::StorageQuery(const Storage& storage, const Containers::Size1D& index, StorageOperations operations, T(*)(const Storage&storage, const Containers::Size1D&index, StorageOperation operation) query, StorageUpdateState(*)(const Storage&storage, const Containers::Size1D&index, StorageOperation operation, const T*value) updater = nullptr)

Create a query to a 1D storage.

Same as StorageQuery(const Storage&, std::size_t, StorageOperations, T(*)(const Storage&, std::size_t, StorageOperation), StorageUpdateState(*)(const Storage&, std::size_t, StorageOperation, const T*)), just with Containers::Size1D instead of std::size_t as an index type to make it easier for generic storage implementations.

template<class T> template<class Storage>
Magnum::Ui::StorageQuery<T>::StorageQuery(const Storage& storage, const Containers::Size2D& index, StorageOperations operations, T(*)(const Storage&storage, const Containers::Size2D&index, StorageOperation operation) query, StorageUpdateState(*)(const Storage&storage, const Containers::Size2D&index, StorageOperation operation, const T*value) updater = nullptr)

Create a query to a 2D storage.

Parameters
storage Storage instance
index Value index to query
operations Operations supported by query and updater
query Lambda to call on the storage to retrieve the desired value for given operation
updater Lambda to call to update the storage value based on supplied operation and value or nullptr if the storage isn't mutable.

Expects that storage is valid in the layer it's associated with, is 2D, i.e. with a size of {1, size[0], size[1]}, and index is not larger than size. The query and updater is expected to be a non-capturing lambda with given signature, not a function pointer.

The operations are expected to be set according to constraints specified in particular StorageOperation values. If operations contain StorageOperation::Min / Max, passing either of them to query should return a min / max allowed storage value, otherwise query is expected to return the currently stored value. If updater is not nullptr, operations are expected to be either empty or contain StorageOperation::Min / Max. The updater return value should follow StorageUpdateState value documentation.

template<class T> template<class Storage>
Magnum::Ui::StorageQuery<T>::StorageQuery(const Storage& storage, const Containers::Size3D& index, StorageOperations operations, T(*)(const Storage&storage, const Containers::Size3D&index, StorageOperation operation) query, StorageUpdateState(*)(const Storage&storage, const Containers::Size3D&index, StorageOperation operation, const T*value) updater = nullptr)

Create a query to a 3D storage.

Parameters
storage Storage instance
index Value index to query
operations Operations supported by query and updater
query Lambda to call on the storage to retrieve the desired value for given operation
updater Lambda to call to update the storage value based on supplied operation and value or nullptr if the storage isn't mutable.

Expects that storage is valid in the layer it's associated with and index is not larger than storage size. The query and updater is expected to be a non-capturing lambda with given signature, not a function pointer.

The operations are expected to be set according to constraints specified in particular StorageOperation values. If operations contain StorageOperation::Min / Max, passing either of them to query should return a min / max allowed storage value, otherwise query is expected to return the currently stored value. If updater is not nullptr, operations are expected to be either empty or contain StorageOperation::Min / Max. The updater return value should follow StorageUpdateState value documentation.

template<class T>
Magnum::Ui::StorageQuery<T>::operator T() const

Storage value.

Returns value of given storage() at index(). Expects that storage() is still valid in the layer(). Meant to be used mainly for diagnostic purposes, for regular access prefer to access the storage data directly.

template<class T>
StorageUpdateState Magnum::Ui::StorageQuery<T>::set(const T& value) const

Update the storage value.

Expects that storage() is still valid in the layer() and operations() list StorageOperation::Set. The return value describes whether the update succeeded.

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

template<class T>
T Magnum::Ui::StorageQuery<T>::min() const

Minimum allowed storage value.

Expects that storage() is still valid in the layer() and operations() list StorageOperation::Min.

template<class T>
T Magnum::Ui::StorageQuery<T>::max() const

Maximum allowed storage value.

Expects that storage() is still valid in the layer() and operations() list StorageOperation::Max.