[coco] Introduce create method for Generic FeatureLayout (#1731)
author박종현/동작제어Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Thu, 4 Oct 2018 01:06:40 +0000 (10:06 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Thu, 4 Oct 2018 01:06:40 +0000 (10:06 +0900)
For consistency, this commit introduces create method for Generic
FeatureLayout.

Signed-off-by: Jonghyun Park <jh1302.park@samsung.com>
contrib/coco/core/include/coco/IR/FeatureLayouts.h
contrib/coco/core/src/IR/FeatureLayouts.cpp
contrib/coco/core/src/IR/FeatureObject.cpp

index d5cb869..8244d25 100644 (file)
@@ -90,7 +90,7 @@ public:
  */
 class Generic final : public FeatureLayout
 {
-public:
+private:
   Generic(const FeatureShape &shape);
 
 public:
@@ -114,6 +114,9 @@ private:
 
 private:
   std::vector<ElemID> _content;
+
+public:
+  static std::unique_ptr<Generic> create(const FeatureShape &shape);
 };
 
 } // namespace FeatureLayouts
index 325dcf5..ffe066d 100644 (file)
@@ -156,5 +156,11 @@ void Generic::reorder(const nncc::core::ADT::feature::Layout &l)
   }
 }
 
+std::unique_ptr<Generic> Generic::create(const nncc::core::ADT::feature::Shape &shape)
+{
+  // NOTE It is impossible to use make_unique here as the constructor is private
+  return std::unique_ptr<Generic>{new Generic{shape}};
+}
+
 } // namespace FeatureLayouts
 } // namespace coco
index ca1bf5e..b7f2270 100644 (file)
@@ -29,7 +29,7 @@ namespace coco
 
 FeatureObject::FeatureObject(const nncc::core::ADT::feature::Shape &shape)
 {
-  _layout = make_unique<FeatureLayouts::Generic>(shape);
+  _layout = FeatureLayouts::Generic::create(shape);
 }
 
 FeatureObject::~FeatureObject()