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