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 terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 #ifndef PXR_USD_PCP_NAMESPACE_EDITS_H
8 #define PXR_USD_PCP_NAMESPACE_EDITS_H
9 
10 #include "pxr/pxr.h"
11 #include "pxr/usd/pcp/api.h"
12 #include "pxr/usd/pcp/cache.h"
13 #include "pxr/base/tf/hashset.h"
14 
15 #include <string>
16 #include <vector>
17 
19 
20 // Forward declarations:
21 class PcpChanges;
22 class PcpCacheChanges;
23 class Pcp_Dependencies;
25 class PcpLifeboat;
26 class PcpNodeRef;
27 class PcpMapFunction;
28 
30 TF_DECLARE_WEAK_AND_REF_PTRS(Pcp_LayerStackRegistry);
32 
33 /// Sites that must respond to a namespace edit.
35 
36  /// Types of namespace edits that a given layer stack site could need
37  /// to perform to respond to a namespace edit.
38  enum EditType {
39  EditPath, ///< Must namespace edit spec
40  EditInherit, ///< Must fixup inherits
41  EditSpecializes, ///< Must fixup specializes
42  EditReference, ///< Must fixup references
43  EditPayload, ///< Must fixup payload
44  EditRelocate, ///< Must fixup relocates
45  };
46 
48  {
49  cacheSites.swap(rhs.cacheSites);
52  }
53 
54  /// Cache site that must respond to a namespace edit.
55  struct CacheSite {
56  size_t cacheIndex; ///< Index of cache of site.
57  SdfPath oldPath; ///< Old path of site.
58  SdfPath newPath; ///< New path of site.
59  };
60  typedef std::vector<CacheSite> CacheSites;
61 
62  /// Layer stack site that must respond to a namespace edit. All
63  /// of the specs at the site will respond the same way.
64  struct LayerStackSite {
65  size_t cacheIndex; ///< Index of cache of site.
66  EditType type; ///< Type of edit.
67  PcpLayerStackPtr layerStack; ///< Layer stack needing fix.
68  SdfPath sitePath; ///< Path of site needing fix.
69  SdfPath oldPath; ///< Old path.
70  SdfPath newPath; ///< New path.
71  };
72  typedef std::vector<LayerStackSite> LayerStackSites;
73 
74  /// Cache sites that must respond to a namespace edit.
76 
77  /// Layer stack sites that must respond to a namespace edit.
79 
80  /// Layer stack sites that are affected by a namespace edit but
81  /// cannot respond properly. For example, in situations involving
82  /// relocates, a valid namespace edit in one cache may result in
83  /// an invalid edit in another cache in response.
85 };
86 
87 /// Returns the changes caused in any cache in \p caches due to
88 /// namespace editing the object at \p curPath in this cache to
89 /// have the path \p newPath. \p caches should have all caches,
90 /// including this cache. If \p caches includes this cache then
91 /// the result includes the changes caused at \p curPath in this
92 /// cache itself.
93 ///
94 /// To keep everything consistent, a namespace edit requires that
95 /// everything using the namespace edited site to be changed in an
96 /// appropriate way. For example, if a referenced prim /A is renamed
97 /// to /B then everything referencing /A must be changed to reference
98 /// /B instead. There are many other possibilities.
99 ///
100 /// One possibility is that there are no opinions at \p curPath in
101 /// this cache's layer stack and the site exists due to some ancestor
102 /// arc. This requires a relocation and only sites using \p curPath
103 /// that include the layer with the relocation must be changed in
104 /// response. To find those sites, \p relocatesLayer indicates which
105 /// layer the client will write the relocation to.
106 ///
107 /// Clients must perform the changes to correctly perform a namespace
108 /// edit. All changes must be performed in a change block, otherwise
109 /// notices could be sent prematurely.
110 ///
111 /// This method only works when the affected prim indexes have been
112 /// computed. In general, this means you must have computed the prim
113 /// index of everything in any existing cache, otherwise you might miss
114 /// changes to objects in those caches that use the namespace edited
115 /// object. Using the above example, if a prim with an uncomputed prim
116 /// index referenced /A then this method would not report that prim.
117 /// As a result that prim would continue to reference /A, which no
118 /// longer exists.
119 PCP_API
121 PcpComputeNamespaceEdits(const PcpCache *primaryCache,
122  const std::vector<PcpCache*>& caches,
123  const SdfPath& curPath,
124  const SdfPath& newPath,
125  const SdfLayerHandle& relocatesLayer);
126 
128 
129 #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:76
Definition: spec.h:32
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:273
LayerStackSites invalidLayerStackSites
PcpLayerStackPtr layerStack
Layer stack needing fix.
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
Must fixup specializes.
void Swap(PcpNamespaceEdits &rhs)
size_t cacheIndex
Index of cache of site.
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
std::vector< CacheSite > CacheSites
Must fixup references.
CacheSites cacheSites
Cache sites that must respond to a namespace edit.
#define PCP_API
Definition: api.h:23