Change shared_ptr to unique_ptr for ItemFactory 89/201089/2
authorJunghoon Park <jh9216.park@samsung.com>
Fri, 8 Mar 2019 06:58:11 +0000 (15:58 +0900)
committerJunghoon Park <jh9216.park@samsung.com>
Fri, 8 Mar 2019 07:00:54 +0000 (16:00 +0900)
- The created item does not need to share each other

Change-Id: Ie6d9a205fc7f345baa0897c164895e79e64203a0
Signed-off-by: Junghoon Park <jh9216.park@samsung.com>
notification-ex/item_factory.cc
notification-ex/item_factory.h

index 0850145..1dc20ee 100644 (file)
@@ -44,36 +44,37 @@ using namespace std;
 namespace notification {
 namespace item {
 
-shared_ptr<AbstractItem> ItemFactory::CreateItem(AbstractItem::Type type) {
+unique_ptr<AbstractItem> ItemFactory::CreateItem(AbstractItem::Type type) {
   switch (type) {
   case AbstractItem::NullObject :
     THROW(NOTIFICATION_ERROR_INVALID_PARAMETER);
   case AbstractItem::Text :
-    return make_shared<TextItem>("","");
+    return unique_ptr<AbstractItem>(new TextItem("",""));
   case AbstractItem::Icon :
-    return make_shared<IconItem>("");
+    return unique_ptr<AbstractItem>(new IconItem(""));
   case AbstractItem::Image :
-    return make_shared<ImageItem>("");
+    return unique_ptr<AbstractItem>(new ImageItem(""));
   case AbstractItem::Button :
-    return make_shared<ButtonItem>("");
+    return unique_ptr<AbstractItem>(new ButtonItem(""));
   case AbstractItem::ChatMessage :
-    return make_shared<ChatMessageItem>("", nullptr, nullptr, nullptr, nullptr, ChatMessageItem::Type::user);
+    return unique_ptr<AbstractItem>(new ChatMessageItem("",
+        nullptr, nullptr, nullptr, nullptr, ChatMessageItem::Type::user));
   case AbstractItem::CheckBox :
-    return make_shared<CheckBoxItem>("", "");
+    return unique_ptr<AbstractItem>(new CheckBoxItem("", ""));
   case AbstractItem::IconText :
-    return make_shared<IconTextItem>("", nullptr, nullptr);
+    return unique_ptr<AbstractItem>(new IconTextItem("", nullptr, nullptr));
   case AbstractItem::InputSelector :
-    return make_shared<InputSelectorItem>();
+    return unique_ptr<AbstractItem>(new InputSelectorItem());
   case AbstractItem::Group :
-    return make_shared<GroupItem>();
+    return unique_ptr<AbstractItem>(new GroupItem());
   case AbstractItem::Entry :
-    return make_shared<EntryItem>("");
+    return unique_ptr<AbstractItem>(new EntryItem(""));
   case AbstractItem::Progress :
-    return make_shared<ProgressItem>(0.0, 0.0, 0.0);
+    return unique_ptr<AbstractItem>(new ProgressItem(0.0, 0.0, 0.0));
   case AbstractItem::Time :
-    return make_shared<TimeItem>();
+    return unique_ptr<AbstractItem>(new TimeItem());
   case AbstractItem::Custom :
-    return make_shared<ButtonItem>("");
+    return unique_ptr<AbstractItem>(new ButtonItem(""));
   }
 
   return nullptr;
index ec24324..70249f1 100644 (file)
@@ -28,7 +28,7 @@ namespace item {
 
 class EXPORT_API ItemFactory {
  public:
-  std::shared_ptr<AbstractItem> CreateItem(AbstractItem::Type type);
+  std::unique_ptr<AbstractItem> CreateItem(AbstractItem::Type type);
   static AbstractItem& GetNullItem();
 };