Bertini 2 d882924 (2026-10-06 19:56 UTC)
Numerical algebraic geometry library (C++ core)
Loading...
Searching...
No Matches
bertini::Event< ObsT, true > Class Template Reference

For emission of events from observables. More...

#include <events.hpp>

Inheritance diagram for bertini::Event< ObsT, true >:
[legend]
Collaboration diagram for bertini::Event< ObsT, true >:
[legend]

Public Types

using HeldT = const ObsT&
 How the observable is held: by const reference.

Public Member Functions

 Event (ObsT const &obs)
 Constructor for an event.
virtual ~Event ()=default
ObsT const & Get () const
 Get the emitting object, by const reference.
 Event ()=delete

Protected Attributes

const ObsT & current_observable_
 The observable object this event carries.

Detailed Description

template<class ObsT>
class bertini::Event< ObsT, true >

For emission of events from observables.

An observable object probably wants to emit events to notify observers that things are happening. The observers filter the events, at this time by dynamic casting (slow, I know, but it works for now. Premature optimization, etc.) A better method than dynamic casting would be to filter based on a union of bits or something. If you, the reader, want to help make this better, please contact a developer!

Say I am an observable object, and I want to emit an event. Events attach the type of object emitting them, and in fact (a refence to) the emitter itself. So if my type is T, I would do something like NotifyObservers(Event<T>(*this)). Then an Observer can filter based on a heirarchy of event types, etc.

Template Parameters
ObsTThe Observed type. When emitting an event, you pass in the type of object emitting the event, and the object itself. Then the observer can Get the emitting object, and do (const) stuff to it.
See also
Observable, Observable::NotifyObservers, ADD_BERTINI_EVENT_TYPE, AMPPathAccumulator, AnyEvent

Member Typedef Documentation

◆ HeldT

template<class ObsT>
using bertini::Event< ObsT, true >::HeldT = const ObsT&

How the observable is held: by const reference.

Constructor & Destructor Documentation

◆ Event() [1/2]

template<class ObsT>
bertini::Event< ObsT, true >::Event ( ObsT const & obs)
inline

Constructor for an event.

Parameters
obsThe observable emitting the event to observers. Passed by const reference, this permits arbitrary const function calls by the observer.

◆ ~Event()

template<class ObsT>
virtual bertini::Event< ObsT, true >::~Event ( )
virtualdefault

◆ Event() [2/2]

template<class ObsT>
bertini::Event< ObsT, true >::Event ( )
delete

Member Function Documentation

◆ Get()

template<class ObsT>
ObsT const & bertini::Event< ObsT, true >::Get ( ) const
inline

Get the emitting object, by const reference.

Returns
The observable who emitted the event. This permits calls of arbitrary const functions, particularly getters.
See also
AMPPathAccumulator for simple example of filtering using dynamic_casts

Member Data Documentation

◆ current_observable_

template<class ObsT>
const ObsT& bertini::Event< ObsT, true >::current_observable_
protected

The observable object this event carries.