forked from PixarAnimationStudios/OpenUSD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
notice.h
235 lines (203 loc) · 7.4 KB
/
notice.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
//
// Copyright 2016 Pixar
//
// Licensed under the Apache License, Version 2.0 (the "Apache License")
// with the following modification; you may not use this file except in
// compliance with the Apache License and the following modification to it:
// Section 6. Trademarks. is deleted and replaced with:
//
// 6. Trademarks. This License does not grant permission to use the trade
// names, trademarks, service marks, or product names of the Licensor
// and its affiliates, except as required to comply with Section 4(c) of
// the License and to reproduce the content of the NOTICE file.
//
// You may obtain a copy of the Apache License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the Apache License with the above modification is
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the Apache License for the specific
// language governing permissions and limitations under the Apache License.
//
#ifndef PXR_USD_SDF_NOTICE_H
#define PXR_USD_SDF_NOTICE_H
#include "pxr/pxr.h"
#include "pxr/usd/sdf/api.h"
#include "pxr/usd/sdf/changeList.h"
#include "pxr/usd/sdf/declareHandles.h"
#include "pxr/usd/sdf/path.h"
#include "pxr/base/tf/notice.h"
PXR_NAMESPACE_OPEN_SCOPE
SDF_DECLARE_HANDLES(SdfLayer);
/// \class SdfNotice
///
/// Wrapper class for Sdf notices.
///
class SdfNotice {
public:
/// \class Base
///
/// Base notification class for scene. Only useful for type hierarchy
/// purposes.
///
class Base : public TfNotice {
public:
SDF_API ~Base();
};
/// \class BaseLayersDidChange
///
/// Base class for LayersDidChange and LayersDidChangeSentPerLayer.
///
class BaseLayersDidChange {
public:
BaseLayersDidChange(const SdfLayerChangeListVec &changeVec,
size_t serialNumber)
: _vec(&changeVec)
, _serialNumber(serialNumber)
{}
using const_iterator = SdfLayerChangeListVec::const_iterator;
using iterator = const_iterator;
/// A list of layers changed.
SDF_API
SdfLayerHandleVector GetLayers() const;
/// A list of layers and the changes that occurred to them.
const SdfLayerChangeListVec &GetChangeListVec() const { return *_vec; }
const_iterator begin() const { return _vec->begin(); }
const_iterator cbegin() const { return _vec->cbegin(); }
const_iterator end() const { return _vec->end(); }
const_iterator cend() const { return _vec->cend(); }
const_iterator find(SdfLayerHandle const &layer) const {
return std::find_if(
begin(), end(),
[&layer](SdfLayerChangeListVec::value_type const &p) {
return p.first == layer;
});
}
bool count(SdfLayerHandle const &layer) const {
return find(layer) != end();
}
/// The serial number for this round of change processing.
size_t GetSerialNumber() const { return _serialNumber; }
private:
const SdfLayerChangeListVec *_vec;
const size_t _serialNumber;
};
/// \class LayersDidChangeSentPerLayer
///
/// Notice sent per-layer indicating all layers whose contents have changed
/// within a single round of change processing. If more than one layer
/// changes in a single round of change processing, we send this notice once
/// per layer with the same changeVec and serialNumber. This is so clients
/// can listen to notices from only the set of layers they care about rather
/// than listening to the global LayersDidChange notice.
///
class LayersDidChangeSentPerLayer
: public Base, public BaseLayersDidChange {
public:
LayersDidChangeSentPerLayer(const SdfLayerChangeListVec &changeVec,
size_t serialNumber)
: BaseLayersDidChange(changeVec, serialNumber) {}
SDF_API virtual ~LayersDidChangeSentPerLayer();
};
/// \class LayersDidChange
///
/// Global notice sent to indicate that layer contents have changed.
///
class LayersDidChange
: public Base, public BaseLayersDidChange {
public:
LayersDidChange(const SdfLayerChangeListVec &changeVec,
size_t serialNumber)
: BaseLayersDidChange(changeVec, serialNumber) {}
SDF_API virtual ~LayersDidChange();
};
/// \class LayerInfoDidChange
///
/// Sent when the (scene spec) info of a layer have changed.
///
class LayerInfoDidChange : public Base {
public:
LayerInfoDidChange( const TfToken &key ) :
_key(key) {}
SDF_API ~LayerInfoDidChange();
/// Return the key affected.
const TfToken & key() const { return _key; }
private:
TfToken _key;
};
/// \class LayerIdentifierDidChange
///
/// Sent when the identifier of a layer has changed.
///
class LayerIdentifierDidChange : public Base {
public:
SDF_API
LayerIdentifierDidChange(const std::string& oldIdentifier,
const std::string& newIdentifier);
SDF_API
~LayerIdentifierDidChange();
/// Returns the old identifier for the layer.
const std::string& GetOldIdentifier() const { return _oldId; }
/// Returns the new identifier for the layer.
const std::string& GetNewIdentifier() const { return _newId; }
private:
std::string _oldId;
std::string _newId;
};
/// \class LayerDidReplaceContent
///
/// Sent after a menv layer has been loaded from a file.
///
class LayerDidReplaceContent : public Base {
public:
SDF_API ~LayerDidReplaceContent();
};
/// \class LayerDidReloadContent
/// Sent after a layer is reloaded.
class LayerDidReloadContent : public LayerDidReplaceContent {
public:
SDF_API virtual ~LayerDidReloadContent();
};
/// \class LayerDidSaveLayerToFile
///
/// Sent after a layer is saved to file.
///
class LayerDidSaveLayerToFile : public Base {
public:
SDF_API ~LayerDidSaveLayerToFile();
};
/// \class LayerDirtinessChanged
///
/// Similar behavior to LayersDidChange, but only gets sent if a change
/// in the dirty status of a layer occurs.
///
class LayerDirtinessChanged : public Base {
public:
SDF_API ~LayerDirtinessChanged();
};
/// \class LayerMutenessChanged
///
/// Sent after a layer has been added or removed from the set of
/// muted layers. Note this does not necessarily mean the specified
/// layer is currently loaded.
///
class LayerMutenessChanged : public Base {
public:
LayerMutenessChanged(const std::string& layerPath, bool wasMuted)
: _layerPath(layerPath)
, _wasMuted(wasMuted)
{ }
SDF_API ~LayerMutenessChanged();
/// Returns the path of the layer that was muted or unmuted.
const std::string& GetLayerPath() const { return _layerPath; }
/// Returns true if the layer was muted, false if unmuted.
bool WasMuted() const { return _wasMuted; }
private:
std::string _layerPath;
bool _wasMuted;
};
};
PXR_NAMESPACE_CLOSE_SCOPE
#endif // PXR_USD_SDF_NOTICE_H