6 #include <amdis/Output.hpp> 7 #include <amdis/common/ConceptsBase.hpp> 8 #include <amdis/common/Index.hpp> 9 #include <amdis/common/TypeTraits.hpp> 25 struct adapt {
bool value =
true; };
34 template <
class Event>
39 virtual void update(Event e) = 0;
40 virtual void unset() = 0;
53 template <
class Event,
class... Events>
63 template <
class Event>
85 if (std::find(observers_.begin(), observers_.end(), o) == observers_.end())
86 observers_.push_back(o);
96 std::list<ObserverInterface<Event>*> observers_;
101 template <
class Event,
class... Tags>
109 : notifier_(const_cast<N*>(¬ifier))
111 notifier_->attach(
this);
116 Observer(N
const& notifier)
118 warning(
"Ignoring Notifier. Use AdaptiveGrid wrapper.");
126 notifier_->detach(
this);
131 : notifier_(other.notifier_)
133 notifier_->attach(
this);
139 if (&other !=
this) {
140 notifier_->detach(
this);
141 notifier_ = other.notifier_;
158 updateImpl(e, Tags{}...);
165 virtual void updateImpl(Event e, Tags...) = 0;
174 template <
class Event,
class Tags>
175 class ObserverSequenceImpl;
178 template <
class Event, std::size_t... Is>
179 class ObserverSequenceImpl<Event, std::index_sequence<Is...>>
180 :
private Observer<Event,index_t<Is>>...
183 template <
class... Notifiers,
184 REQUIRES(
sizeof...(Notifiers) ==
sizeof...(Is))>
185 ObserverSequenceImpl(Notifiers&&... notifiers)
192 template <
class Event, std::
size_t N>
193 using ObserverSequence = Impl::ObserverSequenceImpl<Event, std::make_index_sequence<N>>;
Definition: Observer.hpp:35
void attach(ObserverInterface< Event > *o)
Attach a new observer that gets called on notify.
Definition: Observer.hpp:82
Definition: AdaptBase.hpp:6
Implementation of the ObserverInterface.
Definition: Observer.hpp:102
Observer & operator=(Observer const &other)
Copy-assignment operator, copies the notifier and attaches this.
Definition: Observer.hpp:137
Definition: Observer.hpp:64
virtual ~Observer()
Destructor, detaches from the notifier.
Definition: Observer.hpp:123
Definition: Observer.hpp:25
Definition: Observer.hpp:30
Mixin for signaling of certain events.
Definition: Observer.hpp:54
void update(Event e) final
Definition: Observer.hpp:156
void detach(ObserverInterface< Event > *o)
Detaches the passed observer from the list, if stored.
Definition: Observer.hpp:90
Observer(Observer const &other)
Copy constructor. Attaches this to the copied notifier.
Definition: Observer.hpp:130
void notify(Event const &e)
Call the update method on all attached observers.
Definition: Observer.hpp:75
Definition: Observer.hpp:19
void unset() final
Definition: Observer.hpp:149