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