summaryrefslogtreecommitdiff
path: root/modules/core/id.h
diff options
context:
space:
mode:
Diffstat (limited to 'modules/core/id.h')
-rw-r--r--modules/core/id.h54
1 files changed, 54 insertions, 0 deletions
diff --git a/modules/core/id.h b/modules/core/id.h
new file mode 100644
index 0000000..d836648
--- /dev/null
+++ b/modules/core/id.h
@@ -0,0 +1,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_;
+ }
+};
+}