All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
resolver.h
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 USD_RESOLVER_H
25 #define USD_RESOLVER_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/usd/usd/api.h"
29 #include "pxr/usd/usd/common.h"
30 
31 #include "pxr/usd/pcp/node.h"
32 #include "pxr/usd/pcp/iterator.h"
33 
34 #include "pxr/usd/sdf/path.h"
35 #include "pxr/usd/sdf/declareHandles.h"
36 
37 PXR_NAMESPACE_OPEN_SCOPE
38 
39 class PcpPrimIndex;
40 
46 class Usd_Resolver {
47 public:
48 
54  USD_API
55  explicit Usd_Resolver(const PcpPrimIndex* index, bool skipEmptyNodes = true);
56 
58  bool IsValid() const {
59  return _curNode != _lastNode;
60  }
61 
67  USD_API
68  bool NextLayer();
69 
73  USD_API
74  void NextNode();
75 
80  USD_API
81  PcpNodeRef GetNode() const;
82 
88  USD_API
89  const SdfLayerRefPtr& GetLayer() const;
90 
92  USD_API
93  const SdfPath& GetLocalPath() const;
94 
95  SdfPath GetLocalPath(TfToken const &propName) const {
96  return propName.IsEmpty() ? GetLocalPath() :
97  GetLocalPath().AppendProperty(propName);
98  }
99 
104  USD_API
105  const PcpPrimIndex* GetPrimIndex() const;
106 
111  struct Position
112  {
113  Position() { }
114 
115  PcpNodeRef GetNode() const { return *_curNode; }
116  const SdfLayerRefPtr& GetLayer() const { return *_curLayer; }
117  const SdfPath& GetLocalPath() const { return _curNode->GetPath(); }
118  SdfPath GetLocalPath(TfToken const &propName) const {
119  return propName.IsEmpty() ? GetLocalPath() :
120  GetLocalPath().AppendProperty(propName);
121  }
122 
123  private:
124  friend class Usd_Resolver;
125 
126  Position(const PcpNodeIterator& curNode,
127  const SdfLayerRefPtrVector::const_iterator& curLayer)
128  : _curNode(curNode), _curLayer(curLayer) { }
129 
130  PcpNodeIterator _curNode;
131  SdfLayerRefPtrVector::const_iterator _curLayer;
132  };
133 
136  USD_API
137  Position GetPosition() const;
138 
139 private:
140  void _Init();
141  void _SkipEmptyNodes();
142 
143  const PcpPrimIndex* _index;
144  bool _skipEmptyNodes;
145 
146  PcpNodeIterator _curNode;
147  PcpNodeIterator _lastNode;
148  SdfLayerRefPtrVector::const_iterator _curLayer;
149  SdfLayerRefPtrVector::const_iterator _lastLayer;
150 };
151 
152 PXR_NAMESPACE_CLOSE_SCOPE
153 
154 #endif // USD_RESOLVER_H
PcpPrimIndex is an index of the all sites of scene description that contribute opinions to a specific...
Definition: primIndex.h:77
PcpNode represents a node in an expression tree for compositing scene description.
Definition: node.h:65
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:89
Object used to iterate over nodes in the prim index graph in strong-to-weak order.
Definition: iterator.h:51
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:287
bool IsEmpty() const
Returns true iff this token contains the empty string "".
Definition: token.h:311