From b8bf4a6d73e1fb554323dd8cbee5476ba3bf78f2 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: Wed, 25 Jul 2018 11:41:25 +0900 Subject: [PATCH] [coco] Introduce 'BagInfo' class (#793) This commit introduces 'BagInfo' class which maintains the internal state of 'Bag'. 'BagInfo' allows us to distinguish the methods that users (who build IR) can use from the methods that IR elements such as Object can use. Signed-off-by: Jonghyun Park --- contrib/coco/core/include/coco/IR/Bag.h | 13 ++++++++---- contrib/coco/core/include/coco/IR/BagInfo.h | 32 +++++++++++++++++++++++++++++ contrib/coco/core/src/IR/Bag.cpp | 13 ++++++++++++ 3 files changed, 54 insertions(+), 4 deletions(-) create mode 100644 contrib/coco/core/include/coco/IR/BagInfo.h create mode 100644 contrib/coco/core/src/IR/Bag.cpp diff --git a/contrib/coco/core/include/coco/IR/Bag.h b/contrib/coco/core/include/coco/IR/Bag.h index 9ca7d01..a08e656 100644 --- a/contrib/coco/core/include/coco/IR/Bag.h +++ b/contrib/coco/core/include/coco/IR/Bag.h @@ -1,7 +1,9 @@ #ifndef __COCO_IR_BAG_H__ #define __COCO_IR_BAG_H__ -#include +#include "coco/IR/BagInfo.h" + +#include namespace coco { @@ -20,16 +22,19 @@ namespace coco class Bag { public: - Bag(uint32_t size) : _size{size} + explicit Bag(std::unique_ptr &&info) : _info{std::move(info)} { // DO NOTHING } public: - uint32_t size(void) const { return _size; } + explicit Bag(uint32_t size); + +public: + uint32_t size(void) const { return _info->size(); } private: - uint32_t const _size; + std::unique_ptr _info; }; } // namespace coco diff --git a/contrib/coco/core/include/coco/IR/BagInfo.h b/contrib/coco/core/include/coco/IR/BagInfo.h new file mode 100644 index 0000000..0cb9186 --- /dev/null +++ b/contrib/coco/core/include/coco/IR/BagInfo.h @@ -0,0 +1,32 @@ +#ifndef __COCO_IR_BAG_INFO_H__ +#define __COCO_IR_BAG_INFO_H__ + +#include + +namespace coco +{ + +/*** + * @brief The internal state of Bag + * + * BagInfo is the internal state of Bag. IR elements such as Object can access BagInfo, + * but users (who builds IR) can't access. + */ +class BagInfo +{ +public: + BagInfo(uint32_t size) : _size{size} + { + // DO NOTHING + } + +public: + uint32_t size(void) const { return _size; } + +private: + uint32_t const _size; +}; + +} // namespace coco + +#endif // __COCO_IR_BAG_INFO_H__ diff --git a/contrib/coco/core/src/IR/Bag.cpp b/contrib/coco/core/src/IR/Bag.cpp new file mode 100644 index 0000000..9da5847 --- /dev/null +++ b/contrib/coco/core/src/IR/Bag.cpp @@ -0,0 +1,13 @@ +#include "coco/IR/Bag.h" + +#include + +namespace coco +{ + +Bag::Bag(uint32_t size) +{ + _info = nncc::foundation::make_unique(size); +} + +} // namespace coco -- 2.7.4