All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
USD_PropertyMap.h
1 //
2 // Copyright 2017 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 _GUSD_USD_PROPERTYMAP_H_
25 #define _GUSD_USD_PROPERTYMAP_H_
26 
27 #include <SYS/SYS_Hash.h>
28 #include <UT/UT_ConcurrentHashMap.h>
29 
30 #include "pxr/pxr.h"
31 #include "pxr/usd/usd/object.h"
32 #include "pxr/usd/usd/prim.h"
33 #include "pxr/usd/usd/stage.h"
34 #include "pxr/usd/usd/timeCode.h"
35 
36 PXR_NAMESPACE_OPEN_SCOPE
37 
40 {
41  GusdUSD_VaryingPropertyKey() : hash(0) {}
42 
44  : prim(prim)
45  , time(time)
46  , hash(ComputeHash(prim, time)) {}
47 
48  static std::size_t ComputeHash(const UsdPrim& prim, UsdTimeCode time)
49  {
50  std::size_t h = SYShash(prim);
51  SYShashCombine(h, time);
52  return h;
53  }
54 
55  bool operator==(const GusdUSD_VaryingPropertyKey& o) const
56  { return prim == o.prim && time == o.time; }
57 
58  friend size_t hash_value(const GusdUSD_VaryingPropertyKey& o)
59  { return o.hash; }
60 
61  struct HashCmp
62  {
63  static std::size_t hash(const GusdUSD_VaryingPropertyKey& key)
64  { return key.hash; }
65  static bool equal(const GusdUSD_VaryingPropertyKey& a,
67  { return a == b; }
68  };
69 
70  UsdPrim prim;
71  UsdTimeCode time;
72  std::size_t hash;
73 };
74 
75 
77 template <typename T>
79  : public UT_ConcurrentHashMap<GusdUSD_VaryingPropertyKey, T,
80  GusdUSD_VaryingPropertyKey::HashCmp>
81 {
82 public:
84  typedef GusdUSD_VaryingPropertyKey::HashCmp HashCmp;
85  typedef T value_type;
86 
88  UT_ConcurrentHashMap<Key,T,HashCmp>() {}
89 };
90 
91 
94 {
96 
98  : prim(prim) {}
99 
100  static std::size_t ComputeHash(const UsdPrim& prim)
101  { return hash_value(prim); }
102 
103  bool operator==(const GusdUSD_UnvaryingPropertyKey& o) const
104  { return prim == o.prim; }
105 
106  friend size_t hash_value(const GusdUSD_UnvaryingPropertyKey& o)
107  { return SYShash(o.prim); }
108 
109  struct HashCmp
110  {
111  static std::size_t hash(const GusdUSD_UnvaryingPropertyKey& key)
112  { return SYShash(key.prim); }
113  static bool equal(const GusdUSD_UnvaryingPropertyKey& a,
115  { return a == b; }
116  };
117 
118  UsdPrim prim;
119 };
120 
121 
123 template <typename T>
125  : public UT_ConcurrentHashMap<GusdUSD_UnvaryingPropertyKey, T,
126  GusdUSD_UnvaryingPropertyKey::HashCmp>
127 {
128 public:
130  typedef GusdUSD_UnvaryingPropertyKey::HashCmp HashCmp;
131  typedef T value_type;
132 
134  UT_ConcurrentHashMap<Key,T,HashCmp>() {}
135 };
136 
137 PXR_NAMESPACE_CLOSE_SCOPE
138 
139 #endif /*_GUSD_USD_PROPERTYMAP_H_*/
Represent a time value, which may be either numeric, holding a double value, or a sentinel value UsdT...
Definition: timeCode.h:85
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a &quot;Prim&quot; as ...
Definition: prim.h:131
TBB-style hash key for unvarying prim properties.
TBB-style hash key for time-varying prim properties.
Concurrent hash map for holding a time-varying property on a prim.
Concurrent hash map for holding an unvarying property of a prim.