All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
copyUtils.h
Go to the documentation of this file.
1 //
2 // Copyright 2017 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 SDF_COPY_UTILS_H
25 #define SDF_COPY_UTILS_H
26 
28 
29 #include "pxr/pxr.h"
30 #include "pxr/usd/sdf/api.h"
31 
32 #include "pxr/usd/sdf/declareHandles.h"
33 #include "pxr/usd/sdf/types.h"
34 
35 #include <boost/optional.hpp>
36 #include <functional>
37 
38 PXR_NAMESPACE_OPEN_SCOPE
39 
40 class SdfPath;
41 class TfToken;
42 class VtValue;
43 SDF_DECLARE_HANDLES(SdfLayer);
44 
47 
73 SDF_API
74 bool
76  const SdfLayerHandle& srcLayer, const SdfPath& srcPath,
77  const SdfLayerHandle& dstLayer, const SdfPath& dstPath);
78 
80 
83 
99 using SdfShouldCopyValueFn = std::function<
100  bool(SdfSpecType specType, const TfToken& field,
101  const SdfLayerHandle& srcLayer, const SdfPath& srcPath, bool fieldInSrc,
102  const SdfLayerHandle& dstLayer, const SdfPath& dstPath, bool fieldInDst,
103  boost::optional<VtValue>* valueToCopy)>;
104 
117 {
118 public:
121  using EditFunction =
122  std::function<void(const SdfLayerHandle&, const SdfPath&)>;
123 
124  explicit SdfCopySpecsValueEdit(const EditFunction& edit) : _edit(edit) { }
125  const EditFunction& GetEditFunction() const { return _edit; }
126 
129  bool operator==(const SdfCopySpecsValueEdit& rhs) const { return false; }
130  bool operator!=(const SdfCopySpecsValueEdit& rhs) const { return true; }
131 
132 private:
133  EditFunction _edit;
134 };
135 
151 using SdfShouldCopyChildrenFn = std::function<
152  bool(const TfToken& childrenField,
153  const SdfLayerHandle& srcLayer, const SdfPath& srcPath, bool fieldInSrc,
154  const SdfLayerHandle& dstLayer, const SdfPath& dstPath, bool fieldInDst,
155  boost::optional<VtValue>* srcChildren,
156  boost::optional<VtValue>* dstChildren)>;
157 
166 SDF_API
167 bool
169  const SdfPath& srcRootPath, const SdfPath& dstRootPath,
170  SdfSpecType specType, const TfToken& field,
171  const SdfLayerHandle& srcLayer, const SdfPath& srcPath, bool fieldInSrc,
172  const SdfLayerHandle& dstLayer, const SdfPath& dstPath, bool fieldInDst,
173  boost::optional<VtValue>* valueToCopy);
174 
183 SDF_API
184 bool
186  const SdfPath& srcRootPath, const SdfPath& dstRootPath,
187  const TfToken& childrenField,
188  const SdfLayerHandle& srcLayer, const SdfPath& srcPath, bool fieldInSrc,
189  const SdfLayerHandle& dstLayer, const SdfPath& dstPath, bool fieldInDst,
190  boost::optional<VtValue>* srcChildren,
191  boost::optional<VtValue>* dstChildren);
192 
216 SDF_API
217 bool
219  const SdfLayerHandle& srcLayer, const SdfPath& srcPath,
220  const SdfLayerHandle& dstLayer, const SdfPath& dstPath,
221  const SdfShouldCopyValueFn& shouldCopyValueFn,
222  const SdfShouldCopyChildrenFn& shouldCopyChildrenFn);
223 
225 
226 PXR_NAMESPACE_CLOSE_SCOPE
227 
228 #endif // SDF_COPY_UTILS_H
bool operator==(const SdfCopySpecsValueEdit &rhs) const
SdfCopySpecsValueEdit objects are not comparable, but must provide operator== to be stored in a VtVal...
Definition: copyUtils.h:129
A unit of scene description that you combine with other units of scene description to form a shot...
Definition: layer.h:93
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, boost::optional< VtValue > *srcChildren, boost::optional< VtValue > *dstChildren)
SdfShouldCopyChildrenFn used by the simple version of SdfCopySpec.
SdfSpecType
An enum that specifies the type of an object.
Definition: types.h:91
Value containing an editing operation for SdfCopySpecs.
Definition: copyUtils.h:116
std::function< bool(SdfSpecType specType, const TfToken &field, const SdfLayerHandle &srcLayer, const SdfPath &srcPath, bool fieldInSrc, const SdfLayerHandle &dstLayer, const SdfPath &dstPath, bool fieldInDst, boost::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:103
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:89
std::function< bool(const TfToken &childrenField, const SdfLayerHandle &srcLayer, const SdfPath &srcPath, bool fieldInSrc, const SdfLayerHandle &dstLayer, const SdfPath &dstPath, bool fieldInDst, boost::optional< VtValue > *srcChildren, boost::optional< VtValue > *dstChildren)> SdfShouldCopyChildrenFn
Return true if childrenField and the child objects the field represents should be copied from the spe...
Definition: copyUtils.h:156
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:122
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:287
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, boost::optional< VtValue > *valueToCopy)
SdfShouldCopyValueFn used by the simple version of SdfCopySpec.
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.
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:182