All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
layerStateDelegate.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_LAYER_STATE_DELEGATE_H
25 #define PXR_USD_SDF_LAYER_STATE_DELEGATE_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/usd/sdf/api.h"
30 #include "pxr/usd/sdf/types.h"
32 #include "pxr/base/tf/refBase.h"
33 #include "pxr/base/tf/weakBase.h"
34 
35 PXR_NAMESPACE_OPEN_SCOPE
36 
37 SDF_DECLARE_HANDLES(SdfLayer);
38 
42 
44 class SdfPath;
45 class TfToken;
46 
59  : public TfRefBase
60  , public TfWeakBase
61 {
62 public:
63  SDF_API
64  virtual ~SdfLayerStateDelegateBase();
65 
66  SDF_API
67  bool IsDirty();
68 
69  SDF_API
70  void SetField(
71  const SdfPath& path,
72  const TfToken& field,
73  const VtValue& value,
74  const VtValue *oldValue=NULL);
75 
76  SDF_API
77  void SetField(
78  const SdfPath& path,
79  const TfToken& field,
80  const SdfAbstractDataConstValue& value,
81  const VtValue *oldValue=NULL);
82 
83  SDF_API
84  void SetFieldDictValueByKey(
85  const SdfPath& path,
86  const TfToken& field,
87  const TfToken& keyPath,
88  const VtValue& value,
89  const VtValue *oldValue=NULL);
90 
91  SDF_API
92  void SetFieldDictValueByKey(
93  const SdfPath& path,
94  const TfToken& field,
95  const TfToken& keyPath,
96  const SdfAbstractDataConstValue& value,
97  const VtValue *oldValue=NULL);
98 
99  SDF_API
100  void SetTimeSample(
101  const SdfPath& path,
102  double time,
103  const VtValue& value);
104 
105  SDF_API
106  void SetTimeSample(
107  const SdfPath& path,
108  double time,
109  const SdfAbstractDataConstValue& value);
110 
111  SDF_API
112  void CreateSpec(
113  const SdfPath& path,
114  SdfSpecType specType,
115  bool inert);
116 
117  SDF_API
118  void DeleteSpec(
119  const SdfPath& path,
120  bool inert);
121 
122  SDF_API
123  void MoveSpec(
124  const SdfPath& oldPath,
125  const SdfPath& newPath);
126 
127  SDF_API
128  void PushChild(
129  const SdfPath& parentPath,
130  const TfToken& field,
131  const TfToken& value);
132 
133  SDF_API
134  void PushChild(
135  const SdfPath& parentPath,
136  const TfToken& field,
137  const SdfPath& value);
138 
139  SDF_API
140  void PopChild(
141  const SdfPath& parentPath,
142  const TfToken& field,
143  const TfToken& oldValue);
144 
145  SDF_API
146  void PopChild(
147  const SdfPath& parentPath,
148  const TfToken& field,
149  const SdfPath& oldValue);
150 
151 protected:
152  SDF_API
154 
157  SDF_API
158  SdfLayerHandle _GetLayer() const;
159 
162  SDF_API
163  SdfAbstractDataPtr _GetLayerData() const;
164 
167  virtual bool _IsDirty() = 0;
168 
171  virtual void _MarkCurrentStateAsClean() = 0;
172 
175  virtual void _MarkCurrentStateAsDirty() = 0;
176 
179  virtual void _OnSetLayer(
180  const SdfLayerHandle& layer) = 0;
181 
183  virtual void _OnSetField(
184  const SdfPath& path,
185  const TfToken& fieldName,
186  const VtValue& value) = 0;
187  virtual void _OnSetField(
188  const SdfPath& path,
189  const TfToken& fieldName,
190  const SdfAbstractDataConstValue& value) = 0;
191 
193  virtual void _OnSetFieldDictValueByKey(
194  const SdfPath& path,
195  const TfToken& fieldName,
196  const TfToken& keyPath,
197  const VtValue& value) = 0;
198  virtual void _OnSetFieldDictValueByKey(
199  const SdfPath& path,
200  const TfToken& fieldName,
201  const TfToken& keyPath,
202  const SdfAbstractDataConstValue& value) = 0;
203 
205  virtual void _OnSetTimeSample(
206  const SdfPath& path,
207  double time,
208  const VtValue& value) = 0;
209  virtual void _OnSetTimeSample(
210  const SdfPath& path,
211  double time,
212  const SdfAbstractDataConstValue& value) = 0;
213 
215  virtual void _OnCreateSpec(
216  const SdfPath& path,
217  SdfSpecType specType,
218  bool inert) = 0;
219 
222  virtual void _OnDeleteSpec(
223  const SdfPath& path,
224  bool inert) = 0;
225 
227  virtual void _OnMoveSpec(
228  const SdfPath& oldPath,
229  const SdfPath& newPath) = 0;
230 
232  virtual void _OnPushChild(
233  const SdfPath& parentPath,
234  const TfToken& fieldName,
235  const TfToken& value) = 0;
236 
238  virtual void _OnPushChild(
239  const SdfPath& parentPath,
240  const TfToken& fieldName,
241  const SdfPath& value) = 0;
242 
244  virtual void _OnPopChild(
245  const SdfPath& parentPath,
246  const TfToken& fieldName,
247  const TfToken& oldValue) = 0;
248 
250  virtual void _OnPopChild(
251  const SdfPath& parentPath,
252  const TfToken& fieldName,
253  const SdfPath& oldValue) = 0;
254 
255 private:
256  friend class SdfLayer;
257  SDF_API void _SetLayer(const SdfLayerHandle& layer);
258 
259 private:
260  SdfLayerHandle _layer;
261 };
262 
268 {
269 public:
270  static SdfSimpleLayerStateDelegateRefPtr New();
271 
272 protected:
274 
275  // SdfLayerStateDelegateBase overrides
276  virtual bool _IsDirty() override;
277  virtual void _MarkCurrentStateAsClean() override;
278  virtual void _MarkCurrentStateAsDirty() override;
279 
280  virtual void _OnSetLayer(
281  const SdfLayerHandle& layer) override;
282 
283  virtual void _OnSetField(
284  const SdfPath& path,
285  const TfToken& fieldName,
286  const VtValue& value) override;
287  virtual void _OnSetField(
288  const SdfPath& path,
289  const TfToken& fieldName,
290  const SdfAbstractDataConstValue& value) override;
291  virtual void _OnSetFieldDictValueByKey(
292  const SdfPath& path,
293  const TfToken& fieldName,
294  const TfToken& keyPath,
295  const VtValue& value) override;
296  virtual void _OnSetFieldDictValueByKey(
297  const SdfPath& path,
298  const TfToken& fieldName,
299  const TfToken& keyPath,
300  const SdfAbstractDataConstValue& value) override;
301 
302  virtual void _OnSetTimeSample(
303  const SdfPath& path,
304  double time,
305  const VtValue& value) override;
306  virtual void _OnSetTimeSample(
307  const SdfPath& path,
308  double time,
309  const SdfAbstractDataConstValue& value) override;
310 
311  virtual void _OnCreateSpec(
312  const SdfPath& path,
313  SdfSpecType specType,
314  bool inert) override;
315 
316  virtual void _OnDeleteSpec(
317  const SdfPath& path,
318  bool inert) override;
319 
320  virtual void _OnMoveSpec(
321  const SdfPath& oldPath,
322  const SdfPath& newPath) override;
323 
324  virtual void _OnPushChild(
325  const SdfPath& path,
326  const TfToken& fieldName,
327  const TfToken& value) override;
328  virtual void _OnPushChild(
329  const SdfPath& path,
330  const TfToken& fieldName,
331  const SdfPath& value) override;
332  virtual void _OnPopChild(
333  const SdfPath& path,
334  const TfToken& fieldName,
335  const TfToken& oldValue) override;
336  virtual void _OnPopChild(
337  const SdfPath& path,
338  const TfToken& fieldName,
339  const SdfPath& oldValue) override;
340 
341 private:
342  bool _dirty;
343 };
344 
345 PXR_NAMESPACE_CLOSE_SCOPE
346 
347 #endif // PXR_USD_SDF_LAYER_STATE_DELEGATE_H
A unit of scene description that you combine with other units of scene description to form a shot...
Definition: layer.h:96
#define TF_DECLARE_WEAK_PTRS(type)
Define standard weak pointer types.
Definition: declarePtrs.h:62
virtual void _MarkCurrentStateAsClean() override
Mark the current state of the layer as clean, i.e.
Standard pointer typedefs.
virtual void _OnSetField(const SdfPath &path, const TfToken &fieldName, const VtValue &value) override
Invoked when a field is being changed on the associated layer.
SDF_API SdfLayerHandle _GetLayer() const
Returns the layer associated with this state delegate.
virtual void _OnCreateSpec(const SdfPath &path, SdfSpecType specType, bool inert) override
Invoked when a new spec is created on the associated layer.
SDF_API SdfAbstractDataPtr _GetLayerData() const
Returns the underlying data object for the layer associated with this state delegate.
A type-erased container for a const field value in an SdfAbstractData.
Definition: abstractData.h:477
virtual void _OnPushChild(const SdfPath &parentPath, const TfToken &fieldName, const TfToken &value)=0
Invoked when a child spec is pushed onto a parent's list of children.
virtual void _OnDeleteSpec(const SdfPath &path, bool inert) override
Invoked when a spec and its children are deleted from the associated layer.
virtual void _MarkCurrentStateAsDirty()=0
Mark the current state of the layer as dirty, i.e.
virtual void _OnMoveSpec(const SdfPath &oldPath, const SdfPath &newPath)=0
Invoked when a spec and its children are moved.
virtual void _OnSetLayer(const SdfLayerHandle &layer)=0
Invoked when the state delegate is associated with layer layer.
virtual void _OnCreateSpec(const SdfPath &path, SdfSpecType specType, bool inert)=0
Invoked when a new spec is created on the associated layer.
#define TF_DECLARE_WEAK_AND_REF_PTRS(type)
Define standard weak, ref, and vector pointer types.
Definition: declarePtrs.h:89
A layer state delegate that simply records whether any changes have been made to a layer...
virtual void _OnPushChild(const SdfPath &path, const TfToken &fieldName, const TfToken &value) override
Invoked when a child spec is pushed onto a parent's list of children.
virtual void _OnSetField(const SdfPath &path, const TfToken &fieldName, const VtValue &value)=0
Invoked when a field is being changed on the associated layer.
Basic Sdf data types.
Enable a concrete base class for use with TfRefPtr.
Definition: refBase.h:71
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:87
virtual void _MarkCurrentStateAsDirty() override
Mark the current state of the layer as dirty, i.e.
virtual void _OnSetTimeSample(const SdfPath &path, double time, const VtValue &value) override
Invoked when a time sample is being changed on the associated layer.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:288
virtual bool _IsDirty() override
Returns true if the associated layer has been authored to since the last time the layer was marked cl...
virtual void _OnPopChild(const SdfPath &path, const TfToken &fieldName, const TfToken &oldValue) override
Invoked when a child spec is popped off a parent's list of children.
virtual void _OnPopChild(const SdfPath &parentPath, const TfToken &fieldName, const TfToken &oldValue)=0
Invoked when a child spec is popped off a parent's list of children.
SdfSpecType
An enum that specifies the type of an object.
Definition: types.h:91
virtual bool _IsDirty()=0
Returns true if the associated layer has been authored to since the last time the layer was marked cl...
virtual void _OnDeleteSpec(const SdfPath &path, bool inert)=0
Invoked when a spec and its children are deleted from the associated layer.
Maintains authoring state information for an associated layer.
virtual void _OnSetLayer(const SdfLayerHandle &layer) override
Invoked when the state delegate is associated with layer layer.
virtual void _OnSetTimeSample(const SdfPath &path, double time, const VtValue &value)=0
Invoked when a time sample is being changed on the associated layer.
virtual void _OnSetFieldDictValueByKey(const SdfPath &path, const TfToken &fieldName, const TfToken &keyPath, const VtValue &value)=0
Invoked when a field dict key is being changed on the associated layer.
virtual void _OnSetFieldDictValueByKey(const SdfPath &path, const TfToken &fieldName, const TfToken &keyPath, const VtValue &value) override
Invoked when a field dict key is being changed on the associated layer.
Enable a concrete base class for use with TfWeakPtr.
Definition: weakBase.h:141
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:168
Interface for scene description data storage.
Definition: abstractData.h:73
virtual void _OnMoveSpec(const SdfPath &oldPath, const SdfPath &newPath) override
Invoked when a spec and its children are moved.
virtual void _MarkCurrentStateAsClean()=0
Mark the current state of the layer as clean, i.e.