Cached accessor for a StateTree property. More...
#include <cached_property.hpp>
Public Member Functions | |
| CachedProperty ()=default | |
| CachedProperty (StateTree::Ptr tree, std::string_view property_name, T default_value=T{}) | |
| Bind to a tree node and property name. | |
| ~CachedProperty () | |
| const T & | get () const |
| Get the cached value (no variant extraction — fast). | |
| operator const T & () const | |
| void | set (const T &new_value) |
| Set the value (updates both cache and tree). | |
| CachedProperty & | operator= (const T &new_value) |
| void | refresh () |
| Force refresh from the tree. | |
| bool | is_bound () const |
| Whether bound to a tree. | |
| CachedProperty (const CachedProperty &)=delete | |
| CachedProperty & | operator= (const CachedProperty &)=delete |
| CachedProperty (CachedProperty &&other) noexcept | |
Cached accessor for a StateTree property.
Maintains a local copy that's updated via the tree's listener mechanism.
|
default |
|
inline |
Bind to a tree node and property name.
|
inline |
|
delete |
|
inlinenoexcept |
|
inline |
Get the cached value (no variant extraction — fast).
|
inline |
Whether bound to a tree.
|
inline |
|
delete |
|
inline |
|
inline |
Force refresh from the tree.
|
inline |
Set the value (updates both cache and tree).
Short-circuits a redundant write-through: if the new value equals the current cached value AND the property is already materialized in the tree, the write (and its listener notification) is skipped. The present-check is essential — when the property is absent and the cache is still sitting on default_, a set(default_) MUST materialize the property, so it must not be swallowed by the value-equality test.