ufe  4.2
Universal Front End is a DCC-agnostic component that will allow a DCC to browse and edit data in multiple data models
pathSubject.h
Go to the documentation of this file.
1 #line 1 "S:/jenkins/workspace/ECP/ufe/ufe-full-python3.10-windows/ufe/include/pathSubject.h"
2 #ifndef _ufePathSubject
3 #define _ufePathSubject
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 "common/ufeExport.h"
13 
14 #include "subject.h"
15 #include "sceneItem.h"
16 #include "path.h"
17 
18 #include <memory>
19 #include <vector>
20 #include <functional>
21 
22 UFE_NS_DEF {
23 
24 class Notification;
25 
27 
38 {
39 public:
40  typedef std::shared_ptr<PathSubject> Ptr;
41 
42  // Prevent the re-definition of the private helper methods from hiding
43  // the public methods on Subject that we want to remain callable.
46 
53  using AddObserverFcn = std::function<bool(const SceneItem::Ptr& item, const Observer::Ptr& obs)>;
54 
61  using RemoveObserverFcn = std::function<bool(const Path& Path, const Observer::Ptr& obs)>;
62 
64  ~PathSubject() override;
65 
72  PathSubject(const Path& path, AddObserverFcn addObserverFcn, RemoveObserverFcn removeObserverFcn);
73 
74 private:
75  // Use for scene changes
76  void addObserver(const Path& path);
77  void removeObserver(const Path& path);
78  void addObservers(const Path& path, const Path& endAncestor);
79  void removeObservers(const Path& path, const Path& endAncestor);
80 
86  template<bool ADD_OBSERVER>
87  void addRemoveObserverHelper(const Path& path);
88 
96  template<bool ADD_OBSERVER>
97  void addRemoveObserversHelper(Path path, const Path& endAncestor);
98 
99  void reparent(const Path& oldPath, const Path& newPath);
100  void rename(const Path& oldPath, const Path& newPath);
101  void objectDelete(const Path& path);
102 
103  class SceneChangedObserver;
104 
105  Path _path;
110  bool _attached;
111 };
112 
113 }
114 
115 #endif /* _ufePathSubject */
const RemoveObserverFcn _removeObserverFcn
Definition: pathSubject.h:107
std::function< bool(const SceneItem::Ptr &item, const Observer::Ptr &obs)> AddObserverFcn
Callable function to add an observer to a SceneItem.
Definition: pathSubject.h:53
std::shared_ptr< Observer > Ptr
Definition: observer.h:36
Definition of macros for symbol visibility.
std::function< bool(const Path &Path, const Observer::Ptr &obs)> RemoveObserverFcn
Callable function to remove an observer from a Path.
Definition: pathSubject.h:61
const Observer::Ptr _sceneChangedObserver
Definition: pathSubject.h:109
std::shared_ptr< PathSubject > Ptr
Definition: pathSubject.h:40
bool removeObserver(const Observer::Ptr &obs)
Observer pattern Subject class.
Definition: subject.h:40
const Observer::Ptr _forwardingObserver
Definition: pathSubject.h:108
Identify an object or 3D path in the scene.
Definition: path.h:37
#define UFE_NS_DEF
Definition: ufe.h:35
bool addObserver(const Observer::Ptr &obs)
Helper to make a Path observable.
Definition: pathSubject.h:37
Path path(const std::string &pathString)
const AddObserverFcn _addObserverFcn
Definition: pathSubject.h:106
#define UFE_SDK_DECL
Definition: ufeExport.h:36