Loading...
Searching...
No Matches
copyUtils.h
Go to the documentation of this file.
1//
2// Copyright 2017 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_COPY_UTILS_H
8#define PXR_USD_SDF_COPY_UTILS_H
9
11
12#include "pxr/pxr.h"
13#include "pxr/usd/sdf/api.h"
14
16#include "pxr/usd/sdf/types.h"
17
18#include <functional>
19#include <optional>
20
21PXR_NAMESPACE_OPEN_SCOPE
22
23class SdfPath;
24class TfToken;
25class VtValue;
26SDF_DECLARE_HANDLES(SdfLayer);
27
30
56SDF_API
57bool
59 const SdfLayerHandle& srcLayer, const SdfPath& srcPath,
60 const SdfLayerHandle& dstLayer, const SdfPath& dstPath);
61
63
66
82using SdfShouldCopyValueFn = std::function<
83 bool(SdfSpecType specType, const TfToken& field,
84 const SdfLayerHandle& srcLayer, const SdfPath& srcPath, bool fieldInSrc,
85 const SdfLayerHandle& dstLayer, const SdfPath& dstPath, bool fieldInDst,
86 std::optional<VtValue>* valueToCopy)>;
87
100{
101public:
105 std::function<void(const SdfLayerHandle&, const SdfPath&)>;
106
107 explicit SdfCopySpecsValueEdit(const EditFunction& edit) : _edit(edit) { }
108 const EditFunction& GetEditFunction() const { return _edit; }
109
112 bool operator==(const SdfCopySpecsValueEdit& rhs) const { return false; }
113 bool operator!=(const SdfCopySpecsValueEdit& rhs) const { return true; }
114
115private:
116 EditFunction _edit;
117};
118
134using SdfShouldCopyChildrenFn = std::function<
135 bool(const TfToken& childrenField,
136 const SdfLayerHandle& srcLayer, const SdfPath& srcPath, bool fieldInSrc,
137 const SdfLayerHandle& dstLayer, const SdfPath& dstPath, bool fieldInDst,
138 std::optional<VtValue>* srcChildren,
139 std::optional<VtValue>* dstChildren)>;
140
149SDF_API
150bool
152 const SdfPath& srcRootPath, const SdfPath& dstRootPath,
153 SdfSpecType specType, const TfToken& field,
154 const SdfLayerHandle& srcLayer, const SdfPath& srcPath, bool fieldInSrc,
155 const SdfLayerHandle& dstLayer, const SdfPath& dstPath, bool fieldInDst,
156 std::optional<VtValue>* valueToCopy);
157
166SDF_API
167bool
169 const SdfPath& srcRootPath, const SdfPath& dstRootPath,
170 const TfToken& childrenField,
171 const SdfLayerHandle& srcLayer, const SdfPath& srcPath, bool fieldInSrc,
172 const SdfLayerHandle& dstLayer, const SdfPath& dstPath, bool fieldInDst,
173 std::optional<VtValue>* srcChildren,
174 std::optional<VtValue>* dstChildren);
175
199SDF_API
200bool
202 const SdfLayerHandle& srcLayer, const SdfPath& srcPath,
203 const SdfLayerHandle& dstLayer, const SdfPath& dstPath,
204 const SdfShouldCopyValueFn& shouldCopyValueFn,
205 const SdfShouldCopyChildrenFn& shouldCopyChildrenFn);
206
208
209PXR_NAMESPACE_CLOSE_SCOPE
210
211#endif // PXR_USD_SDF_COPY_UTILS_H
Value containing an editing operation for SdfCopySpecs.
Definition: copyUtils.h:100
bool operator==(const SdfCopySpecsValueEdit &rhs) const
SdfCopySpecsValueEdit objects are not comparable, but must provide operator== to be stored in a VtVal...
Definition: copyUtils.h:112
std::function< void(const SdfLayerHandle &, const SdfPath &)> EditFunction
Callback to apply a scene description edit to the specified layer and spec path.
Definition: copyUtils.h:105
A scene description container that can combine with other such containers to form simple component as...
Definition: layer.h:83
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:274
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:71
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:147
SDF_API bool SdfShouldCopyValue(const SdfPath &srcRootPath, const SdfPath &dstRootPath, SdfSpecType specType, const TfToken &field, const SdfLayerHandle &srcLayer, const SdfPath &srcPath, bool fieldInSrc, const SdfLayerHandle &dstLayer, const SdfPath &dstPath, bool fieldInDst, std::optional< VtValue > *valueToCopy)
SdfShouldCopyValueFn used by the simple version of SdfCopySpec.
SDF_API bool SdfShouldCopyChildren(const SdfPath &srcRootPath, const SdfPath &dstRootPath, const TfToken &childrenField, const SdfLayerHandle &srcLayer, const SdfPath &srcPath, bool fieldInSrc, const SdfLayerHandle &dstLayer, const SdfPath &dstPath, bool fieldInDst, std::optional< VtValue > *srcChildren, std::optional< VtValue > *dstChildren)
SdfShouldCopyChildrenFn used by the simple version of SdfCopySpec.
std::function< bool(SdfSpecType specType, const TfToken &field, const SdfLayerHandle &srcLayer, const SdfPath &srcPath, bool fieldInSrc, const SdfLayerHandle &dstLayer, const SdfPath &dstPath, bool fieldInDst, std::optional< VtValue > *valueToCopy)> SdfShouldCopyValueFn
Return true if field should be copied from the spec at srcPath in srcLayer to the spec at dstPath in ...
Definition: copyUtils.h:86
SDF_API bool SdfCopySpec(const SdfLayerHandle &srcLayer, const SdfPath &srcPath, const SdfLayerHandle &dstLayer, const SdfPath &dstPath)
Utility function for copying spec data at srcPath in srcLayer to destPath in destLayer.
std::function< bool(const TfToken &childrenField, const SdfLayerHandle &srcLayer, const SdfPath &srcPath, bool fieldInSrc, const SdfLayerHandle &dstLayer, const SdfPath &dstPath, bool fieldInDst, std::optional< VtValue > *srcChildren, std::optional< VtValue > *dstChildren)> SdfShouldCopyChildrenFn
Return true if childrenField and the child objects the field represents should be copied from the spe...
Definition: copyUtils.h:139
Basic Sdf data types.
SdfSpecType
An enum that specifies the type of an object.
Definition: types.h:68