Loading...
Searching...
No Matches
layerRelocatesEditBuilder.h
Go to the documentation of this file.
1//
2// Copyright 2024 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_PCP_LAYER_RELOCATES_EDIT_BUILDER_H
8#define PXR_USD_PCP_LAYER_RELOCATES_EDIT_BUILDER_H
9
11
12#include "pxr/pxr.h"
13#include "pxr/usd/pcp/api.h"
14#include "pxr/usd/pcp/errors.h"
16#include "pxr/usd/sdf/path.h"
17#include "pxr/usd/sdf/types.h"
19
20#include <vector>
21
22PXR_NAMESPACE_OPEN_SCOPE
23
24SDF_DECLARE_HANDLES(SdfLayer);
26
48public:
49
59 PCP_API
61 const PcpLayerStackPtr &layerStack,
62 const SdfLayerHandle &addNewRelocatesLayer = nullptr);
63
133 PCP_API
135 const SdfPath &sourcePath,
136 const SdfPath &targetPath,
137 std::string *whyNot = nullptr);
138
151 PCP_API
153 const SdfPath &sourcePath,
154 std::string *whyNot = nullptr);
155
158 using LayerRelocatesEdit = std::pair<SdfLayerHandle, SdfRelocates>;
159
161 using LayerRelocatesEdits = std::vector<LayerRelocatesEdit>;
162
176 PCP_API
178
180 PCP_API
182
183private:
184 void _UpdateExistingRelocates(
185 const SdfPath &source, const SdfPath &target);
186
187 void _RemoveRelocatesWithErrors(const PcpErrorVector &errors);
188
189 mutable std::optional<SdfRelocatesMap> _relocatesMap;
190
191 LayerRelocatesEdits _layerRelocatesEdits;
192 SdfLayerHandleSet _layersWithRelocatesChanges;
193 size_t _editForNewRelocatesIndex = ~0;
194};
195
196// Modifies the given relocates in place by moving paths at or under
197// oldPath to be at or under newPath.
198//
199// The old path may not be empty but the new path can be. Any relocates
200// that become invalid or no-ops are removed from the resulting modified
201// relocates. Returns true if any modifications were made to the relocates,
202// false otherwise.
203bool
204Pcp_ModifyRelocates(
205 SdfRelocates *relocates, const SdfPath &oldPath, const SdfPath &newPath);
206
207PXR_NAMESPACE_CLOSE_SCOPE
208
209#endif // PXR_USD_PCP_LAYER_RELOCATES_EDIT_BUILDER_H
Utility class for building up a map of valid relocates and producing the layer metadata edits that ca...
PCP_API PcpLayerRelocatesEditBuilder(const PcpLayerStackPtr &layerStack, const SdfLayerHandle &addNewRelocatesLayer=nullptr)
Constructor that initializes the relocates map from the given layerStack.
std::vector< LayerRelocatesEdit > LayerRelocatesEdits
List of relocates edits to perform on all layers.
PCP_API bool Relocate(const SdfPath &sourcePath, const SdfPath &targetPath, std::string *whyNot=nullptr)
Updates the relocates map and layer edits so that sourcePath is moved to targetPath in the edited rel...
PCP_API LayerRelocatesEdits GetEdits() const
Returns a list of edits to perform on the layers of the layer stack this builder was initialized with...
PCP_API const SdfRelocatesMap & GetEditedRelocatesMap() const
Returns a map of relocates composed from the edited layer relocates.
PCP_API bool RemoveRelocate(const SdfPath &sourcePath, std::string *whyNot=nullptr)
Updates the relocates map and layer edits so that the relocate with sourcePath is removed from the ed...
std::pair< SdfLayerHandle, SdfRelocates > LayerRelocatesEdit
An edit is a layer and an SdfRelocates value to set in the layer's 'layerRelocates' metatdata.
Represents a stack of layers that contribute opinions to composition.
Definition: layerStack.h:50
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
Standard pointer typedefs.
#define TF_DECLARE_WEAK_PTRS(type)
Define standard weak pointer types.
Definition: declarePtrs.h:45
Basic Sdf data types.
std::vector< SdfRelocate > SdfRelocates
A vector of relocation source path to target path pairs.
Definition: types.h:274
std::map< SdfPath, SdfPath > SdfRelocatesMap
A map of source SdfPaths to target SdfPaths for relocation.
Definition: types.h:267