HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TAKE_DataId.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: TAKE_DataId.h ( TAKE Library, C++)
7  *
8  * COMMENTS: An identifier object for TAKE_Data
9  */
10 
11 #ifndef __TAKE_Hash__
12 #define __TAKE_Hash__
13 
14 #include "TAKE_API.h"
15 
16 #include <UT/UT_NonCopyable.h>
17 #include <UT/UT_StringHolder.h>
18 #include <SYS/SYS_Hash.h>
19 
20 class TAKE_API TAKE_DataId final
21 {
22 public:
23  TAKE_DataId(int opid, const UT_StringHolder &label)
24  {
25  myLabel = label;
26  myOpId = opid;
27  }
28 
29  bool operator==(const TAKE_DataId &key) const
30  {
31  return myOpId == key.myOpId && myLabel == key.myLabel;
32  }
33  bool operator!=(const TAKE_DataId &key) const
34  {
35  return myOpId != key.myOpId || myLabel != key.myLabel;
36  }
37 
38  size_t hash() const
39  {
40  SYS_HashType hash = myLabel.hash();
41  SYShashCombine(hash, myOpId);
42  return hash;
43  }
44 
45  int64 getMemoryUsage(bool inclusive) const
46  {
47  // NOTE: We could try to count myLabel, but it might be
48  // shared by millions of TAKE_Hash objects.
49  return inclusive ? sizeof(*this) : 0;
50  }
51 
52  UT_StringRef getLabel() const { return myLabel; }
53  int getOpId() const { return myOpId; }
54 
55  struct Hasher
56  {
57  size_t operator()(const TAKE_DataId &k) const
58  {
59  return k.hash();
60  }
61  };
62 private:
63  UT_StringHolder myLabel;
64  int myOpId;
65 };
66 
67 #endif
int64 getMemoryUsage(bool inclusive) const
Definition: TAKE_DataId.h:45
GLuint GLsizei const GLchar * label
Definition: glcorearb.h:2545
std::size_t SYS_HashType
Define the type for hash values.
Definition: SYS_Hash.h:19
bool operator!=(const TAKE_DataId &key) const
Definition: TAKE_DataId.h:33
size_t hash() const
Definition: TAKE_DataId.h:38
long long int64
Definition: SYS_Types.h:116
TAKE_DataId(int opid, const UT_StringHolder &label)
Definition: TAKE_DataId.h:23
UT_StringRef getLabel() const
Definition: TAKE_DataId.h:52
int getOpId() const
Definition: TAKE_DataId.h:53
bool operator==(const TAKE_DataId &key) const
Definition: TAKE_DataId.h:29
size_t operator()(const TAKE_DataId &k) const
Definition: TAKE_DataId.h:57
#define TAKE_API
Definition: TAKE_API.h:10