blob: 813d82d92022748efffbd3d27dbe0439889b16e5 [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
reed@google.comac10a2d2010-12-22 21:39:39 +00002/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00003 * Copyright 2010 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
reed@google.comac10a2d2010-12-22 21:39:39 +00007 */
8
9
epoger@google.comec3ed6a2011-07-28 14:26:00 +000010
reed@google.comac10a2d2010-12-22 21:39:39 +000011#ifndef GrKey_DEFINED
12#define GrKey_DEFINED
13
14#include "GrRefCnt.h"
15
16class GrKey : public GrRefCnt {
17public:
18 typedef intptr_t Hash;
19
20 explicit GrKey(Hash hash) : fHash(hash) {}
21
22 intptr_t getHash() const { return fHash; }
23
24 bool operator<(const GrKey& rh) const {
25 return fHash < rh.fHash || (fHash == rh.fHash && this->lt(rh));
26 }
27 bool operator==(const GrKey& rh) const {
28 return fHash == rh.fHash && this->eq(rh);
29 }
30
31protected:
32 virtual bool lt(const GrKey& rh) const = 0;
33 virtual bool eq(const GrKey& rh) const = 0;
34
35private:
36 const Hash fHash;
37};
38
39#endif
40