From: 박종현/동작제어Lab(SR)/Staff Engineer/삼성전자 Date: Tue, 24 Jul 2018 06:00:01 +0000 (+0900) Subject: [coco] Add 'ElemID' class (#773) X-Git-Tag: nncc_backup~2336 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=eed4c697da8b0d3039d925e3cf96045817e80517;p=platform%2Fcore%2Fml%2Fnnfw.git [coco] Add 'ElemID' class (#773) This commit adds 'ElemID' class to distinguish element IDs from usual numeric values. Signed-off-by: Jonghyun Park --- diff --git a/contrib/coco/core/include/coco/IR/ElemID.h b/contrib/coco/core/include/coco/IR/ElemID.h new file mode 100644 index 0000000..de5676b --- /dev/null +++ b/contrib/coco/core/include/coco/IR/ElemID.h @@ -0,0 +1,26 @@ +#ifndef __COCO_IR_ELEM_ID_H__ +#define __COCO_IR_ELEM_ID_H__ + +#include + +namespace coco +{ + +class ElemID final +{ +public: + explicit ElemID(uint32_t value) : _value{value} + { + // DO NOTHING + } + +public: + uint32_t value(void) const { return _value; } + +private: + uint32_t const _value; +}; + +} // namespace coco + +#endif // __COCO_IR_ELEM_ID_H__ diff --git a/contrib/coco/core/src/IR/ElemID.test.cpp b/contrib/coco/core/src/IR/ElemID.test.cpp new file mode 100644 index 0000000..188e860 --- /dev/null +++ b/contrib/coco/core/src/IR/ElemID.test.cpp @@ -0,0 +1,22 @@ +#include "coco/IR/ElemID.h" + +#include + +#include + +TEST(IR_ELEM_ID, constructor) +{ + coco::ElemID id{128}; + + ASSERT_EQ(id.value(), 128); +} + +TEST(IR_ELEM_ID, std_vector_compatible) +{ + // ElemID SHOULD be compatible with standard container (including std::vector) + std::vector vec; + + vec.emplace_back(coco::ElemID{128}); + + ASSERT_EQ(vec.at(0).value(), 128); +}