summaryrefslogtreecommitdiff
path: root/c++/core/id.h
blob: d8366487f2433d9678305dc590a9f48fdeca677e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#pragma once

namespace saw {
/**
 * ID class which is tied to it's representing class
 */
template<typename T>
class id {
private:
		/**
		 * Alias for the value type representing the ID
		 */
		using type = uint64_t;

		/**
		 * The low level value
		 */
		type value_;
public:
		/**
		 * Basic constructor for the id class
		 */
		id(type val):
				value_{val}
		{}

		SAW_DEFAULT_COPY(id);
		SAW_DEFAULT_MOVE(id);

		/**
		 * Equal operator for the id.
		 * Returns true if equal, false otherwise.
		 */
		bool operator==(const id<T>& rhs) const {
				return value_ == rhs.value_;
		}

		/**
		 * Unequal operator for the id.
		 * Returns false if equal, true otherwise.
		 */
		bool operator!=(const id<T>& rhs) const {
				return !(*this == rhs);
		}

		/**
		 * Returns a const ref of the underlying base type.
		 * Mostly used for internal purposes.
		 */
		const type& get_value() const {
				return value_;
		}
};
}