Loading...
Searching...
No Matches
notice.h
1//
2// Copyright 2016 Pixar
3//
4// Licensed under the Apache License, Version 2.0 (the "Apache License")
5// with the following modification; you may not use this file except in
6// compliance with the Apache License and the following modification to it:
7// Section 6. Trademarks. is deleted and replaced with:
8//
9// 6. Trademarks. This License does not grant permission to use the trade
10// names, trademarks, service marks, or product names of the Licensor
11// and its affiliates, except as required to comply with Section 4(c) of
12// the License and to reproduce the content of the NOTICE file.
13//
14// You may obtain a copy of the Apache License at
15//
16// http://www.apache.org/licenses/LICENSE-2.0
17//
18// Unless required by applicable law or agreed to in writing, software
19// distributed under the Apache License with the above modification is
20// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21// KIND, either express or implied. See the Apache License for the specific
22// language governing permissions and limitations under the Apache License.
23//
24#ifndef PXR_USD_USD_NOTICE_H
25#define PXR_USD_USD_NOTICE_H
26
27#include "pxr/pxr.h"
28#include "pxr/usd/usd/api.h"
29#include "pxr/usd/usd/common.h"
30#include "pxr/usd/usd/object.h"
31
33#include "pxr/usd/sdf/path.h"
34#include "pxr/base/tf/notice.h"
35
36PXR_NAMESPACE_OPEN_SCOPE
37
38
43class UsdNotice {
44public:
45
47 class StageNotice : public TfNotice {
48 public:
49 USD_API
50 StageNotice(const UsdStageWeakPtr &stage);
51 USD_API
52 virtual ~StageNotice();
53
55 const UsdStageWeakPtr &GetStage() const { return _stage; }
56
57 private:
58 UsdStageWeakPtr _stage;
59 };
60
74 public:
75 explicit StageContentsChanged(const UsdStageWeakPtr& stage)
76 : StageNotice(stage) {}
77 USD_API virtual ~StageContentsChanged();
78 };
79
129 using _PathsToChangesMap =
130 std::map<SdfPath, std::vector<const SdfChangeList::Entry*>>;
131
132 static const _PathsToChangesMap& _GetEmptyChangesMap();
133
134 friend class UsdStage;
135 ObjectsChanged(const UsdStageWeakPtr &stage,
136 const _PathsToChangesMap *resyncChanges,
137 const _PathsToChangesMap *infoChanges,
138 const _PathsToChangesMap *assetPathChanges)
139 : StageNotice(stage)
140 , _resyncChanges(resyncChanges)
141 , _infoChanges(infoChanges)
142 , _assetPathChanges(assetPathChanges) {}
143
144 ObjectsChanged(const UsdStageWeakPtr &stage,
145 const _PathsToChangesMap *resyncChanges);
146
147 public:
148 USD_API virtual ~ObjectsChanged();
149
156 bool AffectedObject(const UsdObject &obj) const {
157 return ResyncedObject(obj) || ResolvedAssetPathsResynced(obj)
158 || ChangedInfoOnly(obj);
159 }
160
164 USD_API bool ResyncedObject(const UsdObject &obj) const;
165
170 USD_API bool ResolvedAssetPathsResynced(const UsdObject &obj) const;
171
175 USD_API bool ChangedInfoOnly(const UsdObject &obj) const;
176
184 {
185 public:
187 class iterator {
188 using _UnderlyingIterator = _PathsToChangesMap::const_iterator;
189 public:
190 using iterator_category = std::forward_iterator_tag;
191 using value_type = const SdfPath&;
192 using reference = const SdfPath&;
193 using pointer = const SdfPath*;
194 using difference_type =
195 typename _UnderlyingIterator::difference_type;
196
197 iterator() = default;
198 reference operator*() const { return dereference(); }
199 pointer operator->() const { return &(dereference()); }
200
201 iterator& operator++() {
202 ++_underlyingIterator;
203 return *this;
204 }
205
206 iterator operator++(int) {
207 iterator result = *this;
208 ++_underlyingIterator;
209 return result;
210 }
211
212 bool operator==(const iterator& other) const{
213 return _underlyingIterator == other._underlyingIterator;
214 }
215
216 bool operator!=(const iterator& other) const{
217 return _underlyingIterator != other._underlyingIterator;
218 }
219
224 USD_API TfTokenVector GetChangedFields() const;
225
230 USD_API bool HasChangedFields() const;
231
233 _UnderlyingIterator GetBase() const {
234 return _underlyingIterator;
235 }
236
238 _UnderlyingIterator base() const {
239 return GetBase();
240 }
241
242 private:
243 friend class PathRange;
244
245 explicit iterator(_UnderlyingIterator baseIter)
246 : _underlyingIterator(baseIter) {}
247
248 inline reference dereference() const {
249 return _underlyingIterator->first;
250 }
251
252 _UnderlyingIterator _underlyingIterator;
253 };
254
255 using const_iterator = iterator;
256
257 PathRange() : _changes(nullptr) { }
258
260 explicit operator SdfPathVector() const {
261 return SdfPathVector(begin(), end());
262 }
263
265 bool empty() const {
266 return !_changes || _changes->empty();
267 }
268
270 size_t size() const {
271 return _changes ? _changes->size() : 0;
272 }
273
275 iterator begin() const {
276 return iterator(_changes->cbegin());
277 }
278
280 const_iterator cbegin() const {
281 return iterator(_changes->cbegin());
282 }
283
285 iterator end() const {
286 return iterator(_changes->cend());
287 }
288
290 const_iterator cend() const {
291 return iterator(_changes->cend());
292 }
293
297 const_iterator find(const SdfPath& path) const {
298 return const_iterator(_changes->find(path));
299 }
300
301 private:
302 friend class ObjectsChanged;
303 explicit PathRange(const _PathsToChangesMap* changes)
304 : _changes(changes)
305 { }
306
307 const _PathsToChangesMap* _changes;
308 };
309
325
341
358
370 USD_API TfTokenVector GetChangedFields(const UsdObject &obj) const;
371
373 USD_API TfTokenVector GetChangedFields(const SdfPath &path) const;
374
377 USD_API bool HasChangedFields(const UsdObject &obj) const;
378
380 USD_API bool HasChangedFields(const SdfPath &path) const;
381
382 private:
383 const _PathsToChangesMap *_resyncChanges;
384 const _PathsToChangesMap *_infoChanges;
385 const _PathsToChangesMap *_assetPathChanges;
386 };
387
394 public:
395 explicit StageEditTargetChanged(const UsdStageWeakPtr &stage)
396 : StageNotice(stage) {}
397 USD_API virtual ~StageEditTargetChanged();
398 };
399
415 public:
416 explicit LayerMutingChanged(const UsdStageWeakPtr &stage,
417 const std::vector<std::string>& mutedLayers,
418 const std::vector<std::string>& unmutedLayers)
419 : StageNotice(stage),
420 _mutedLayers(mutedLayers),
421 _unMutedLayers(unmutedLayers) {}
422
423 USD_API virtual ~LayerMutingChanged();
424
430 const std::vector<std::string>& GetMutedLayers() const {
431 return _mutedLayers;
432 }
433
439 const std::vector<std::string>& GetUnmutedLayers() const {
440 return _unMutedLayers;
441 }
442
443 private:
444 const std::vector<std::string>& _mutedLayers;
445 const std::vector<std::string>& _unMutedLayers;
446 };
447
448};
449
450
451PXR_NAMESPACE_CLOSE_SCOPE
452
453#endif // PXR_USD_USD_NOTICE_H
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:290
The base class for objects used to notify interested parties (listeners) when events have occurred.
Definition: notice.h:93
Notice sent after a set of layers have been newly muted or unmuted.
Definition: notice.h:414
const std::vector< std::string > & GetMutedLayers() const
Returns the identifier of the layers that were muted.
Definition: notice.h:430
const std::vector< std::string > & GetUnmutedLayers() const
Returns the identifier of the layers that were unmuted.
Definition: notice.h:439
An iterable range of paths to objects that have changed.
Definition: notice.h:184
iterator begin() const
Return iterator to the start of this range.
Definition: notice.h:275
size_t size() const
Return the number of paths in this range.
Definition: notice.h:270
const_iterator cbegin() const
Return iterator to the start of this range.
Definition: notice.h:280
bool empty() const
Return true if this range contains any paths, false otherwise.
Definition: notice.h:265
iterator end() const
Return the end iterator for this range.
Definition: notice.h:285
const_iterator cend() const
Return the end iterator for this range.
Definition: notice.h:290
const_iterator find(const SdfPath &path) const
Return an iterator to the specified path in this range if it exists, or end() if it does not.
Definition: notice.h:297
Notice sent in response to authored changes that affect UsdObjects.
Definition: notice.h:128
USD_API PathRange GetChangedInfoOnlyPaths() const
Return the set of paths that have only info changes (those that do not affect the structure of cached...
bool AffectedObject(const UsdObject &obj) const
Return true if obj was possibly affected by the layer changes that generated this notice.
Definition: notice.h:156
USD_API TfTokenVector GetChangedFields(const UsdObject &obj) const
Return the set of changed fields in layers that affected obj.
USD_API TfTokenVector GetChangedFields(const SdfPath &path) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
USD_API bool ResolvedAssetPathsResynced(const UsdObject &obj) const
Return true if asset path values in obj were resynced by the layer changes that generated this notice...
USD_API PathRange GetResyncedPaths() const
Return the set of paths that are resynced in lexicographical order.
USD_API bool HasChangedFields(const UsdObject &obj) const
Return true if there are any changed fields that affected obj, false otherwise.
USD_API bool HasChangedFields(const SdfPath &path) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
USD_API PathRange GetResolvedAssetPathsResyncedPaths() const
Return the set of paths affected by changes that may cause asset path values to resolve to different ...
USD_API bool ChangedInfoOnly(const UsdObject &obj) const
Return true if obj was changed but not resynced by the layer changes that generated this notice.
USD_API bool ResyncedObject(const UsdObject &obj) const
Return true if obj was resynced by the layer changes that generated this notice.
Ultra-conservative notice sent when the given UsdStage's contents have changed in any way.
Definition: notice.h:73
Notice sent when a stage's EditTarget has changed.
Definition: notice.h:393
Base class for UsdStage notices.
Definition: notice.h:47
const UsdStageWeakPtr & GetStage() const
Return the stage associated with this notice.
Definition: notice.h:55
Container class for Usd notices.
Definition: notice.h:43
Base class for Usd scenegraph objects, providing common API.
Definition: object.h:132
The outermost container for scene description, which owns and presents composed prims as a scenegraph...
Definition: stage.h:151
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:457