This document is for a version of USD that is under development. See this page for the current release.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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
62SDF_API
63bool
65 const SdfLayerHandle& srcLayer, const SdfPath& srcPath,
66 const SdfLayerHandle& dstLayer, const SdfPath& dstPath);
67
69
72
88using SdfShouldCopyValueFn = std::function<
89 bool(SdfSpecType specType, const TfToken& field,
90 const SdfLayerHandle& srcLayer, const SdfPath& srcPath, bool fieldInSrc,
91 const SdfLayerHandle& dstLayer, const SdfPath& dstPath, bool fieldInDst,
92 std::optional<VtValue>* valueToCopy)>;
93
106{
107public:
111 std::function<void(const SdfLayerHandle&, const SdfPath&)>;
112
113 explicit SdfCopySpecsValueEdit(const EditFunction& edit) : _edit(edit) { }
114 const EditFunction& GetEditFunction() const { return _edit; }
115
118 bool operator==(const SdfCopySpecsValueEdit& rhs) const { return false; }
119 bool operator!=(const SdfCopySpecsValueEdit& rhs) const { return true; }
120
121private:
122 EditFunction _edit;
123};
124
140using SdfShouldCopyChildrenFn = std::function<
141 bool(const TfToken& childrenField,
142 const SdfLayerHandle& srcLayer, const SdfPath& srcPath, bool fieldInSrc,
143 const SdfLayerHandle& dstLayer, const SdfPath& dstPath, bool fieldInDst,
144 std::optional<VtValue>* srcChildren,
145 std::optional<VtValue>* dstChildren)>;
146
155SDF_API
156bool
158 const SdfPath& srcRootPath, const SdfPath& dstRootPath,
159 SdfSpecType specType, const TfToken& field,
160 const SdfLayerHandle& srcLayer, const SdfPath& srcPath, bool fieldInSrc,
161 const SdfLayerHandle& dstLayer, const SdfPath& dstPath, bool fieldInDst,
162 std::optional<VtValue>* valueToCopy);
163
172SDF_API
173bool
175 const SdfPath& srcRootPath, const SdfPath& dstRootPath,
176 const TfToken& childrenField,
177 const SdfLayerHandle& srcLayer, const SdfPath& srcPath, bool fieldInSrc,
178 const SdfLayerHandle& dstLayer, const SdfPath& dstPath, bool fieldInDst,
179 std::optional<VtValue>* srcChildren,
180 std::optional<VtValue>* dstChildren);
181
214SDF_API
215bool
217 const SdfLayerHandle& srcLayer, const SdfPath& srcPath,
218 const SdfLayerHandle& dstLayer, const SdfPath& dstPath,
219 const SdfShouldCopyValueFn& shouldCopyValueFn,
220 const SdfShouldCopyChildrenFn& shouldCopyChildrenFn);
221
223
224PXR_NAMESPACE_CLOSE_SCOPE
225
226#endif // PXR_USD_SDF_COPY_UTILS_H
Value containing an editing operation for SdfCopySpecs.
Definition: copyUtils.h:106
bool operator==(const SdfCopySpecsValueEdit &rhs) const
SdfCopySpecsValueEdit objects are not comparable, but must provide operator== to be stored in a VtVal...
Definition: copyUtils.h:118
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:111
A scene description container that can combine with other such containers to form simple component as...
Definition: layer.h:84
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:92
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:145
Basic Sdf data types.
SdfSpecType
An enum that specifies the type of an object.
Definition: types.h:68