HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
notice.h
Go to the documentation of this file.
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"
12 #include "pxr/usd/sdf/changeList.h"
14 #include "pxr/usd/sdf/path.h"
15 #include "pxr/base/tf/notice.h"
16 
18 
20 
21 /// \class SdfNotice
22 ///
23 /// Wrapper class for Sdf notices.
24 ///
25 class SdfNotice {
26 public:
27  /// \class Base
28  ///
29  /// Base notification class for scene. Only useful for type hierarchy
30  /// purposes.
31  ///
32  class Base : public TfNotice {
33  public:
34  SDF_API ~Base();
35  };
36 
37  /// \class BaseLayersDidChange
38  ///
39  /// Base class for LayersDidChange and LayersDidChangeSentPerLayer.
40  ///
42  public:
44  size_t serialNumber)
45  : _vec(&changeVec)
46  , _serialNumber(serialNumber)
47  {}
48 
49  using const_iterator = SdfLayerChangeListVec::const_iterator;
51 
52  /// A list of layers changed.
53  SDF_API
54  SdfLayerHandleVector GetLayers() const;
55 
56  /// A list of layers and the changes that occurred to them.
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 
76  /// The serial number for this round of change processing.
77  size_t GetSerialNumber() const { return _serialNumber; }
78 
79  private:
80  const SdfLayerChangeListVec *_vec;
81  const size_t _serialNumber;
82  };
83 
84  /// \class LayersDidChangeSentPerLayer
85  ///
86  /// Notice sent per-layer indicating all layers whose contents have changed
87  /// within a single round of change processing. If more than one layer
88  /// changes in a single round of change processing, we send this notice once
89  /// per layer with the same changeVec and serialNumber. This is so clients
90  /// can listen to notices from only the set of layers they care about rather
91  /// than listening to the global LayersDidChange notice.
92  ///
94  : public Base, public BaseLayersDidChange {
95  public:
97  size_t serialNumber)
98  : BaseLayersDidChange(changeVec, serialNumber) {}
100  };
101 
102  /// \class LayersDidChange
103  ///
104  /// Global notice sent to indicate that layer contents have changed.
105  ///
107  : public Base, public BaseLayersDidChange {
108  public:
110  size_t serialNumber)
111  : BaseLayersDidChange(changeVec, serialNumber) {}
112  SDF_API virtual ~LayersDidChange();
113  };
114 
115  /// \class LayerInfoDidChange
116  ///
117  /// Sent when the (scene spec) info of a layer have changed.
118  ///
119  class LayerInfoDidChange : public Base {
120  public:
122  _key(key) {}
124 
125  /// Return the key affected.
126  const TfToken & key() const { return _key; }
127  private:
128  TfToken _key;
129  };
130 
131  /// \class LayerIdentifierDidChange
132  ///
133  /// Sent when the identifier of a layer has changed.
134  ///
136  public:
137  SDF_API
138  LayerIdentifierDidChange(const std::string& oldIdentifier,
139  const std::string& newIdentifier);
140  SDF_API
142 
143  /// Returns the old identifier for the layer.
144  const std::string& GetOldIdentifier() const { return _oldId; }
145 
146  /// Returns the new identifier for the layer.
147  const std::string& GetNewIdentifier() const { return _newId; }
148 
149  private:
150  std::string _oldId;
151  std::string _newId;
152  };
153 
154  /// \class LayerDidReplaceContent
155  ///
156  /// Sent after a layer has been loaded from a file.
157  ///
158  class LayerDidReplaceContent : public Base {
159  public:
161  };
162 
163  /// \class LayerDidReloadContent
164  /// Sent after a layer is reloaded.
166  public:
168  };
169 
170  /// \class LayerDidSaveLayerToFile
171  ///
172  /// Sent after a layer is saved to file.
173  ///
174  class LayerDidSaveLayerToFile : public Base {
175  public:
177  };
178 
179  /// \class LayerDirtinessChanged
180  ///
181  /// Similar behavior to LayersDidChange, but only gets sent if a change
182  /// in the dirty status of a layer occurs.
183  ///
184  class LayerDirtinessChanged : public Base {
185  public:
187  };
188 
189  /// \class LayerMutenessChanged
190  ///
191  /// Sent after a layer has been added or removed from the set of
192  /// muted layers. Note this does not necessarily mean the specified
193  /// layer is currently loaded.
194  ///
195  class LayerMutenessChanged : public Base {
196  public:
197  LayerMutenessChanged(const std::string& layerPath, bool wasMuted)
198  : _layerPath(layerPath)
199  , _wasMuted(wasMuted)
200  { }
201 
203 
204  /// Returns the path of the layer that was muted or unmuted.
205  const std::string& GetLayerPath() const { return _layerPath; }
206 
207  /// Returns true if the layer was muted, false if unmuted.
208  bool WasMuted() const { return _wasMuted; }
209 
210  private:
211  std::string _layerPath;
212  bool _wasMuted;
213  };
214 };
215 
217 
218 #endif // PXR_USD_SDF_NOTICE_H
const_iterator cend() const
Definition: notice.h:62
const SdfLayerChangeListVec & GetChangeListVec() const
A list of layers and the changes that occurred to them.
Definition: notice.h:57
Definition: layer.h:81
virtual SDF_API ~LayersDidChange()
const_iterator iterator
Definition: notice.h:50
const std::string & GetLayerPath() const
Returns the path of the layer that was muted or unmuted.
Definition: notice.h:205
const_iterator begin() const
Definition: notice.h:59
LayerMutenessChanged(const std::string &layerPath, bool wasMuted)
Definition: notice.h:197
virtual SDF_API ~LayerDidReloadContent()
uint64 value_type
Definition: GA_PrimCompat.h:29
SDF_API SdfLayerHandleVector GetLayers() const
A list of layers changed.
const_iterator end() const
Definition: notice.h:61
SdfLayerChangeListVec::const_iterator const_iterator
Definition: notice.h:49
GLenum GLuint GLint GLint layer
Definition: glcorearb.h:1299
LayersDidChangeSentPerLayer(const SdfLayerChangeListVec &changeVec, size_t serialNumber)
Definition: notice.h:96
const_iterator cbegin() const
Definition: notice.h:60
PXR_NAMESPACE_OPEN_SCOPE SDF_DECLARE_HANDLES(SdfLayer)
Definition: token.h:70
const std::string & GetNewIdentifier() const
Returns the new identifier for the layer.
Definition: notice.h:147
size_t GetSerialNumber() const
The serial number for this round of change processing.
Definition: notice.h:77
SDF_API LayerIdentifierDidChange(const std::string &oldIdentifier, const std::string &newIdentifier)
#define SDF_API
Definition: api.h:23
LayerInfoDidChange(const TfToken &key)
Definition: notice.h:121
std::vector< std::pair< SdfLayerHandle, SdfChangeList > > SdfLayerChangeListVec
Definition: changeList.h:25
const_iterator find(SdfLayerHandle const &layer) const
Definition: notice.h:64
const std::string & GetOldIdentifier() const
Returns the old identifier for the layer.
Definition: notice.h:144
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
LayersDidChange(const SdfLayerChangeListVec &changeVec, size_t serialNumber)
Definition: notice.h:109
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
bool WasMuted() const
Returns true if the layer was muted, false if unmuted.
Definition: notice.h:208
virtual SDF_API ~LayersDidChangeSentPerLayer()
SDF_API ~Base()
BaseLayersDidChange(const SdfLayerChangeListVec &changeVec, size_t serialNumber)
Definition: notice.h:43
bool count(SdfLayerHandle const &layer) const
Definition: notice.h:72
const TfToken & key() const
Return the key affected.
Definition: notice.h:126