00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef __TAKE_Hash__
00019 #define __TAKE_Hash__
00020
00021 #include "TAKE_API.h"
00022 #include <SYS/SYS_Math.h>
00023 #include <UT/UT_Hash.h>
00024 #include <UT/UT_String.h>
00025 #include <UT/UT_SharedString.h>
00026
00027 class TAKE_API TAKE_Hash : public UT_Hash {
00028 public:
00029 TAKE_Hash(int opid, const char *label)
00030 {
00031 myLabel = allocString(label);
00032 myOpId = opid;
00033 myHash = UT_String::hash(label);
00034 myHash ^= SYSwang_inthash(myOpId);
00035 }
00036 TAKE_Hash(const TAKE_Hash &src)
00037 : UT_Hash()
00038 {
00039 myLabel = allocString(src.myLabel);
00040 myOpId = src.myOpId;
00041 myHash = src.myHash;
00042 }
00043 virtual ~TAKE_Hash();
00044
00045 virtual int compare(const UT_Hash &a) const;
00046 virtual void copy(const UT_Hash &a);
00047 virtual unsigned hash() const;
00048 virtual UT_Hash *copy() const;
00049
00050 int getOpId() const { return myOpId; }
00051 const char *getLabel() const { return myLabel; }
00052
00053 static UT_SharedString &getStringTable();
00054
00055 private:
00056 const char *allocString(const char *str);
00057
00058 const char *myLabel;
00059 int myOpId;
00060 uint myHash;
00061 };
00062
00063 #endif