[nest] Add 'DomainID' class (#660)
author박종현/동작제어Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Mon, 16 Jul 2018 03:06:03 +0000 (12:06 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Mon, 16 Jul 2018 03:06:03 +0000 (12:06 +0900)
This commit adds 'DomainID' class which serves as an internal
representation of 'domain' in nest IR.

Signed-off-by: Jonghyun Park <jh1302.park@samsung.com>
contrib/nest/include/nest/DomainID.h [new file with mode: 0644]
contrib/nest/src/DomainID.cpp [new file with mode: 0644]
contrib/nest/src/DomainID.test.cpp [new file with mode: 0644]

diff --git a/contrib/nest/include/nest/DomainID.h b/contrib/nest/include/nest/DomainID.h
new file mode 100644 (file)
index 0000000..65aaca3
--- /dev/null
@@ -0,0 +1,38 @@
+#ifndef __NEST_DOMAIN_ID_H__
+#define __NEST_DOMAIN_ID_H__
+
+#include <cstdint>
+
+namespace nest
+{
+
+class DomainID
+{
+public:
+  DomainID();
+
+public:
+  explicit DomainID(uint32_t value) : _value{value}
+  {
+    // DO NOTHING
+  }
+
+public:
+  DomainID(const DomainID &vid) : _value{vid._value}
+  {
+    // DO NOTHING
+  }
+
+public:
+  uint32_t value(void) const { return _value; }
+
+private:
+  uint32_t _value;
+};
+
+bool operator==(const DomainID &lhs, const DomainID &rhs);
+bool operator<(const DomainID &lhs, const DomainID &rhs);
+
+} // namespace nest
+
+#endif // __NEST_DOMAIN_ID_H__
diff --git a/contrib/nest/src/DomainID.cpp b/contrib/nest/src/DomainID.cpp
new file mode 100644 (file)
index 0000000..627b15f
--- /dev/null
@@ -0,0 +1,14 @@
+#include "nest/DomainID.h"
+
+namespace nest
+{
+
+DomainID::DomainID() : _value{0xffffffff}
+{
+  // DO NOTHING
+}
+
+bool operator==(const DomainID &lhs, const DomainID &rhs) { return lhs.value() == rhs.value(); }
+bool operator<(const DomainID &lhs, const DomainID &rhs) { return lhs.value() < rhs.value(); }
+
+} // namespace nest
diff --git a/contrib/nest/src/DomainID.test.cpp b/contrib/nest/src/DomainID.test.cpp
new file mode 100644 (file)
index 0000000..7baf081
--- /dev/null
@@ -0,0 +1,22 @@
+#include "nest/DomainID.h"
+
+#include <gtest/gtest.h>
+
+TEST(DOMAIN_ID, ctor)
+{
+  nest::DomainID id{0};
+
+  ASSERT_EQ(id.value(), 0);
+}
+
+TEST(DOMAIN_ID, operator_eq)
+{
+  ASSERT_TRUE(nest::DomainID(0) == nest::DomainID(0));
+  ASSERT_FALSE(nest::DomainID(0) == nest::DomainID(1));
+}
+
+TEST(DOMAIN_ID, operator_lt)
+{
+  ASSERT_TRUE(nest::DomainID(0) < nest::DomainID(1));
+  ASSERT_FALSE(nest::DomainID(1) < nest::DomainID(0));
+}