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 
28 
29 #include "pxr/pxr.h"
30 #include "pxr/usd/sdf/api.h"
31 #include "pxr/usd/sdf/changeList.h"
32 #include "pxr/usd/sdf/declareHandles.h"
33 #include "pxr/usd/sdf/path.h"
34 #include "pxr/base/tf/notice.h"
35 
36 PXR_NAMESPACE_OPEN_SCOPE
37 
38 SDF_DECLARE_HANDLES(SdfLayer);
39 
44 class SdfNotice {
45 public:
51  class Base : public TfNotice {
52  public:
53  SDF_API ~Base();
54  };
55 
61  public:
62  BaseLayersDidChange(const SdfLayerChangeListVec &changeVec,
63  size_t serialNumber)
64  : _vec(&changeVec)
65  , _serialNumber(serialNumber)
66  {}
67 
68  using const_iterator = SdfLayerChangeListVec::const_iterator;
69  using iterator = const_iterator;
70 
72  SDF_API
73  SdfLayerHandleVector GetLayers() const;
74 
76  const SdfLayerChangeListVec &GetChangeListVec() const { return *_vec; }
77 
78  const_iterator begin() const { return _vec->begin(); }
79  const_iterator cbegin() const { return _vec->cbegin(); }
80  const_iterator end() const { return _vec->end(); }
81  const_iterator cend() const { return _vec->cend(); }
82 
83  const_iterator find(SdfLayerHandle const &layer) const {
84  return std::find_if(
85  begin(), end(),
86  [&layer](SdfLayerChangeListVec::value_type const &p) {
87  return p.first == layer;
88  });
89  }
90 
91  bool count(SdfLayerHandle const &layer) const {
92  return find(layer) != end();
93  }
94 
96  size_t GetSerialNumber() const { return _serialNumber; }
97 
98  private:
99  const SdfLayerChangeListVec *_vec;
100  const size_t _serialNumber;
101  };
102 
113  : public Base, public BaseLayersDidChange {
114  public:
115  LayersDidChangeSentPerLayer(const SdfLayerChangeListVec &changeVec,
116  size_t serialNumber)
117  : BaseLayersDidChange(changeVec, serialNumber) {}
118  SDF_API virtual ~LayersDidChangeSentPerLayer();
119  };
120 
126  : public Base, public BaseLayersDidChange {
127  public:
128  LayersDidChange(const SdfLayerChangeListVec &changeVec,
129  size_t serialNumber)
130  : BaseLayersDidChange(changeVec, serialNumber) {}
131  SDF_API virtual ~LayersDidChange();
132  };
133 
138  class LayerInfoDidChange : public Base {
139  public:
140  LayerInfoDidChange( const TfToken &key ) :
141  _key(key) {}
142  SDF_API ~LayerInfoDidChange();
143 
145  const TfToken & key() const { return _key; }
146  private:
147  TfToken _key;
148  };
149 
155  public:
156  SDF_API
157  LayerIdentifierDidChange(const std::string& oldIdentifier,
158  const std::string& newIdentifier);
159  SDF_API
160  ~LayerIdentifierDidChange();
161 
163  const std::string& GetOldIdentifier() const { return _oldId; }
164 
166  const std::string& GetNewIdentifier() const { return _newId; }
167 
168  private:
169  std::string _oldId;
170  std::string _newId;
171  };
172 
177  class LayerDidReplaceContent : public Base {
178  public:
179  SDF_API ~LayerDidReplaceContent();
180  };
181 
185  public:
186  SDF_API virtual ~LayerDidReloadContent();
187  };
188 
193  class LayerDidSaveLayerToFile : public Base {
194  public:
195  SDF_API ~LayerDidSaveLayerToFile();
196  };
197 
203  class LayerDirtinessChanged : public Base {
204  public:
205  SDF_API ~LayerDirtinessChanged();
206  };
207 
214  class LayerMutenessChanged : public Base {
215  public:
216  LayerMutenessChanged(const std::string& layerPath, bool wasMuted)
217  : _layerPath(layerPath)
218  , _wasMuted(wasMuted)
219  { }
220 
221  SDF_API ~LayerMutenessChanged();
222 
224  const std::string& GetLayerPath() const { return _layerPath; }
225 
227  bool WasMuted() const { return _wasMuted; }
228 
229  private:
230  std::string _layerPath;
231  bool _wasMuted;
232  };
233 };
234 
235 PXR_NAMESPACE_CLOSE_SCOPE
236 
237 #endif // PXR_USD_SDF_NOTICE_H
SDF_API SdfLayerHandleVector GetLayers() const
A list of layers changed.
A unit of scene description that you combine with other units of scene description to form a shot...
Definition: layer.h:93
const std::string & GetLayerPath() const
Returns the path of the layer that was muted or unmuted.
Definition: notice.h:224
The base class for objects used to notify interested parties (listeners) when events have occurred...
Definition: notice.h:93
Similar behavior to LayersDidChange, but only gets sent if a change in the dirty status of a layer oc...
Definition: notice.h:203
Wrapper class for Sdf notices.
Definition: notice.h:44
Base class for LayersDidChange and LayersDidChangeSentPerLayer.
Definition: notice.h:60
const SdfLayerChangeListVec & GetChangeListVec() const
A list of layers and the changes that occurred to them.
Definition: notice.h:76
bool WasMuted() const
Returns true if the layer was muted, false if unmuted.
Definition: notice.h:227
size_t GetSerialNumber() const
The serial number for this round of change processing.
Definition: notice.h:96
Sent after a layer has been added or removed from the set of muted layers.
Definition: notice.h:214
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:89
Base notification class for scene.
Definition: notice.h:51
Sent when the (scene spec) info of a layer have changed.
Definition: notice.h:138
const std::string & GetOldIdentifier() const
Returns the old identifier for the layer.
Definition: notice.h:163
Global notice sent to indicate that layer contents have changed.
Definition: notice.h:125
Sent after a menv layer has been loaded from a file.
Definition: notice.h:177
Notice sent per-layer indicating all layers whose contents have changed within a single round of chan...
Definition: notice.h:112
const std::string & GetNewIdentifier() const
Returns the new identifier for the layer.
Definition: notice.h:166
const TfToken & key() const
Return the key affected.
Definition: notice.h:145
Sent after a layer is reloaded.
Definition: notice.h:184
Sent when the identifier of a layer has changed.
Definition: notice.h:154
Sent after a layer is saved to file.
Definition: notice.h:193