All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
notice.h
1//
2// Copyright 2016 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7#ifndef PXR_USD_SDF_NOTICE_H
8#define PXR_USD_SDF_NOTICE_H
9
10#include "pxr/pxr.h"
11#include "pxr/usd/sdf/api.h"
14#include "pxr/usd/sdf/path.h"
15#include "pxr/base/tf/notice.h"
16
17PXR_NAMESPACE_OPEN_SCOPE
18
19SDF_DECLARE_HANDLES(SdfLayer);
20
25class SdfNotice {
26public:
32 class Base : public TfNotice {
33 public:
34 SDF_API ~Base();
35 };
36
42 public:
43 BaseLayersDidChange(const SdfLayerChangeListVec &changeVec,
44 size_t serialNumber)
45 : _vec(&changeVec)
46 , _serialNumber(serialNumber)
47 {}
48
49 using const_iterator = SdfLayerChangeListVec::const_iterator;
50 using iterator = const_iterator;
51
53 SDF_API
54 SdfLayerHandleVector GetLayers() const;
55
57 const SdfLayerChangeListVec &GetChangeListVec() const { return *_vec; }
58
59 const_iterator begin() const { return _vec->begin(); }
60 const_iterator cbegin() const { return _vec->cbegin(); }
61 const_iterator end() const { return _vec->end(); }
62 const_iterator cend() const { return _vec->cend(); }
63
64 const_iterator find(SdfLayerHandle const &layer) const {
65 return std::find_if(
66 begin(), end(),
67 [&layer](SdfLayerChangeListVec::value_type const &p) {
68 return p.first == layer;
69 });
70 }
71
72 bool count(SdfLayerHandle const &layer) const {
73 return find(layer) != end();
74 }
75
77 size_t GetSerialNumber() const { return _serialNumber; }
78
79 private:
80 const SdfLayerChangeListVec *_vec;
81 const size_t _serialNumber;
82 };
83
94 : public Base, public BaseLayersDidChange {
95 public:
96 LayersDidChangeSentPerLayer(const SdfLayerChangeListVec &changeVec,
97 size_t serialNumber)
98 : BaseLayersDidChange(changeVec, serialNumber) {}
99 SDF_API virtual ~LayersDidChangeSentPerLayer();
100 };
101
107 : public Base, public BaseLayersDidChange {
108 public:
109 LayersDidChange(const SdfLayerChangeListVec &changeVec,
110 size_t serialNumber)
111 : BaseLayersDidChange(changeVec, serialNumber) {}
112 SDF_API virtual ~LayersDidChange();
113 };
114
119 class LayerInfoDidChange : public Base {
120 public:
121 LayerInfoDidChange( const TfToken &key ) :
122 _key(key) {}
123 SDF_API ~LayerInfoDidChange();
124
126 const TfToken & key() const { return _key; }
127 private:
128 TfToken _key;
129 };
130
136 public:
137 SDF_API
138 LayerIdentifierDidChange(const std::string& oldIdentifier,
139 const std::string& newIdentifier);
140 SDF_API
142
144 const std::string& GetOldIdentifier() const { return _oldId; }
145
147 const std::string& GetNewIdentifier() const { return _newId; }
148
149 private:
150 std::string _oldId;
151 std::string _newId;
152 };
153
159 public:
160 SDF_API ~LayerDidReplaceContent();
161 };
162
166 public:
167 SDF_API virtual ~LayerDidReloadContent();
168 };
169
175 public:
176 SDF_API ~LayerDidSaveLayerToFile();
177 };
178
185 public:
186 SDF_API ~LayerDirtinessChanged();
187 };
188
195 class LayerMutenessChanged : public Base {
196 public:
197 LayerMutenessChanged(const std::string& layerPath, bool wasMuted)
198 : _layerPath(layerPath)
199 , _wasMuted(wasMuted)
200 { }
201
202 SDF_API ~LayerMutenessChanged();
203
205 const std::string& GetLayerPath() const { return _layerPath; }
206
208 bool WasMuted() const { return _wasMuted; }
209
210 private:
211 std::string _layerPath;
212 bool _wasMuted;
213 };
214};
215
216PXR_NAMESPACE_CLOSE_SCOPE
217
218#endif // PXR_USD_SDF_NOTICE_H
A scene description container that can combine with other such containers to form simple component as...
Definition: layer.h:84
Base notification class for scene.
Definition: notice.h:32
Base class for LayersDidChange and LayersDidChangeSentPerLayer.
Definition: notice.h:41
size_t GetSerialNumber() const
The serial number for this round of change processing.
Definition: notice.h:77
const SdfLayerChangeListVec & GetChangeListVec() const
A list of layers and the changes that occurred to them.
Definition: notice.h:57
SDF_API SdfLayerHandleVector GetLayers() const
A list of layers changed.
Sent after a layer is reloaded.
Definition: notice.h:165
Sent after a layer has been loaded from a file.
Definition: notice.h:158
Sent after a layer is saved to file.
Definition: notice.h:174
Similar behavior to LayersDidChange, but only gets sent if a change in the dirty status of a layer oc...
Definition: notice.h:184
Sent when the identifier of a layer has changed.
Definition: notice.h:135
const std::string & GetNewIdentifier() const
Returns the new identifier for the layer.
Definition: notice.h:147
const std::string & GetOldIdentifier() const
Returns the old identifier for the layer.
Definition: notice.h:144
Sent when the (scene spec) info of a layer have changed.
Definition: notice.h:119
const TfToken & key() const
Return the key affected.
Definition: notice.h:126
Sent after a layer has been added or removed from the set of muted layers.
Definition: notice.h:195
const std::string & GetLayerPath() const
Returns the path of the layer that was muted or unmuted.
Definition: notice.h:205
bool WasMuted() const
Returns true if the layer was muted, false if unmuted.
Definition: notice.h:208
Global notice sent to indicate that layer contents have changed.
Definition: notice.h:107
Notice sent per-layer indicating all layers whose contents have changed within a single round of chan...
Definition: notice.h:94
Wrapper class for Sdf notices.
Definition: notice.h:25
The base class for objects used to notify interested parties (listeners) when events have occurred.
Definition: notice.h:76
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:71