ufe 7.0
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 "D:/Jenkins/workspace/EMS/ECG/ufe/full/ufe-full-python3.13-windows/ufe/include/subject.h"
2#ifndef UFE_SUBJECT_H
3#define UFE_SUBJECT_H
4
5// ===========================================================================
6// Copyright 2025 Autodesk, Inc. All rights reserved.
7//
8// The use of this software is subject to the Autodesk Terms of Use or other
9// license agreement provided at the time of installation or download, or
10// which otherwise accompanies this software.
11// ===========================================================================
12
13#include "observer.h"
14
15#include <set>
16
18
19class Notification;
20class NotificationGuard;
21
23
42{
43public:
44
47
50
53
55 virtual ~Subject();
56
59
62
69 bool addObserver(const Observer::Ptr& obs);
70
77 bool removeObserver(const Observer::Ptr& obs);
78
80 bool hasObserver(const Observer::Ptr& obs) const;
81
83 std::size_t nbObservers() const;
84
87 virtual void notify(const Notification& notification);
88
92 virtual bool inCompositeNotification() const;
93
94protected:
97 virtual void beginNotificationGuard();
98 virtual void endNotificationGuard();
100
101private:
102 friend class NotificationGuard;
103
104 // Weak pointers cannot be ordered by default, as they can expire at any
105 // time. However, they can be ordered by the address of the control block,
106 // which stores the number of shared_ptr AND weak_ptr, and is deleted only
107 // when the last weak_ptr expires.
108 typedef std::set<Observer::WeakPtr, std::owner_less<Observer::WeakPtr> >
110
113 void cleanObservers(const Observers& dead);
114
116};
117
119
130public:
131
134
140
141private:
143};
144
145}
146
147#endif /* UFE_SUBJECT_H */
Notification guard for Subject.
Definition: subject.h:129
Subject *const fSubject
Definition: subject.h:142
NotificationGuard(const NotificationGuard &)=delete
const NotificationGuard & operator&(const NotificationGuard &)=delete
NotificationGuard(Subject &subject)
Base class for all notifications.
Definition: notification.h:30
std::shared_ptr< Observer > Ptr
Definition: observer.h:37
Observer pattern Subject class.
Definition: subject.h:42
bool removeObserver(const Observer::Ptr &obs)
Observers fObservers
Definition: subject.h:115
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()
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:109
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:36
#define UFE_SDK_DECL
Definition: ufeExport.h:35