ObjectID.h revision fce4895d
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
12class ObjectID : public BReferenceable {
13public:
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
22protected:
23	virtual	uint32				ComputeHashValue() const = 0;
24
25protected:
26	mutable	uint32				fHashValue;
27};
28
29
30uint32
31ObjectID::HashValue() const
32{
33	if (fHashValue == 0)
34		fHashValue = ComputeHashValue();
35	return fHashValue;
36}
37
38
39bool
40ObjectID::operator!=(const ObjectID& other) const
41{
42	return !(*this == other);
43}
44
45
46#endif	// OBJECT_ID_H
47