HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
USD_PropertyMap.h
Go to the documentation of this file.
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>
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 
37 
38 /** TBB-style hash key for time-varying prim properties.*/
40 {
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 
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 
72  std::size_t hash;
73 };
74 
75 
76 /** Concurrent hash map for holding a time-varying property on a prim.*/
77 template <typename T>
79  : public UT_ConcurrentHashMap<GusdUSD_VaryingPropertyKey, T,
80  GusdUSD_VaryingPropertyKey::HashCmp>
81 {
82 public:
85  typedef T value_type;
86 
89 };
90 
91 
92 /** TBB-style hash key for unvarying prim properties.*/
94 {
96 
98  : prim(prim) {}
99 
100  static std::size_t ComputeHash(const UsdPrim& prim)
101  { return hash_value(prim); }
102 
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); }
115  { return a == b; }
116  };
117 
119 };
120 
121 
122 /** Concurrent hash map for holding an unvarying property of a prim.*/
123 template <typename T>
125  : public UT_ConcurrentHashMap<GusdUSD_UnvaryingPropertyKey, T,
126  GusdUSD_UnvaryingPropertyKey::HashCmp>
127 {
128 public:
131  typedef T value_type;
132 
135 };
136 
138 
139 #endif /*_GUSD_USD_PROPERTYMAP_H_*/
GusdUSD_UnvaryingPropertyKey(const UsdPrim &prim)
GusdUSD_VaryingPropertyKey::HashCmp HashCmp
bool operator==(const GusdUSD_UnvaryingPropertyKey &o) const
bool operator==(const GusdUSD_VaryingPropertyKey &o) const
GLboolean GLboolean GLboolean GLboolean a
Definition: glcorearb.h:1222
static bool equal(const GusdUSD_VaryingPropertyKey &a, const GusdUSD_VaryingPropertyKey &b)
friend size_t hash_value(const GusdUSD_VaryingPropertyKey &o)
static bool equal(const GusdUSD_UnvaryingPropertyKey &a, const GusdUSD_UnvaryingPropertyKey &b)
GusdUSD_VaryingPropertyKey(const UsdPrim &prim, UsdTimeCode time)
friend size_t hash_value(const GusdUSD_UnvaryingPropertyKey &o)
Definition: prim.h:133
static std::size_t ComputeHash(const UsdPrim &prim, UsdTimeCode time)
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:1222
static std::size_t hash(const GusdUSD_UnvaryingPropertyKey &key)
#define UT_ConcurrentHashMap
GLfloat GLfloat GLfloat GLfloat h
Definition: glcorearb.h:2002
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1432
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
static std::size_t hash(const GusdUSD_VaryingPropertyKey &key)
GusdUSD_UnvaryingPropertyKey::HashCmp HashCmp
GusdUSD_UnvaryingPropertyKey Key
GusdUSD_VaryingPropertyKey Key
static std::size_t ComputeHash(const UsdPrim &prim)