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
subject.h
Go to the documentation of this file.
1#line 1 "S:/jenkins/workspace/ECP/ufe/ufe-full-python3.11-windows/ufe/include/subject.h"
2#ifndef _ufeSubject
3#define _ufeSubject
4// ===========================================================================
5// Copyright 2018 Autodesk, Inc. All rights reserved.
6//
7// Use of this software is subject to the terms of the Autodesk license
8// agreement provided at the time of installation or download, or which
9// otherwise accompanies this software in either electronic or hard copy form.
10// ===========================================================================
11
12#include "observer.h"
13
14#include <set>
15
17
18class Notification;
19class NotificationGuard;
20
22
41{
42public:
43
46
49
52
54 virtual ~Subject();
55
58
61
68 bool addObserver(const Observer::Ptr& obs);
69
76 bool removeObserver(const Observer::Ptr& obs);
77
79 bool hasObserver(const Observer::Ptr& obs) const;
80
82 std::size_t nbObservers() const;
83
86 virtual void notify(const Notification& notification);
87
91 virtual bool inCompositeNotification() const;
92
93protected:
95
96 virtual void beginNotificationGuard();
97 virtual void endNotificationGuard();
99
100private:
101 friend class NotificationGuard;
102
103 // Weak pointers cannot be ordered by default, as they can expire at any
104 // time. However, they can be ordered by the address of the control block,
105 // which stores the number of shared_ptr AND weak_ptr, and is deleted only
106 // when the last weak_ptr expires.
107 typedef std::set<Observer::WeakPtr, std::owner_less<Observer::WeakPtr> >
109
112 void cleanObservers(const Observers& dead);
113
115};
116
118
129public:
130
133
135
139
140private:
142};
143
144}
145
146#endif /* _ufeSubject */
Notification guard for Subject.
Definition: subject.h:128
Subject *const fSubject
Definition: subject.h:141
NotificationGuard(const NotificationGuard &)=delete
Cannot be copied or assigned.
const NotificationGuard & operator&(const NotificationGuard &)=delete
NotificationGuard(Subject &subject)
Base class for all notifications.
Definition: notification.h:29
std::shared_ptr< Observer > Ptr
Definition: observer.h:36
Observer pattern Subject class.
Definition: subject.h:41
bool removeObserver(const Observer::Ptr &obs)
Observers fObservers
Definition: subject.h:114
virtual void notify(const Notification &notification)
void cleanObservers(const Observers &dead)
virtual void endNotificationGuard()
Subject & operator=(const Subject &)
Assignment operator. Does nothing, as observers are not copied.
virtual void beginNotificationGuard()
Notification guard interface. Implementation in this class is a no-op.
bool addObserver(const Observer::Ptr &obs)
virtual ~Subject()
Destructor.
Subject()
Constructor.
Subject(const Subject &)
Copy constructor. Observers are not copied.
std::size_t nbObservers() const
std::set< Observer::WeakPtr, std::owner_less< Observer::WeakPtr > > Observers
Definition: subject.h:108
bool hasObserver(const Observer::Ptr &obs) const
Subject(Subject &&)
Move constructor. Observers are not moved.
Subject & operator=(Subject &&)
Move assignment operator. Does nothing, as observers are not moved.
virtual bool inCompositeNotification() const
#define UFE_NS_DEF
Definition: ufe.h:35
#define UFE_SDK_DECL
Definition: ufeExport.h:36