From: 박종현/동작제어Lab(SR)/Staff Engineer/삼성전자 Date: Mon, 16 Jul 2018 03:06:03 +0000 (+0900) Subject: [nest] Add 'DomainID' class (#660) X-Git-Tag: nncc_backup~2419 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5a754814ecadc766df6686bec9e3df38f5569c73;p=platform%2Fcore%2Fml%2Fnnfw.git [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 --- 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)); +}