template<typename T, typename Traits = ResourceTraits<T>>
sk::CachedResource class

Another utility that can manage undo/redo.

Contents

This was actually supposed to be FCachedResource. It turned out we were overcomplicating ourselves with the store cache after n layers. It was incredibly tedious to implement(address sanitizer found some iterator invalidations) and didn't provide much benefit. This is only used when multiple users are connected to store local cache for each of them.

Public functions

template<typename... Ts>
auto emplaceBack(Ts && ... ts) -> T & -> auto
auto getLastCache() noexcept -> T * -> auto
Get tha last stored cache or nullptr if no cache was built yet.
auto reduceTo(T& value) -> void -> auto
template<typename F2>
auto reduceTo(F2 f) -> void -> auto
auto underUndo() const noexcept -> bool -> auto constexpr
auto undo() -> bool -> auto
auto redo() -> bool -> auto

Function documentation

template<typename T, typename Traits> template<typename... Ts>
auto sk::CachedResource<T, Traits>::emplaceBack(Ts && ... ts) -> T &

Similar to FCachedResource::emplaceBack.

template<typename T, typename Traits>
auto sk::CachedResource<T, Traits>::reduceTo(T& value) -> void

Called for the last built cache + all remaining layers.

template<typename T, typename Traits> template<typename F2>
auto sk::CachedResource<T, Traits>::reduceTo(F2 f) -> void

Same as reduceTo but can take a callback to know what to do.

template<typename T, typename Traits>
auto sk::CachedResource<T, Traits>::underUndo() const noexcept -> bool constexpr

Similar to FCachedResource::underUndo.

template<typename T, typename Traits>
auto sk::CachedResource<T, Traits>::undo() -> bool

Returns true If undo was successful. false If already at oldest change.

template<typename T, typename Traits>
auto sk::CachedResource<T, Traits>::redo() -> bool

Returns true If redo can be done still. false If got to the newest change.