All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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_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 
34 PXR_NAMESPACE_OPEN_SCOPE
35 
36 SDF_DECLARE_HANDLES(SdfLayer);
37 
42 class SdfNotice {
43 public:
49  class Base : public TfNotice {
50  public:
51  SDF_API ~Base();
52  };
53 
59  public:
60  BaseLayersDidChange(const SdfLayerChangeListVec &changeVec,
61  size_t serialNumber)
62  : _vec(&changeVec)
63  , _serialNumber(serialNumber)
64  {}
65 
66  using const_iterator = SdfLayerChangeListVec::const_iterator;
67  using iterator = const_iterator;
68 
70  SDF_API
71  SdfLayerHandleVector GetLayers() const;
72 
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 
94  size_t GetSerialNumber() const { return _serialNumber; }
95 
96  private:
97  const SdfLayerChangeListVec *_vec;
98  const size_t _serialNumber;
99  };
100 
111  : public Base, public BaseLayersDidChange {
112  public:
113  LayersDidChangeSentPerLayer(const SdfLayerChangeListVec &changeVec,
114  size_t serialNumber)
115  : BaseLayersDidChange(changeVec, serialNumber) {}
116  SDF_API virtual ~LayersDidChangeSentPerLayer();
117  };
118 
124  : public Base, public BaseLayersDidChange {
125  public:
126  LayersDidChange(const SdfLayerChangeListVec &changeVec,
127  size_t serialNumber)
128  : BaseLayersDidChange(changeVec, serialNumber) {}
129  SDF_API virtual ~LayersDidChange();
130  };
131 
136  class LayerInfoDidChange : public Base {
137  public:
138  LayerInfoDidChange( const TfToken &key ) :
139  _key(key) {}
140  SDF_API ~LayerInfoDidChange();
141 
143  const TfToken & key() const { return _key; }
144  private:
145  TfToken _key;
146  };
147 
153  public:
154  SDF_API
155  LayerIdentifierDidChange(const std::string& oldIdentifier,
156  const std::string& newIdentifier);
157  SDF_API
158  ~LayerIdentifierDidChange();
159 
161  const std::string& GetOldIdentifier() const { return _oldId; }
162 
164  const std::string& GetNewIdentifier() const { return _newId; }
165 
166  private:
167  std::string _oldId;
168  std::string _newId;
169  };
170 
175  class LayerDidReplaceContent : public Base {
176  public:
177  SDF_API ~LayerDidReplaceContent();
178  };
179 
183  public:
184  SDF_API virtual ~LayerDidReloadContent();
185  };
186 
191  class LayerDidSaveLayerToFile : public Base {
192  public:
193  SDF_API ~LayerDidSaveLayerToFile();
194  };
195 
201  class LayerDirtinessChanged : public Base {
202  public:
203  SDF_API ~LayerDirtinessChanged();
204  };
205 
212  class LayerMutenessChanged : public Base {
213  public:
214  LayerMutenessChanged(const std::string& layerPath, bool wasMuted)
215  : _layerPath(layerPath)
216  , _wasMuted(wasMuted)
217  { }
218 
219  SDF_API ~LayerMutenessChanged();
220 
222  const std::string& GetLayerPath() const { return _layerPath; }
223 
225  bool WasMuted() const { return _wasMuted; }
226 
227  private:
228  std::string _layerPath;
229  bool _wasMuted;
230  };
231 };
232 
233 PXR_NAMESPACE_CLOSE_SCOPE
234 
235 #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:96
Wrapper class for Sdf notices.
Definition: notice.h:42
const std::string & GetLayerPath() const
Returns the path of the layer that was muted or unmuted.
Definition: notice.h:222
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:201
Base class for LayersDidChange and LayersDidChangeSentPerLayer.
Definition: notice.h:58
const SdfLayerChangeListVec & GetChangeListVec() const
A list of layers and the changes that occurred to them.
Definition: notice.h:74
bool WasMuted() const
Returns true if the layer was muted, false if unmuted.
Definition: notice.h:225
size_t GetSerialNumber() const
The serial number for this round of change processing.
Definition: notice.h:94
Sent after a layer has been added or removed from the set of muted layers.
Definition: notice.h:212
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:87
Base notification class for scene.
Definition: notice.h:49
Sent when the (scene spec) info of a layer have changed.
Definition: notice.h:136
const std::string & GetOldIdentifier() const
Returns the old identifier for the layer.
Definition: notice.h:161
Global notice sent to indicate that layer contents have changed.
Definition: notice.h:123
Sent after a menv layer has been loaded from a file.
Definition: notice.h:175
Notice sent per-layer indicating all layers whose contents have changed within a single round of chan...
Definition: notice.h:110
const std::string & GetNewIdentifier() const
Returns the new identifier for the layer.
Definition: notice.h:164
const TfToken & key() const
Return the key affected.
Definition: notice.h:143
Sent after a layer is reloaded.
Definition: notice.h:182
Sent when the identifier of a layer has changed.
Definition: notice.h:152
Sent after a layer is saved to file.
Definition: notice.h:191