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

DataLayer storage query

Returned from AbstractStorage implementations.

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 onUpdate(Containers::Function<void(const T&value)>&& function, NodeHandle node = NodeHandle::Null) const -> DataHandle
Bind a function to storage data update.
auto onUpdate(Containers::Function<void(T value)>&& function, NodeHandle node = NodeHandle::Null) const -> DataHandle
auto onUpdate(Containers::Function<void(T value, T min, T max)>&& function, NodeHandle node = NodeHandle::Null) const -> DataHandle
Bind a function to storage data update along with min/max values.
auto onUpdate(Containers::Function<void(DataHandle handle, const T&value)>&& function, NodeHandle node = NodeHandle::Null) const -> DataHandle
Bind a function to storage data update along with the data handle itself.
auto onUpdate(Containers::Function<void(DataHandle handle, T value)>&& function, NodeHandle node = NodeHandle::Null) const -> DataHandle
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>
DataHandle Magnum::Ui::StorageQuery<T>::onUpdate(Containers::Function<void(const T&value)>&& function, NodeHandle node = NodeHandle::Null) const

Bind a function to storage data update.

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

Expects that storage() is still valid in the 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 on the layer.

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

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::StorageQuery<T>::onUpdate(Containers::Function<void(T value, T min, T max)>&& function, NodeHandle node = NodeHandle::Null) const

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

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

Expects that storage() is still valid in the 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::StorageQuery<T>::onUpdate(Containers::Function<void(DataHandle handle, const T&value)>&& function, NodeHandle node = NodeHandle::Null) const

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

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

Like onUpdate(Containers::Function<void(const T& value)>&&, NodeHandle) const 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(Containers::Function<void(const T& value)>&&, NodeHandle) const for more information.

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

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>
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.