7 #ifndef RETDEC_LLVMIR2HLL_SUPPORT_SUBJECT_H
8 #define RETDEC_LLVMIR2HLL_SUPPORT_SUBJECT_H
42 template<
typename SubjectType,
typename ArgType = SubjectType>
176 return !observer.expired();
184 existingObserver->update(
getSelf(), arg);
193 [&observer](
const auto &other) {
194 return other.expired() || observer.lock() == other.lock();
Implementation of a generic typed observer using shared pointers (observer part).
Definition: observer.h:41
Implementation of a generic typed observer using shared pointers (subject part).
Definition: subject.h:43
bool observerExists(ObserverPtr observer)
Checks if the given observer still exists.
Definition: subject.h:175
void removeObservers()
Removes all observers.
Definition: subject.h:107
virtual ~Subject()=default
Destructs the subject.
void addObserver(ObserverPtr observer)
Adds a new observer to the list of observers.
Definition: subject.h:91
observer_iterator observer_begin() const
Returns a constant iterator to the first observer.
Definition: subject.h:146
WkPtr< ConcreteObserver > ObserverPtr
A pointer to an observer.
Definition: subject.h:51
void notifyObservers(ShPtr< ArgType > arg=nullptr)
Notifies all observers by calling Observer::update() on them.
Definition: subject.h:125
typename ObserverContainer::const_iterator observer_iterator
Definition: subject.h:140
observer_iterator observer_end() const
Returns a constant iterator past the last observer.
Definition: subject.h:153
virtual ShPtr< SubjectType > getSelf()=0
Returns a shared pointer of self.
Subject()
Creates a new subject.
Definition: subject.h:57
void notifyObserverOrRemoveItIfNotExists(ObserverPtr observer, ShPtr< ArgType > arg)
Notifies the given observer (if it exists) or removes it (if it does not exist).
Definition: subject.h:163
std::vector< ObserverPtr > ObserverContainer
A container to store observers.
Definition: subject.h:137
void removeObserverAndNonExistingObservers(ObserverPtr observer)
Removes the given observer and all the non-existing observers.
Definition: subject.h:191
void notifyObserver(ObserverPtr observer, ShPtr< ArgType > arg)
Notifies the given observer, provided it still exists.
Definition: subject.h:182
ObserverContainer observers
Container to store observers.
Definition: subject.h:201
void removeObserver(ObserverPtr observer)
Removes the selected observer from the list of observers.
Definition: subject.h:100
A library providing API for working with back-end IR.
std::weak_ptr< T > WkPtr
An alias for a weak pointer.
Definition: smart_ptr.h:22
std::shared_ptr< T > ShPtr
An alias for a shared pointer.
Definition: smart_ptr.h:18
Definition: archive_wrapper.h:19
Declarations, aliases, macros, etc. for the use of smart pointers.