Loading...
Searching...
No Matches
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"
34
35PXR_NAMESPACE_OPEN_SCOPE
36
37SDF_DECLARE_HANDLES(SdfLayer);
38
42
44class SdfPath;
45class TfToken;
46
59 : public TfRefBase
60 , public TfWeakBase
61{
62public:
63 SDF_API
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 VtValue *oldValue=NULL);
75
76 SDF_API
77 void SetField(
78 const SdfPath& path,
79 const TfToken& field,
80 const SdfAbstractDataConstValue& value,
81 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 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 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
151protected:
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
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
255private:
256 friend class SdfLayer;
257 SDF_API void _SetLayer(const SdfLayerHandle& layer);
258
259private:
260 SdfLayerHandle _layer;
261};
262
268{
269public:
270 SDF_API
271 static SdfSimpleLayerStateDelegateRefPtr New();
272
273protected:
274 SDF_API
276
277 // SdfLayerStateDelegateBase overrides
278 SDF_API
279 virtual bool _IsDirty() override;
280
281 SDF_API
282 virtual void _MarkCurrentStateAsClean() override;
283
284 SDF_API
285 virtual void _MarkCurrentStateAsDirty() override;
286
287 SDF_API
288 virtual void _OnSetLayer(
289 const SdfLayerHandle& layer) override;
290
291 SDF_API
292 virtual void _OnSetField(
293 const SdfPath& path,
294 const TfToken& fieldName,
295 const VtValue& value) override;
296
297 SDF_API
298 virtual void _OnSetField(
299 const SdfPath& path,
300 const TfToken& fieldName,
301 const SdfAbstractDataConstValue& value) override;
302
303 SDF_API
305 const SdfPath& path,
306 const TfToken& fieldName,
307 const TfToken& keyPath,
308 const VtValue& value) override;
309
310 SDF_API
311 virtual void _OnSetFieldDictValueByKey(
312 const SdfPath& path,
313 const TfToken& fieldName,
314 const TfToken& keyPath,
315 const SdfAbstractDataConstValue& value) override;
316
317 SDF_API
318 virtual void _OnSetTimeSample(
319 const SdfPath& path,
320 double time,
321 const VtValue& value) override;
322
323 SDF_API
324 virtual void _OnSetTimeSample(
325 const SdfPath& path,
326 double time,
327 const SdfAbstractDataConstValue& value) override;
328
329 SDF_API
330 virtual void _OnCreateSpec(
331 const SdfPath& path,
332 SdfSpecType specType,
333 bool inert) override;
334
335 SDF_API
336 virtual void _OnDeleteSpec(
337 const SdfPath& path,
338 bool inert) override;
339
340 SDF_API
341 virtual void _OnMoveSpec(
342 const SdfPath& oldPath,
343 const SdfPath& newPath) override;
344
345 SDF_API
346 virtual void _OnPushChild(
347 const SdfPath& path,
348 const TfToken& fieldName,
349 const TfToken& value) override;
350
351 SDF_API
352 virtual void _OnPushChild(
353 const SdfPath& path,
354 const TfToken& fieldName,
355 const SdfPath& value) override;
356
357 SDF_API
358 virtual void _OnPopChild(
359 const SdfPath& path,
360 const TfToken& fieldName,
361 const TfToken& oldValue) override;
362
363 SDF_API
364 virtual void _OnPopChild(
365 const SdfPath& path,
366 const TfToken& fieldName,
367 const SdfPath& oldValue) override;
368
369private:
370 bool _dirty;
371};
372
373PXR_NAMESPACE_CLOSE_SCOPE
374
375#endif // PXR_USD_SDF_LAYER_STATE_DELEGATE_H
A type-erased container for a const field value in an SdfAbstractData.
Definition: abstractData.h:520
Interface for scene description data storage.
Definition: abstractData.h:74
A scene description container that can combine with other such containers to form simple component as...
Definition: layer.h:100
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:291
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:73
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:88
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:165
Standard pointer typedefs.
#define TF_DECLARE_WEAK_PTRS(type)
Define standard weak pointer types.
Definition: declarePtrs.h:62
#define TF_DECLARE_WEAK_AND_REF_PTRS(type)
Define standard weak, ref, and vector pointer types.
Definition: declarePtrs.h:89
Basic Sdf data types.
SdfSpecType
An enum that specifies the type of an object.
Definition: types.h:84