Clio  develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
util::impl::ObservableValueBase< T > Class Template Referenceabstract

Base class containing common ObservableValue functionality. More...

#include <ObservableValue.hpp>

Inheritance diagram for util::impl::ObservableValueBase< T >:

Public Member Functions

boost::signals2::connection observe (std::invocable< T const & > auto &&fn)
 Registers an observer callback for value changes.
bool hasObservers () const
 Checks if there are any active observers.
virtual void forceNotify ()=0
 Forces notification of all observers with the current value.

Protected Member Functions

void notifyObservers (T const &value)
 Notifies all observers with the given value.

Protected Attributes

boost::signals2::signal< void(T const &)> onUpdate_

Detailed Description

template<Observable T>
class util::impl::ObservableValueBase< T >

Base class containing common ObservableValue functionality.

This class contains all the observer management and notification logic that is shared between regular and atomic ObservableValue specializations.

Template Parameters
TThe value type (for atomic specializations, this is the underlying type, not std::atomic<T>)

Member Function Documentation

◆ forceNotify()

template<Observable T>
virtual void util::impl::ObservableValueBase< T >::forceNotify ( )
pure virtual

Forces notification of all observers with the current value.

This method will notify all observers with the current value regardless of whether the value has changed since the last notification.

Implemented in util::ObservableValue< std::atomic< T > >, and util::ObservableValue< T >.

◆ hasObservers()

template<Observable T>
bool util::impl::ObservableValueBase< T >::hasObservers ( ) const
inlinenodiscard

Checks if there are any active observers.

Returns
true if there are observers, false otherwise

◆ notifyObservers()

template<Observable T>
void util::impl::ObservableValueBase< T >::notifyObservers ( T const & value)
inlineprotected

Notifies all observers with the given value.

Parameters
valueThe value to send to observers

◆ observe()

template<Observable T>
boost::signals2::connection util::impl::ObservableValueBase< T >::observe ( std::invocable< T const & > auto && fn)
inline

Registers an observer callback for value changes.

Parameters
fnCallback function/lambda that accepts T const&
Returns
Connection object for managing the subscription

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