ufe 5.5
Universal Front End is a DCC-agnostic component that will allow a DCC to browse and edit data in multiple data models
Ufe::PathSubject Class Reference

Helper to make a Path observable. More...

#include <pathSubject.h>

Inheritance diagram for Ufe::PathSubject:
Collaboration diagram for Ufe::PathSubject:

Public Types

typedef std::shared_ptr< PathSubjectPtr
 
using AddObserverFcn = std::function< bool(const SceneItem::Ptr &item, const Observer::Ptr &obs)>
 Callable function to add an observer to a SceneItem. More...
 
using RemoveObserverFcn = std::function< bool(const Path &Path, const Observer::Ptr &obs)>
 Callable function to remove an observer from a Path. More...
 

Public Member Functions

 ~PathSubject () override
 Destructor. More...
 
 PathSubject (const Path &path, AddObserverFcn addObserverFcn, RemoveObserverFcn removeObserverFcn)
 
bool addObserver (const Observer::Ptr &obs)
 
bool removeObserver (const Observer::Ptr &obs)
 
- Public Member Functions inherited from Ufe::Subject
 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
 

Private Member Functions

void addObserver (const Path &path)
 
void removeObserver (const Path &path)
 
void addObservers (const Path &path, const Path &endAncestor)
 
void removeObservers (const Path &path, const Path &endAncestor)
 
template<bool ADD_OBSERVER>
void addRemoveObserverHelper (const Path &path)
 
template<bool ADD_OBSERVER>
void addRemoveObserversHelper (Path path, const Path &endAncestor)
 
void reparent (const Path &oldPath, const Path &newPath)
 
void rename (const Path &oldPath, const Path &newPath)
 
void objectDelete (const Path &path)
 

Private Attributes

Path _path
 
const AddObserverFcn _addObserverFcn
 
const RemoveObserverFcn _removeObserverFcn
 
const Observer::Ptr _forwardingObserver
 
const Observer::Ptr _sceneChangedObserver
 
bool _attached
 

Additional Inherited Members

- Protected Member Functions inherited from Ufe::Subject
virtual void beginNotificationGuard ()
 Notification guard interface. Implementation in this class is a no-op. More...
 
virtual void endNotificationGuard ()
 

Detailed Description

Helper to make a Path observable.

PathSubject observes all SceneItems in its path and forwards all notifications to the observers of PathSubject.

In Ufe a SceneItem can have multiple subjects to observe. PathSubject observes the SceneItem subjects which are registered through the AddSubject function.

As the observed path changes (through reparent operations) the set of observed SceneItem subjects is automatically updated to reflect the new path.

Definition at line 37 of file pathSubject.h.

Member Typedef Documentation

◆ AddObserverFcn

using Ufe::PathSubject::AddObserverFcn = std::function<bool(const SceneItem::Ptr& item, const Observer::Ptr& obs)>

Callable function to add an observer to a SceneItem.

Parameters
itemThe SceneItem to observe
obsThe observer to add
Returns
True if the observer is added.

Definition at line 53 of file pathSubject.h.

◆ Ptr

typedef std::shared_ptr<PathSubject> Ufe::PathSubject::Ptr

Definition at line 40 of file pathSubject.h.

◆ RemoveObserverFcn

using Ufe::PathSubject::RemoveObserverFcn = std::function<bool(const Path& Path, const Observer::Ptr& obs)>

Callable function to remove an observer from a Path.

Parameters
pathThe Path to remove observation on
obsThe observer to remove
Returns
True if the observer is removed.

Definition at line 61 of file pathSubject.h.

Constructor & Destructor Documentation

◆ ~PathSubject()

Ufe::PathSubject::~PathSubject ( )
override

Destructor.

◆ PathSubject()

Ufe::PathSubject::PathSubject ( const Path path,
AddObserverFcn  addObserverFcn,
RemoveObserverFcn  removeObserverFcn 
)

Constructor

Parameters
pathPath to make observable
addObserverFcnCallable function to add an observer to a scene item
removeObserverFcnCallable function to remove an observer from a path

Member Function Documentation

◆ addObserver() [1/2]

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.

◆ addObserver() [2/2]

void Ufe::PathSubject::addObserver ( const Path path)
private

◆ addObservers()

void Ufe::PathSubject::addObservers ( const Path path,
const Path endAncestor 
)
private

◆ addRemoveObserverHelper()

template<bool ADD_OBSERVER>
void Ufe::PathSubject::addRemoveObserverHelper ( const Path path)
private

Add or Remove an observer from Path.

Template Parameters
ADD_OBSERVERTrue to add an Observer, False to remove an Observer.
Parameters
pathPath to add or remove an Observer from.

◆ addRemoveObserversHelper()

template<bool ADD_OBSERVER>
void Ufe::PathSubject::addRemoveObserversHelper ( Path  path,
const Path endAncestor 
)
private

Add or Remove an observers from Path and each ancestor of path to endAncestor, not including endAncestor itself.

Template Parameters
ADD_OBSERVERTrue to add an Observer, False to remove an Observer.
Parameters
pathPath to add or remove an Observer from.
endAncestorFinal ancestor to add or remove an Observer from.

◆ objectDelete()

void Ufe::PathSubject::objectDelete ( const Path path)
private

◆ removeObserver() [1/2]

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.

◆ removeObserver() [2/2]

void Ufe::PathSubject::removeObserver ( const Path path)
private

◆ removeObservers()

void Ufe::PathSubject::removeObservers ( const Path path,
const Path endAncestor 
)
private

◆ rename()

void Ufe::PathSubject::rename ( const Path oldPath,
const Path newPath 
)
private

◆ reparent()

void Ufe::PathSubject::reparent ( const Path oldPath,
const Path newPath 
)
private

Member Data Documentation

◆ _addObserverFcn

const AddObserverFcn Ufe::PathSubject::_addObserverFcn
private

Definition at line 106 of file pathSubject.h.

◆ _attached

bool Ufe::PathSubject::_attached
private

Definition at line 110 of file pathSubject.h.

◆ _forwardingObserver

const Observer::Ptr Ufe::PathSubject::_forwardingObserver
private

Definition at line 108 of file pathSubject.h.

◆ _path

Path Ufe::PathSubject::_path
private

Definition at line 105 of file pathSubject.h.

◆ _removeObserverFcn

const RemoveObserverFcn Ufe::PathSubject::_removeObserverFcn
private

Definition at line 107 of file pathSubject.h.

◆ _sceneChangedObserver

const Observer::Ptr Ufe::PathSubject::_sceneChangedObserver
private

Definition at line 109 of file pathSubject.h.


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