HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
namespaceEdits.h
Go to the documentation of this file.
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_PCP_NAMESPACE_EDITS_H
25 #define PXR_USD_PCP_NAMESPACE_EDITS_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/usd/pcp/api.h"
29 #include "pxr/usd/pcp/cache.h"
30 #include "pxr/base/tf/hashset.h"
31 
32 #include <string>
33 #include <vector>
34 
36 
37 // Forward declarations:
38 class PcpChanges;
39 class PcpCacheChanges;
40 class Pcp_Dependencies;
42 class PcpLifeboat;
43 class PcpNodeRef;
44 class PcpMapFunction;
45 
47 TF_DECLARE_WEAK_AND_REF_PTRS(Pcp_LayerStackRegistry);
49 
50 /// Sites that must respond to a namespace edit.
52 
53  /// Types of namespace edits that a given layer stack site could need
54  /// to perform to respond to a namespace edit.
55  enum EditType {
56  EditPath, ///< Must namespace edit spec
57  EditInherit, ///< Must fixup inherits
58  EditSpecializes, ///< Must fixup specializes
59  EditReference, ///< Must fixup references
60  EditPayload, ///< Must fixup payload
61  EditRelocate, ///< Must fixup relocates
62  };
63 
65  {
66  cacheSites.swap(rhs.cacheSites);
69  }
70 
71  /// Cache site that must respond to a namespace edit.
72  struct CacheSite {
73  size_t cacheIndex; ///< Index of cache of site.
74  SdfPath oldPath; ///< Old path of site.
75  SdfPath newPath; ///< New path of site.
76  };
77  typedef std::vector<CacheSite> CacheSites;
78 
79  /// Layer stack site that must respond to a namespace edit. All
80  /// of the specs at the site will respond the same way.
81  struct LayerStackSite {
82  size_t cacheIndex; ///< Index of cache of site.
83  EditType type; ///< Type of edit.
84  PcpLayerStackPtr layerStack; ///< Layer stack needing fix.
85  SdfPath sitePath; ///< Path of site needing fix.
86  SdfPath oldPath; ///< Old path.
87  SdfPath newPath; ///< New path.
88  };
89  typedef std::vector<LayerStackSite> LayerStackSites;
90 
91  /// Cache sites that must respond to a namespace edit.
93 
94  /// Layer stack sites that must respond to a namespace edit.
96 
97  /// Layer stack sites that are affected by a namespace edit but
98  /// cannot respond properly. For example, in situations involving
99  /// relocates, a valid namespace edit in one cache may result in
100  /// an invalid edit in another cache in response.
102 };
103 
104 /// Returns the changes caused in any cache in \p caches due to
105 /// namespace editing the object at \p curPath in this cache to
106 /// have the path \p newPath. \p caches should have all caches,
107 /// including this cache. If \p caches includes this cache then
108 /// the result includes the changes caused at \p curPath in this
109 /// cache itself.
110 ///
111 /// To keep everything consistent, a namespace edit requires that
112 /// everything using the namespace edited site to be changed in an
113 /// appropriate way. For example, if a referenced prim /A is renamed
114 /// to /B then everything referencing /A must be changed to reference
115 /// /B instead. There are many other possibilities.
116 ///
117 /// One possibility is that there are no opinions at \p curPath in
118 /// this cache's layer stack and the site exists due to some ancestor
119 /// arc. This requires a relocation and only sites using \p curPath
120 /// that include the layer with the relocation must be changed in
121 /// response. To find those sites, \p relocatesLayer indicates which
122 /// layer the client will write the relocation to.
123 ///
124 /// Clients must perform the changes to correctly perform a namespace
125 /// edit. All changes must be performed in a change block, otherwise
126 /// notices could be sent prematurely.
127 ///
128 /// This method only works when the affected prim indexes have been
129 /// computed. In general, this means you must have computed the prim
130 /// index of everything in any existing cache, otherwise you might miss
131 /// changes to objects in those caches that use the namespace edited
132 /// object. Using the above example, if a prim with an uncomputed prim
133 /// index referenced /A then this method would not report that prim.
134 /// As a result that prim would continue to reference /A, which no
135 /// longer exists.
136 PCP_API
138 PcpComputeNamespaceEdits(const PcpCache *primaryCache,
139  const std::vector<PcpCache*>& caches,
140  const SdfPath& curPath,
141  const SdfPath& newPath,
142  const SdfLayerHandle& relocatesLayer);
143 
145 
146 #endif // PXR_USD_PCP_NAMESPACE_EDITS_H
Sites that must respond to a namespace edit.
EditType type
Type of edit.
SDF_DECLARE_HANDLES(SdfSpec)
std::vector< LayerStackSite > LayerStackSites
PCP_API PcpNamespaceEdits PcpComputeNamespaceEdits(const PcpCache *primaryCache, const std::vector< PcpCache * > &caches, const SdfPath &curPath, const SdfPath &newPath, const SdfLayerHandle &relocatesLayer)
SdfPath sitePath
Path of site needing fix.
Definition: cache.h:93
Definition: spec.h:49
TF_DECLARE_WEAK_AND_REF_PTRS(PcpLayerStack)
size_t cacheIndex
Index of cache of site.
Must namespace edit spec.
Cache site that must respond to a namespace edit.
Must fixup relocates.
Must fixup inherits.
SdfPath newPath
New path of site.
LayerStackSites layerStackSites
Layer stack sites that must respond to a namespace edit.
SdfPath oldPath
Old path of site.
Definition: path.h:290
LayerStackSites invalidLayerStackSites
PcpLayerStackPtr layerStack
Layer stack needing fix.
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1432
Must fixup specializes.
void Swap(PcpNamespaceEdits &rhs)
size_t cacheIndex
Index of cache of site.
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
std::vector< CacheSite > CacheSites
Must fixup references.
CacheSites cacheSites
Cache sites that must respond to a namespace edit.
#define PCP_API
Definition: api.h:40