7#ifndef PXR_USD_PCP_LAYER_STACK_H
8#define PXR_USD_PCP_LAYER_STACK_H
13#include "pxr/usd/pcp/api.h"
14#include "pxr/usd/pcp/errors.h"
16#include "pxr/usd/pcp/mapExpression.h"
20#include <tbb/spin_mutex.h>
24#include <unordered_set>
27PXR_NAMESPACE_OPEN_SCOPE
34class Pcp_LayerStackRegistry;
117 return _localErrors ? *_localErrors.get() : PcpErrorVector();
129 {
return *_expressionVariables; }
134 const std::unordered_set<std::string>&
136 {
return _expressionVariableDependencies; }
221 friend class Pcp_LayerStackRegistry;
225 friend bool Pcp_NeedToRecomputeDueToAssetPathChange(
const PcpLayerStackPtr&);
232 const Pcp_LayerStackRegistry ®istry);
235 void _BlowRelocations();
236 void _Compute(
const std::string &fileFormatTarget,
237 const Pcp_MutedLayers &mutedLayers);
240 const SdfLayerHandle & layer,
245 const std::string & sessionOwner,
246 const Pcp_MutedLayers & mutedLayers,
247 SdfLayerHandleSet *seenLayers,
248 PcpErrorVector *errors);
257 Pcp_LayerStackRegistryPtr _registry;
270 SdfLayerRefPtrVector _layers;
275 std::vector<PcpMapFunction> _mapFunctions;
279 double _timeCodesPerSecond;
290 struct _SublayerSourceInfo {
291 _SublayerSourceInfo() =
default;
293 const SdfLayerHandle& layer_,
294 const std::string& authoredSublayerPath_,
295 const std::string& computedSublayerPath_)
297 , authoredSublayerPath(authoredSublayerPath_)
298 , computedSublayerPath(computedSublayerPath_) { }
300 SdfLayerHandle layer;
301 std::string authoredSublayerPath;
302 std::string computedSublayerPath;
306 std::vector<_SublayerSourceInfo> _sublayerSourceInfo;
309 std::set<std::string> _mutedAssetPaths;
313 std::unique_ptr<PcpErrorVector> _localErrors;
326 SdfPath::FastLessThan> _RelocatesVarMap;
327 _RelocatesVarMap _relocatesVariables;
328 tbb::spin_mutex _relocatesVariablesMutex;
331 SdfPathVector _relocatesPrimPaths;
334 std::shared_ptr<PcpExpressionVariables> _expressionVariables;
337 std::unordered_set<std::string> _expressionVariableDependencies;
347std::ostream& operator<<(std::ostream&,
const PcpLayerStackPtr&);
349std::ostream& operator<<(std::ostream&,
const PcpLayerStackRefPtr&);
356Pcp_IsValidRelocatesEntry(
357 const SdfPath &source,
const SdfPath &target, std::string *errorMessage);
362 const std::vector<std::pair<SdfLayerHandle, SdfRelocates>> &layerRelocates,
364 PcpErrorVector *errors);
370Pcp_ComputeRelocationsForLayerStack(
376 SdfPathVector *relocatesPrimPaths,
377 PcpErrorVector *errors);
385Pcp_NeedToRecomputeDueToAssetPathChange(
const PcpLayerStackPtr& layerStack);
391Pcp_NeedToRecomputeLayerStackTimeCodesPerSecond(
392 const PcpLayerStackPtr& layerStack,
const SdfLayerHandle &changedLayer);
398PXR_NAMESPACE_CLOSE_SCOPE
An asset resolver context allows clients to provide additional data to the resolver for use during re...
PcpCache is the context required to make requests of the Pcp composition algorithm and cache the resu...
Object containing composed expression variables associated with a given layer stack,...
Types of changes per layer stack.
Represents a stack of layers that contribute opinions to composition.
PCP_API const SdfLayerOffset * GetLayerOffsetForLayer(const SdfLayerHandle &) const
Returns the layer offset for the given layer, or NULL if the layer can't be found or is the identity.
PCP_API void Apply(const PcpLayerStackChanges &changes, PcpLifeboat *lifeboat)
Apply the changes in changes.
double GetTimeCodesPerSecond() const
Return the time codes per second value of the layer stack.
PCP_API bool HasLayer(const SdfLayerHandle &layer) const
Returns true if this layer stack contains the given layer, false otherwise.
PCP_API SdfLayerHandleVector GetSessionLayers() const
Returns only the session layers in the layer stack in strong-to-weak order.
PCP_API bool HasRelocates() const
Return true if there are any relocated prim paths in this layer stack.
PCP_API const SdfLayerTreeHandle & GetSessionLayerTree() const
Returns the layer tree representing the structure of the session layers in the layer stack or null if...
PCP_API const SdfPathVector & GetPathsToPrimsWithRelocates() const
Returns a list of paths to all prims across all layers in this layer stack that contained relocates.
const std::unordered_set< std::string > & GetExpressionVariableDependencies() const
Return the set of expression variables used during the computation of this layer stack.
const PcpExpressionVariables & GetExpressionVariables() const
Return the composed expression variables for this layer stack.
PCP_API const std::set< std::string > & GetMutedLayers() const
Returns the set of layers that were muted in this layer stack.
PCP_API const SdfLayerTreeHandle & GetLayerTree() const
Returns the layer tree representing the structure of the non-session layers in the layer stack.
bool IsUsd() const
Return true if this layer stack is in USD mode.
PCP_API const PcpLayerStackIdentifier & GetIdentifier() const
Returns the identifier for this layer stack.
PCP_API const SdfRelocatesMap & GetRelocatesSourceToTarget() const
Returns relocation source-to-target mapping for this layer stack.
PCP_API PcpMapExpression GetExpressionForRelocatesAtPath(const SdfPath &path)
Return a PcpMapExpression representing the relocations that affect namespace at and below the given p...
PcpErrorVector GetLocalErrors() const
Return the list of errors local to this layer stack.
PCP_API const SdfLayerOffset * GetLayerOffsetForLayer(const SdfLayerRefPtr &) const
Return the layer offset for the given layer, or NULL if the layer can't be found or is the identity.
PCP_API const SdfRelocatesMap & GetIncrementalRelocatesTargetToSource() const
Returns incremental relocation target-to-source mapping for this layer stack.
PCP_API const SdfLayerRefPtrVector & GetLayers() const
Returns the layers in this layer stack in strong-to-weak order.
PCP_API const SdfLayerOffset * GetLayerOffsetForLayer(size_t layerIdx) const
Returns the layer offset for the layer at the given index in this layer stack.
PCP_API const SdfRelocatesMap & GetIncrementalRelocatesSourceToTarget() const
Returns incremental relocation source-to-target mapping for this layer stack.
PCP_API const SdfSchemaBase * GetSchemaForAllLayers() const
Return pointer to an SdfSchemaBase if all layers in the layer stack use that schema,...
PCP_API const SdfRelocatesMap & GetRelocatesTargetToSource() const
Returns relocation target-to-source mapping for this layer stack.
Arguments used to identify a layer stack.
Structure used to temporarily retain layers and layerStacks within a code block.
An expression that yields a PcpMapFunction value.
std::unique_ptr< Variable > VariableUniquePtr
Variables are held by reference.
A scene description container that can combine with other such containers to form simple component as...
std::map< std::string, std::string > FileFormatArguments
Type for specifying additional file format-specific arguments to layer API.
Represents a time offset and scale between layers.
A path value used to locate objects in layers or scenegraphs.
Generic class that provides information about scene description fields but doesn't actually provide a...
Enable a concrete base class for use with TfRefPtr.
Enable a concrete base class for use with TfWeakPtr.
Standard pointer typedefs.
#define TF_DECLARE_REF_PTRS(type)
Define standard ref pointer types.
#define TF_DECLARE_WEAK_AND_REF_PTRS(type)
Define standard weak, ref, and vector pointer types.
bool PcpIsSessionOwnerSublayerReorderingEnabled()
Return true if sublayers are reordered according to the current session owner (session owner's sublay...
std::map< SdfPath, SdfPath > SdfRelocatesMap
A map of source SdfPaths to target SdfPaths for relocation.