From 9bb5e1ea0089ad1147159741ad6059a228ba8f6b Mon Sep 17 00:00:00 2001 From: Junghoon Park Date: Fri, 8 Mar 2019 15:58:11 +0900 Subject: [PATCH] Change shared_ptr to unique_ptr for ItemFactory - The created item does not need to share each other Change-Id: Ie6d9a205fc7f345baa0897c164895e79e64203a0 Signed-off-by: Junghoon Park --- notification-ex/item_factory.cc | 29 +++++++++++++++-------------- notification-ex/item_factory.h | 2 +- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/notification-ex/item_factory.cc b/notification-ex/item_factory.cc index 0850145..1dc20ee 100644 --- a/notification-ex/item_factory.cc +++ b/notification-ex/item_factory.cc @@ -44,36 +44,37 @@ using namespace std; namespace notification { namespace item { -shared_ptr ItemFactory::CreateItem(AbstractItem::Type type) { +unique_ptr ItemFactory::CreateItem(AbstractItem::Type type) { switch (type) { case AbstractItem::NullObject : THROW(NOTIFICATION_ERROR_INVALID_PARAMETER); case AbstractItem::Text : - return make_shared("",""); + return unique_ptr(new TextItem("","")); case AbstractItem::Icon : - return make_shared(""); + return unique_ptr(new IconItem("")); case AbstractItem::Image : - return make_shared(""); + return unique_ptr(new ImageItem("")); case AbstractItem::Button : - return make_shared(""); + return unique_ptr(new ButtonItem("")); case AbstractItem::ChatMessage : - return make_shared("", nullptr, nullptr, nullptr, nullptr, ChatMessageItem::Type::user); + return unique_ptr(new ChatMessageItem("", + nullptr, nullptr, nullptr, nullptr, ChatMessageItem::Type::user)); case AbstractItem::CheckBox : - return make_shared("", ""); + return unique_ptr(new CheckBoxItem("", "")); case AbstractItem::IconText : - return make_shared("", nullptr, nullptr); + return unique_ptr(new IconTextItem("", nullptr, nullptr)); case AbstractItem::InputSelector : - return make_shared(); + return unique_ptr(new InputSelectorItem()); case AbstractItem::Group : - return make_shared(); + return unique_ptr(new GroupItem()); case AbstractItem::Entry : - return make_shared(""); + return unique_ptr(new EntryItem("")); case AbstractItem::Progress : - return make_shared(0.0, 0.0, 0.0); + return unique_ptr(new ProgressItem(0.0, 0.0, 0.0)); case AbstractItem::Time : - return make_shared(); + return unique_ptr(new TimeItem()); case AbstractItem::Custom : - return make_shared(""); + return unique_ptr(new ButtonItem("")); } return nullptr; diff --git a/notification-ex/item_factory.h b/notification-ex/item_factory.h index ec24324..70249f1 100644 --- a/notification-ex/item_factory.h +++ b/notification-ex/item_factory.h @@ -28,7 +28,7 @@ namespace item { class EXPORT_API ItemFactory { public: - std::shared_ptr CreateItem(AbstractItem::Type type); + std::unique_ptr CreateItem(AbstractItem::Type type); static AbstractItem& GetNullItem(); }; -- 2.7.4