From 5a754814ecadc766df6686bec9e3df38f5569c73 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EB=B0=95=EC=A2=85=ED=98=84/=EB=8F=99=EC=9E=91=EC=A0=9C?= =?utf8?q?=EC=96=B4Lab=28SR=29/Staff=20Engineer/=EC=82=BC=EC=84=B1?= =?utf8?q?=EC=A0=84=EC=9E=90?= Date: Mon, 16 Jul 2018 12:06:03 +0900 Subject: [PATCH] [nest] Add 'DomainID' class (#660) This commit adds 'DomainID' class which serves as an internal representation of 'domain' in nest IR. Signed-off-by: Jonghyun Park --- contrib/nest/include/nest/DomainID.h | 38 ++++++++++++++++++++++++++++++++++++ contrib/nest/src/DomainID.cpp | 14 +++++++++++++ contrib/nest/src/DomainID.test.cpp | 22 +++++++++++++++++++++ 3 files changed, 74 insertions(+) create mode 100644 contrib/nest/include/nest/DomainID.h create mode 100644 contrib/nest/src/DomainID.cpp create mode 100644 contrib/nest/src/DomainID.test.cpp diff --git a/contrib/nest/include/nest/DomainID.h b/contrib/nest/include/nest/DomainID.h new file mode 100644 index 0000000..65aaca3 --- /dev/null +++ b/contrib/nest/include/nest/DomainID.h @@ -0,0 +1,38 @@ +#ifndef __NEST_DOMAIN_ID_H__ +#define __NEST_DOMAIN_ID_H__ + +#include + +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 index 0000000..627b15f --- /dev/null +++ b/contrib/nest/src/DomainID.cpp @@ -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 index 0000000..7baf081 --- /dev/null +++ b/contrib/nest/src/DomainID.test.cpp @@ -0,0 +1,22 @@ +#include "nest/DomainID.h" + +#include + +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)); +} -- 2.7.4