All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
instanceKey.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 PXR_USD_PCP_INSTANCE_KEY_H
25 #define PXR_USD_PCP_INSTANCE_KEY_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/usd/pcp/api.h"
29 #include "pxr/usd/pcp/mapExpression.h"
30 #include "pxr/usd/pcp/node.h"
31 #include "pxr/usd/pcp/site.h"
32 #include "pxr/usd/pcp/types.h"
33 
35 
36 #include <boost/functional/hash.hpp>
37 
38 #include <string>
39 #include <utility>
40 #include <vector>
41 
42 PXR_NAMESPACE_OPEN_SCOPE
43 
44 class PcpPrimIndex;
45 
55 {
56 public:
57  PCP_API
59 
61  PCP_API
62  explicit PcpInstanceKey(const PcpPrimIndex& primIndex);
63 
65  PCP_API
66  bool operator==(const PcpInstanceKey& rhs) const;
67  PCP_API
68  bool operator!=(const PcpInstanceKey& rhs) const;
69 
71  friend size_t hash_value(const PcpInstanceKey& key)
72  {
73  return key._hash;
74  }
75 
80  struct Hash {
81  inline size_t operator()(const PcpInstanceKey& key) const
82  {
83  return key._hash;
84  }
85  };
86 
89  PCP_API
90  std::string GetString() const;
91 
92 private:
93  struct _Collector;
94 
95  struct _Arc
96  {
97  explicit _Arc(const PcpNodeRef& node)
98  : _arcType(node.GetArcType())
99  , _sourceSite(node.GetSite())
100  , _timeOffset(node.GetMapToRoot().GetTimeOffset())
101  {
102  }
103 
104  bool operator==(const _Arc& rhs) const
105  {
106  return _arcType == rhs._arcType &&
107  _sourceSite == rhs._sourceSite &&
108  _timeOffset == rhs._timeOffset;
109  }
110 
111  size_t GetHash() const
112  {
113  size_t hash = _arcType;
114  boost::hash_combine(hash, _sourceSite);
115  boost::hash_combine(hash, _timeOffset.GetHash());
116  return hash;
117  }
118 
119  PcpArcType _arcType;
120  PcpSite _sourceSite;
121  SdfLayerOffset _timeOffset;
122  };
123  std::vector<_Arc> _arcs;
124 
125  typedef std::pair<std::string, std::string> _VariantSelection;
126  std::vector<_VariantSelection> _variantSelection;
127 
128  size_t _hash;
129 };
130 
131 PXR_NAMESPACE_CLOSE_SCOPE
132 
133 #endif // PXR_USD_PCP_INSTANCE_KEY_H
A PcpInstanceKey identifies instanceable prim indexes that share the same set of opinions.
Definition: instanceKey.h:54
PcpPrimIndex is an index of the all sites of scene description that contribute opinions to a specific...
Definition: primIndex.h:75
PcpNode represents a node in an expression tree for compositing scene description.
Definition: node.h:67
friend size_t hash_value(const PcpInstanceKey &key)
Returns hash value for this instance key.
Definition: instanceKey.h:71
A site specifies a path in a layer stack of scene description.
Definition: site.h:46
Hash functor.
Definition: instanceKey.h:80
PCP_API std::string GetString() const
Returns string representation of this instance key for debugging purposes.
PCP_API bool operator==(const PcpInstanceKey &rhs) const
Comparison operators.
Represents a time offset and scale between layers.
Definition: layerOffset.h:61
PcpArcType
Describes the type of arc connecting two nodes in the prim index.
Definition: types.h:46