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
Ufe::Subject Class Reference

Observer pattern Subject class. More...

#include <subject.h>

Inheritance diagram for Ufe::Subject:

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...
 
Subjectoperator= (const Subject &)
 Assignment operator. Does nothing, as observers are not copied. More...
 
Subjectoperator= (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 &notification)
 
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
 

Detailed Description

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.

Definition at line 40 of file subject.h.

Member Typedef Documentation

◆ Observers

typedef std::set<Observer::WeakPtr, std::owner_less<Observer::WeakPtr> > Ufe::Subject::Observers
private

Definition at line 108 of file subject.h.

Constructor & Destructor Documentation

◆ Subject() [1/3]

Ufe::Subject::Subject ( )

Constructor.

◆ Subject() [2/3]

Ufe::Subject::Subject ( const Subject )

Copy constructor. Observers are not copied.

◆ Subject() [3/3]

Ufe::Subject::Subject ( Subject &&  )

Move constructor. Observers are not moved.

◆ ~Subject()

virtual Ufe::Subject::~Subject ( )
virtual

Destructor.

Member Function Documentation

◆ addObserver()

bool Ufe::Subject::addObserver ( const Observer::Ptr obs)

Add the argument Observer to this subject. Does nothing and returns false if the Observer is already present.

Parameters
obsObserver to add to Subject.
Returns
True if the Observer has been added to Subject.

◆ beginNotificationGuard()

virtual void Ufe::Subject::beginNotificationGuard ( )
protectedvirtual

Notification guard interface. Implementation in this class is a no-op.

Reimplemented in Ufe::ObservableSelection, and Ufe::Scene.

◆ cleanObservers()

void Ufe::Subject::cleanObservers ( const Observers dead)
private

Remove dead observers.

Parameters
deadObservers to remove.

◆ endNotificationGuard()

virtual void Ufe::Subject::endNotificationGuard ( )
protectedvirtual

Reimplemented in Ufe::ObservableSelection, and Ufe::Scene.

◆ hasObserver()

bool Ufe::Subject::hasObserver ( const Observer::Ptr obs) const
Returns
True if this subject has the argument observer.

◆ inCompositeNotification()

virtual bool Ufe::Subject::inCompositeNotification ( ) const
virtual

Composite notification predicate. Implementation in this class returns false.

Returns
True if this subject is collecting notifications into a composite notification.

Reimplemented in Ufe::ObservableSelection, and Ufe::Scene.

◆ nbObservers()

std::size_t Ufe::Subject::nbObservers ( ) const
Returns
Number of observers.

◆ notify()

virtual void Ufe::Subject::notify ( const Notification notification)
virtual

Notify observers. Not protected to simplify Python bindings.

Parameters
notificationNotification to notify.

Reimplemented in Ufe::Scene.

◆ operator=() [1/2]

Subject & Ufe::Subject::operator= ( const Subject )

Assignment operator. Does nothing, as observers are not copied.

◆ operator=() [2/2]

Subject & Ufe::Subject::operator= ( Subject &&  )

Move assignment operator. Does nothing, as observers are not moved.

◆ removeObserver()

bool Ufe::Subject::removeObserver ( const Observer::Ptr obs)

Remove the argument Observer from this subject. Returns false if the observer isn't found.

Parameters
obsObserver to remove from Subject.
Returns
True if the Observer has been removed from Subject.

Friends And Related Function Documentation

◆ NotificationGuard

friend class NotificationGuard
friend

Definition at line 101 of file subject.h.

Member Data Documentation

◆ fObservers

Observers Ufe::Subject::fObservers
private

Definition at line 114 of file subject.h.


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