xref: /haiku/headers/private/debugger/ids/ObjectID.h (revision e81a954787e50e56a7f06f72705b7859b6ab06d1)
1 /*
2  * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef OBJECT_ID_H
6 #define OBJECT_ID_H
7 
8 
9 #include <Referenceable.h>
10 
11 
12 class ObjectID : public BReferenceable {
13 public:
14 								ObjectID();
15 	virtual						~ObjectID();
16 
17 	inline	uint32				HashValue() const;
18 
19 	virtual	bool				operator==(const ObjectID& other) const = 0;
20 	inline	bool				operator!=(const ObjectID& other) const;
21 
22 protected:
23 	virtual	uint32				ComputeHashValue() const = 0;
24 
25 protected:
26 	mutable	uint32				fHashValue;
27 };
28 
29 
30 uint32
31 ObjectID::HashValue() const
32 {
33 	if (fHashValue == 0)
34 		fHashValue = ComputeHashValue();
35 	return fHashValue;
36 }
37 
38 
39 bool
40 ObjectID::operator!=(const ObjectID& other) const
41 {
42 	return !(*this == other);
43 }
44 
45 
46 #endif	// OBJECT_ID_H
47