KiCad PCB EDA Suite
Loading...
Searching...
No Matches
UTIL::OBSERVABLE< ObserverInterface > Class Template Reference

#include <observable.h>

Inheritance diagram for UTIL::OBSERVABLE< ObserverInterface >:
UTIL::DETAIL::OBSERVABLE_BASE

Public Member Functions

 OBSERVABLE ()
 Construct an observable with empty non-shared subscription list.
 
 OBSERVABLE (OBSERVABLE &aInherit)
 Construct an observable with a shared subscription list.
 
void SubscribeUnmanaged (ObserverInterface *aObserver)
 Add a subscription without RAII link.
 
LINK Subscribe (ObserverInterface *aObserver)
 Add a subscription returning an RAII link.
 
void Unsubscribe (ObserverInterface *aObserver)
 Cancel the subscription of a subscriber.
 
template<typename... Args1, typename... Args2>
void Notify (void(ObserverInterface::*Ptr)(Args1...), Args2 &&... aArgs)
 Notify event to all subscribed observers.
 
template<typename... Args1, typename... Args2>
void NotifyIgnore (void(ObserverInterface::*Ptr)(Args1...), ObserverInterface *aIgnore, Args2 &&... aArgs)
 Notify event to all subscribed observers but one to be ignore.
 
size_t size () const
 

Protected Member Functions

void on_observers_empty ()
 
void enter_iteration ()
 
void leave_iteration ()
 
void add_observer (void *observer)
 
void remove_observer (void *observer)
 

Protected Attributes

std::shared_ptr< IMPLimpl_
 

Private Member Functions

void allocate_impl ()
 
void allocate_shared_impl ()
 
void deallocate_impl ()
 
std::shared_ptr< IMPLget_shared_impl ()
 

Detailed Description

template<typename ObserverInterface>
class UTIL::OBSERVABLE< ObserverInterface >

Definition at line 126 of file observable.h.

Constructor & Destructor Documentation

◆ OBSERVABLE() [1/2]

template<typename ObserverInterface >
UTIL::OBSERVABLE< ObserverInterface >::OBSERVABLE ( )
inline

Construct an observable with empty non-shared subscription list.

Definition at line 132 of file observable.h.

◆ OBSERVABLE() [2/2]

template<typename ObserverInterface >
UTIL::OBSERVABLE< ObserverInterface >::OBSERVABLE ( OBSERVABLE< ObserverInterface > &  aInherit)
inline

Construct an observable with a shared subscription list.

Parameters
aInheritObservable to share the subscription list with.

Definition at line 139 of file observable.h.

Member Function Documentation

◆ add_observer()

void UTIL::DETAIL::OBSERVABLE_BASE::add_observer ( void *  observer)
protectedinherited

◆ allocate_impl()

void UTIL::DETAIL::OBSERVABLE_BASE::allocate_impl ( )
privateinherited

◆ allocate_shared_impl()

void UTIL::DETAIL::OBSERVABLE_BASE::allocate_shared_impl ( )
privateinherited

◆ deallocate_impl()

void UTIL::DETAIL::OBSERVABLE_BASE::deallocate_impl ( )
privateinherited

◆ enter_iteration()

void UTIL::DETAIL::OBSERVABLE_BASE::enter_iteration ( )
protectedinherited

◆ get_shared_impl()

std::shared_ptr< OBSERVABLE_BASE::IMPL > UTIL::DETAIL::OBSERVABLE_BASE::get_shared_impl ( )
privateinherited

◆ leave_iteration()

void UTIL::DETAIL::OBSERVABLE_BASE::leave_iteration ( )
protectedinherited

◆ Notify()

template<typename ObserverInterface >
template<typename... Args1, typename... Args2>
void UTIL::OBSERVABLE< ObserverInterface >::Notify ( void(ObserverInterface::*)(Args1...)  Ptr,
Args2 &&...  aArgs 
)
inline

Notify event to all subscribed observers.

Parameters
Ptris a pointer to method of the observer interface.
aArgsis a list of arguments to each notification call, will be perfectly forwarded.

Definition at line 182 of file observable.h.

References UTIL::DETAIL::OBSERVABLE_BASE::enter_iteration(), UTIL::DETAIL::OBSERVABLE_BASE::impl_, and UTIL::DETAIL::OBSERVABLE_BASE::leave_iteration().

◆ NotifyIgnore()

template<typename ObserverInterface >
template<typename... Args1, typename... Args2>
void UTIL::OBSERVABLE< ObserverInterface >::NotifyIgnore ( void(ObserverInterface::*)(Args1...)  Ptr,
ObserverInterface *  aIgnore,
Args2 &&...  aArgs 
)
inline

Notify event to all subscribed observers but one to be ignore.

Parameters
Ptris a pointer to method of the observer interface.
aIgnoreis an observer to ignore during this notification.
aArgsis a list of arguments to each notification call, will be perfectly forwarded.

Definition at line 218 of file observable.h.

References UTIL::DETAIL::OBSERVABLE_BASE::enter_iteration(), UTIL::DETAIL::OBSERVABLE_BASE::impl_, and UTIL::DETAIL::OBSERVABLE_BASE::leave_iteration().

◆ on_observers_empty()

void UTIL::DETAIL::OBSERVABLE_BASE::on_observers_empty ( )
protectedinherited

Definition at line 258 of file observable.cpp.

References UTIL::DETAIL::OBSERVABLE_BASE::deallocate_impl().

◆ remove_observer()

void UTIL::DETAIL::OBSERVABLE_BASE::remove_observer ( void *  observer)
protectedinherited

Definition at line 223 of file observable.cpp.

References UTIL::DETAIL::OBSERVABLE_BASE::impl_.

◆ size()

size_t UTIL::DETAIL::OBSERVABLE_BASE::size ( ) const
inherited

Definition at line 249 of file observable.cpp.

References UTIL::DETAIL::OBSERVABLE_BASE::impl_.

◆ Subscribe()

template<typename ObserverInterface >
LINK UTIL::OBSERVABLE< ObserverInterface >::Subscribe ( ObserverInterface *  aObserver)
inline

Add a subscription returning an RAII link.

Parameters
aObserverobserver to subscribe
Returns
RAII link controlling the lifetime of the subscription

Definition at line 157 of file observable.h.

References UTIL::DETAIL::OBSERVABLE_BASE::impl_, and UTIL::DETAIL::OBSERVABLE_BASE::UTIL::LINK.

Referenced by KIGFX::GAL::GAL().

◆ SubscribeUnmanaged()

template<typename ObserverInterface >
void UTIL::OBSERVABLE< ObserverInterface >::SubscribeUnmanaged ( ObserverInterface *  aObserver)
inline

Add a subscription without RAII link.

Parameters
aObserverObserver to subscribe.

Definition at line 146 of file observable.h.

◆ Unsubscribe()

template<typename ObserverInterface >
void UTIL::OBSERVABLE< ObserverInterface >::Unsubscribe ( ObserverInterface *  aObserver)
inline

Cancel the subscription of a subscriber.

This can be called during notification calls.

Parameters
aObserverobserver to remove from the subscription list.

Definition at line 170 of file observable.h.

Member Data Documentation

◆ impl_


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