![]() |
ufe 6.2
Universal Front End is a DCC-agnostic component that will allow a DCC to browse and edit data in multiple data models
|
Observer pattern Subject class. More...
#include <subject.h>
Public Member Functions | |
Subject () | |
Constructor. More... | |
Subject (const Subject &) | |
Copy constructor. Observers are not copied. More... | |
Subject (Subject &&) | |
Move constructor. Observers are not moved. More... | |
virtual | ~Subject () |
Destructor. More... | |
Subject & | operator= (const Subject &) |
Assignment operator. Does nothing, as observers are not copied. More... | |
Subject & | operator= (Subject &&) |
Move assignment operator. Does nothing, as observers are not moved. More... | |
bool | addObserver (const Observer::Ptr &obs) |
bool | removeObserver (const Observer::Ptr &obs) |
bool | hasObserver (const Observer::Ptr &obs) const |
std::size_t | nbObservers () const |
virtual void | notify (const Notification ¬ification) |
virtual bool | inCompositeNotification () const |
Protected Member Functions | |
virtual void | beginNotificationGuard () |
Notification guard interface. Implementation in this class is a no-op. More... | |
virtual void | endNotificationGuard () |
Private Types | |
typedef std::set< Observer::WeakPtr, std::owner_less< Observer::WeakPtr > > | Observers |
Private Member Functions | |
void | cleanObservers (const Observers &dead) |
Private Attributes | |
Observers | fObservers |
Friends | |
class | NotificationGuard |
Observer pattern Subject class.
This class implements the Subject in the Observer Pattern:
https://en.wikipedia.org/wiki/Observer_pattern
Observers are held by weak pointer. The order in which observers are notified is unspecified, implementation dependent, and can change at any time. Observers should NOT rely on the order in which they are added to a Subject and assume they will be called in the same order.
The semantics of Subject under copy, assignment, move, and move assignment are that observers are not copied or moved. As compared to preventing copying, this provides flexibility for derived classes to support the value-based semantics of copy, as well as efficient support of temporary objects with move.
|
private |
Ufe::Subject::Subject | ( | ) |
Constructor.
Ufe::Subject::Subject | ( | const Subject & | ) |
Copy constructor. Observers are not copied.
Ufe::Subject::Subject | ( | Subject && | ) |
Move constructor. Observers are not moved.
|
virtual |
Destructor.
bool Ufe::Subject::addObserver | ( | const Observer::Ptr & | obs | ) |
|
protectedvirtual |
Notification guard interface. Implementation in this class is a no-op.
Reimplemented in Ufe::ObservableSelection, and Ufe::Scene.
|
private |
Remove dead observers.
dead | Observers to remove. |
|
protectedvirtual |
Reimplemented in Ufe::ObservableSelection, and Ufe::Scene.
bool Ufe::Subject::hasObserver | ( | const Observer::Ptr & | obs | ) | const |
|
virtual |
Composite notification predicate. Implementation in this class returns false.
Reimplemented in Ufe::ObservableSelection, and Ufe::Scene.
std::size_t Ufe::Subject::nbObservers | ( | ) | const |
|
virtual |
Notify observers. Not protected to simplify Python bindings.
notification | Notification to notify. |
Reimplemented in Ufe::Scene.
Assignment operator. Does nothing, as observers are not copied.
Move assignment operator. Does nothing, as observers are not moved.
bool Ufe::Subject::removeObserver | ( | const Observer::Ptr & | obs | ) |
|
friend |