Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::CA::Composite_Observer< Observers > Class Template Reference

Variadic adaptor that fan-outs notifications to many observers. More...

#include <ca-observer.H>

Public Member Functions

 Composite_Observer (Observers... observers)
 Build the composite from child observers.
 
template<std::size_t I>
const auto & get () const noexcept
 Return read-only access to a child observer.
 
template<std::size_t I>
auto & get () noexcept
 Return mutable access to a child observer.
 
template<typename Lattice >
void on_step_begin (std::size_t step, const Lattice &frame)
 Forward a step-begin event to every child observer.
 
template<typename Lattice >
void on_step_end (std::size_t step, const Lattice &frame)
 Forward a step-end event to every child observer.
 

Static Public Member Functions

static constexpr std::size_t size () noexcept
 Return the number of child observers.
 

Private Attributes

std::tuple< Observers... > obs_
 

Detailed Description

template<typename... Observers>
class Aleph::CA::Composite_Observer< Observers >

Variadic adaptor that fan-outs notifications to many observers.

Composite_Observer<O1, O2, ...> owns its child observers by value (move-constructed at build time) and forwards on_step_begin / on_step_end to each one in declaration order. This lets the engine's single pre/post hook host an arbitrary number of independent observers.

Template Parameters
Observerstypes of the child observers.

Definition at line 128 of file ca-observer.H.

Constructor & Destructor Documentation

◆ Composite_Observer()

template<typename... Observers>
Aleph::CA::Composite_Observer< Observers >::Composite_Observer ( Observers...  observers)
inlineexplicit

Build the composite from child observers.

Reference types in Observers... are preserved and borrowed; value types are moved into the tuple and owned by the composite.

Parameters
[in]observerschild observers to store or reference.
Exceptions
Anyexception thrown while constructing the internal tuple.
Complexity
O(number of observers) time and space.
Thread-safety
Not thread-safe for concurrent callback writes. Concurrent readers are safe only if the referenced/owned observers are safe.

Definition at line 148 of file ca-observer.H.

Member Function Documentation

◆ get() [1/2]

template<typename... Observers>
template<std::size_t I>
const auto & Aleph::CA::Composite_Observer< Observers >::get ( ) const
inlinenoexcept

Return read-only access to a child observer.

Template Parameters
Ichild index.
Returns
const reference to the selected observer.
Exceptions
Thisfunction does not throw.

Definition at line 157 of file ca-observer.H.

References Aleph::CA::Composite_Observer< Observers >::obs_.

◆ get() [2/2]

template<typename... Observers>
template<std::size_t I>
auto & Aleph::CA::Composite_Observer< Observers >::get ( )
inlinenoexcept

Return mutable access to a child observer.

Template Parameters
Ichild index.
Returns
mutable reference to the selected observer.
Exceptions
Thisfunction does not throw.

Definition at line 168 of file ca-observer.H.

References Aleph::CA::Composite_Observer< Observers >::obs_.

◆ on_step_begin()

template<typename... Observers>
template<typename Lattice >
void Aleph::CA::Composite_Observer< Observers >::on_step_begin ( std::size_t  step,
const Lattice &  frame 
)
inline

Forward a step-begin event to every child observer.

Template Parameters
Latticelattice type.
Parameters
[in]stepstep index about to run.
[in]framecurrent frame before the step.
Exceptions
Anyexception thrown by a child observer.
Complexity
O(number of observers).

Definition at line 192 of file ca-observer.H.

References Aleph::blossom_maximum_cardinality_matching(), and Aleph::CA::Composite_Observer< Observers >::obs_.

◆ on_step_end()

template<typename... Observers>
template<typename Lattice >
void Aleph::CA::Composite_Observer< Observers >::on_step_end ( std::size_t  step,
const Lattice &  frame 
)
inline

Forward a step-end event to every child observer.

Template Parameters
Latticelattice type.
Parameters
[in]stepstep index just completed.
[in]framecurrent frame after the step.
Exceptions
Anyexception thrown by a child observer.
Complexity
O(number of observers).

Definition at line 210 of file ca-observer.H.

References Aleph::blossom_maximum_cardinality_matching(), and Aleph::CA::Composite_Observer< Observers >::obs_.

◆ size()

template<typename... Observers>
static constexpr std::size_t Aleph::CA::Composite_Observer< Observers >::size ( )
inlinestaticconstexprnoexcept

Return the number of child observers.

Returns
sizeof...(Observers).
Exceptions
Thisfunction does not throw.

Definition at line 177 of file ca-observer.H.

Member Data Documentation

◆ obs_


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