resolveTarget.h
1 //
2 // Copyright 2022 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_USD_RESOLVE_TARGET_H
25 #define PXR_USD_USD_RESOLVE_TARGET_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/usd/usd/api.h"
29 #include "pxr/usd/pcp/node.h"
30 #include "pxr/usd/pcp/primIndex.h"
32 
33 #include <memory>
34 
35 PXR_NAMESPACE_OPEN_SCOPE
36 
37 SDF_DECLARE_HANDLES(SdfLayer);
38 
74 
75 public:
76  UsdResolveTarget() = default;
77 
79  const PcpPrimIndex *GetPrimIndex() const {
80  return _expandedPrimIndex.get();
81  }
82 
85  USD_API
86  PcpNodeRef GetStartNode() const;
87 
90  USD_API
91  SdfLayerHandle GetStartLayer() const;
92 
95  USD_API
96  PcpNodeRef GetStopNode() const;
97 
100  USD_API
101  SdfLayerHandle GetStopLayer() const;
102 
104  bool IsNull() const {
105  return !bool(_expandedPrimIndex);
106  }
107 
108 private:
109  // Non-null UsdResolveTargets can only be created by functions in UsdPrim
110  // and UsdPrimCompositionQueryArc.
111  friend class UsdPrim;
112  friend class UsdPrimCompositionQueryArc;
113 
114  // Usd_Resolver wants to access the iterators provided by this target.
115  friend class Usd_Resolver;
116 
117  USD_API
119  const std::shared_ptr<PcpPrimIndex> &index,
120  const PcpNodeRef &node,
121  const SdfLayerHandle &layer);
122 
123  USD_API
125  const std::shared_ptr<PcpPrimIndex> &index,
126  const PcpNodeRef &node,
127  const SdfLayerHandle &layer,
128  const PcpNodeRef &stopNode,
129  const SdfLayerHandle &stopLayer);
130 
131  // Resolve targets are created with an expanded prim index either from
132  // a composition query (which owns and holds it) or from a UsdPrim (which
133  // creates it solely to create the resolve target). The expanded prim index
134  // is not otherwise cached, so we have to hold on to it during the lifetime
135  // of the resolve target.
136  std::shared_ptr<PcpPrimIndex> _expandedPrimIndex;
137  PcpNodeRange _nodeRange;
138 
139  PcpNodeIterator _startNodeIt;
140  SdfLayerRefPtrVector::const_iterator _startLayerIt;
141  PcpNodeIterator _stopNodeIt;
142  SdfLayerRefPtrVector::const_iterator _stopLayerIt;
143 };
144 
145 PXR_NAMESPACE_CLOSE_SCOPE
146 
147 #endif // PXR_USD_USD_RESOLVE_TARGET_H
This represents a composition arc that is returned by a UsdPrimCompositionQuery.
A scene description container that can combine with other such containers to form simple component as...
Definition: layer.h:94
PcpPrimIndex is an index of the all sites of scene description that contribute opinions to a specific...
Definition: primIndex.h:76
const PcpPrimIndex * GetPrimIndex() const
Get the prim index of the resolve target.
Definition: resolveTarget.h:79
PcpNode represents a node in an expression tree for compositing scene description.
Definition: node.h:67
USD_API PcpNodeRef GetStopNode() const
Returns the node that value resolution with this resolve target will stop at when the "stop at" layer...
Object used to iterate over nodes in the prim index graph in strong-to-weak order.
Definition: iterator.h:51
bool IsNull() const
Returns true if this is a null resolve target.
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a "Prim" as ...
Definition: prim.h:134
USD_API SdfLayerHandle GetStartLayer() const
Returns the layer in the layer stack of the start node that value resolution with this resolve target...
USD_API PcpNodeRef GetStartNode() const
Returns the node that value resolution with this resolve target will start at.
USD_API SdfLayerHandle GetStopLayer() const
Returns the layer in the layer stack of the stop node that value resolution with this resolve target ...
Defines a subrange of nodes and layers within a prim's prim index to consider when performing value r...
Definition: resolveTarget.h:73