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_StringHolder.h>
17 #include <SYS/SYS_Hash.h>
18 
20 {
21 public:
22  TAKE_DataId(int opid, const UT_StringHolder &label)
23  {
24  myLabel = label;
25  myOpId = opid;
26  }
27  virtual ~TAKE_DataId() {}
28 
29  bool operator==(const TAKE_DataId &key) const
30  {
31  return myOpId == key.myOpId && myLabel == key.myLabel;
32  }
33 
34  bool operator!=(const TAKE_DataId &key) const
35  {
36  return myOpId != key.myOpId || myLabel != key.myLabel;
37  }
38 
39  virtual size_t hash() const {
40  SYS_HashType hash = myLabel.hash();
41  SYShashCombine(hash, myOpId);
42  return hash;
43  }
44 
45  virtual 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
GLuint GLsizei const GLchar * label
Definition: glcorearb.h:2544
virtual size_t hash() const
Definition: TAKE_DataId.h:39
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:34
virtual int64 getMemoryUsage(bool inclusive) const
Definition: TAKE_DataId.h:45
long long int64
Definition: SYS_Types.h:107
virtual ~TAKE_DataId()
Definition: TAKE_DataId.h:27
TAKE_DataId(int opid, const UT_StringHolder &label)
Definition: TAKE_DataId.h:22
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