HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SHOP_ClerkCache.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: SHOP_ClerkCacheEntry.h ( SHOP Library, C++)
7  *
8  * COMMENTS: Classes used for allowing clerks to cache information.
9  */
10 
11 #ifndef __SHOP_ClerkCacheEntry__
12 #define __SHOP_ClerkCacheEntry__
13 
14 #include "SHOP_API.h"
15 #include <OP/OP_Node.h>
16 #include <SYS/SYS_Hash.h>
17 
18 class SHOP_Clerk;
19 
21 {
22 public:
23  SHOP_ClerkCacheKey(const SHOP_Clerk *clerk, OP_Node *shop,
24  OP_Node *obj, OP_Node *sop)
25  {
26  myClerk = clerk;
27  myShop = shop ? shop->getUniqueId() : -1;
28  myObj = obj ? obj->getUniqueId() : -1;
29  mySop = sop ? sop->getUniqueId() : -1;
30 
31  myHash = SYShash(myClerk);
32  SYShashCombine(myHash, myShop);
33  SYShashCombine(myHash, myObj);
34  SYShashCombine(myHash, mySop);
35  }
36 
37  bool operator==(const SHOP_ClerkCacheKey &key) const
38  {
39  return myClerk == key.myClerk && myShop == key.myShop &&
40  myObj == key.myObj && mySop == key.mySop;
41  }
42 
43  bool operator!=(const SHOP_ClerkCacheKey &key) const
44  {
45  return myClerk != key.myClerk || myShop != key.myShop ||
46  myObj != key.myObj || mySop != key.mySop;
47  }
48 
49  SYS_HashType hash() const { return myHash; }
50 
51 private:
52  const SHOP_Clerk *myClerk;
53  int myShop, myObj, mySop;
54  SYS_HashType myHash;
55 };
56 
57 // boost.hash implementation
58 static inline std::size_t hash_value(const SHOP_ClerkCacheKey &key) { return key.hash(); }
59 
61 public:
62  // Common entry class so that SHOP_Node
64  virtual ~SHOP_ClerkCacheEntry();
65 };
66 
67 #endif
int getUniqueId() const
Definition: OP_Node.h:712
std::size_t SYS_HashType
Define the type for hash values.
Definition: SYS_Hash.h:19
#define SHOP_API
Definition: SHOP_API.h:10
SYS_HashType hash() const
bool operator!=(const SHOP_ClerkCacheKey &key) const
SHOP_ClerkCacheKey(const SHOP_Clerk *clerk, OP_Node *shop, OP_Node *obj, OP_Node *sop)
bool operator==(const SHOP_ClerkCacheKey &key) const
size_t hash_value(const CH_ChannelRef &ref)