Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
pulp::state::CachedProperty< T > Class Template Reference

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

Detailed Description

template<typename T>
class pulp::state::CachedProperty< T >

Cached accessor for a StateTree property.

Maintains a local copy that's updated via the tree's listener mechanism.

Constructor & Destructor Documentation

◆ CachedProperty() [1/4]

template<typename T>
pulp::state::CachedProperty< T >::CachedProperty ( )
default

◆ CachedProperty() [2/4]

template<typename T>
pulp::state::CachedProperty< T >::CachedProperty ( StateTree::Ptr tree,
std::string_view property_name,
T default_value = T{} )
inline

Bind to a tree node and property name.

◆ ~CachedProperty()

template<typename T>
pulp::state::CachedProperty< T >::~CachedProperty ( )
inline

◆ CachedProperty() [3/4]

template<typename T>
pulp::state::CachedProperty< T >::CachedProperty ( const CachedProperty< T > & )
delete

◆ CachedProperty() [4/4]

template<typename T>
pulp::state::CachedProperty< T >::CachedProperty ( CachedProperty< T > && other)
inlinenoexcept

Member Function Documentation

◆ get()

template<typename T>
const T & pulp::state::CachedProperty< T >::get ( ) const
inline

Get the cached value (no variant extraction — fast).

◆ is_bound()

template<typename T>
bool pulp::state::CachedProperty< T >::is_bound ( ) const
inline

Whether bound to a tree.

◆ operator const T &()

template<typename T>
pulp::state::CachedProperty< T >::operator const T & ( ) const
inline

◆ operator=() [1/2]

template<typename T>
CachedProperty & pulp::state::CachedProperty< T >::operator= ( const CachedProperty< T > & )
delete

◆ operator=() [2/2]

template<typename T>
CachedProperty & pulp::state::CachedProperty< T >::operator= ( const T & new_value)
inline

◆ refresh()

template<typename T>
void pulp::state::CachedProperty< T >::refresh ( )
inline

Force refresh from the tree.

◆ set()

template<typename T>
void pulp::state::CachedProperty< T >::set ( const T & new_value)
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.


The documentation for this class was generated from the following file: