From: Junghoon Park Date: Mon, 11 Mar 2019 02:10:28 +0000 (+0900) Subject: Create FactoryManager to register the other factory X-Git-Tag: submit/tizen/20190326.074206~26 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c74de872c8d8aed0a83fd91753361dc68728f14d;p=platform%2Fcore%2Fapi%2Fnotification.git Create FactoryManager to register the other factory Change-Id: Ibd3b9131be2cba08796e04d4d3be459159442134 Signed-off-by: Junghoon Park --- diff --git a/notification-ex/button_item.cc b/notification-ex/button_item.cc index f4a33d8e..0ac28581 100644 --- a/notification-ex/button_item.cc +++ b/notification-ex/button_item.cc @@ -20,7 +20,7 @@ #include "notification-ex/button_item.h" #include "notification-ex/button_item_implementation.h" -#include "notification-ex/item_factory.h" +#include "notification-ex/factory_manager.h" #ifdef LOG_TAG #undef LOG_TAG @@ -66,7 +66,7 @@ void ButtonItem::Deserialize(Bundle b) { AbstractItem& ButtonItem::FindByID(std::string id) { if (GetId() == id) return *this; - return ItemFactory::GetNullItem(); + return FactoryManager::GetInst().GetNullItem(); } std::string ButtonItem::GetTitle() const { diff --git a/notification-ex/chat_message_item.cc b/notification-ex/chat_message_item.cc index e6747094..0f889867 100644 --- a/notification-ex/chat_message_item.cc +++ b/notification-ex/chat_message_item.cc @@ -18,7 +18,7 @@ #include "notification-ex/chat_message_item.h" #include "notification-ex/chat_message_item_implementation.h" -#include "notification-ex/item_factory.h" +#include "notification-ex/factory_manager.h" #include "notification-ex/exception.h" #ifdef LOG_TAG @@ -66,23 +66,25 @@ Bundle ChatMessageItem::Serialize() { } void ChatMessageItem::Deserialize(Bundle b) { - ItemFactory factory; - AbstractItem::Deserialize(b); - std::shared_ptr name = factory.CreateItem(AbstractItem::Text); + std::shared_ptr name = + FactoryManager::GetInst().CreateItem(AbstractItem::Text); name.get()->Deserialize(Bundle(b.GetString(CHATMESSAGE_NAME_KEY))); impl_->name_ = std::static_pointer_cast(name); - std::shared_ptr text = factory.CreateItem(AbstractItem::Text); + std::shared_ptr text = + FactoryManager::GetInst().CreateItem(AbstractItem::Text); text.get()->Deserialize(Bundle(b.GetString(CHATMESSAGE_TEXT_KEY))); impl_->text_ = std::static_pointer_cast(text); - std::shared_ptr data = factory.CreateItem(AbstractItem::Text); + std::shared_ptr data = + FactoryManager::GetInst().CreateItem(AbstractItem::Text); data.get()->Deserialize(Bundle(b.GetString(CHATMESSAGE_DATA_KEY))); impl_->data_ = std::static_pointer_cast(data); - std::shared_ptr time = factory.CreateItem(AbstractItem::Time); + std::shared_ptr time = + FactoryManager::GetInst().CreateItem(AbstractItem::Time); time.get()->Deserialize(Bundle(b.GetString(CHATMESSAGE_TIME_KEY))); impl_->time_ = std::static_pointer_cast(time); @@ -93,7 +95,7 @@ AbstractItem& ChatMessageItem::FindByID(std::string id) { if (GetId() == id) return *this; - return ItemFactory::GetNullItem(); + return FactoryManager::GetInst().GetNullItem(); } TextItem& ChatMessageItem::GetNameItem() const { diff --git a/notification-ex/checkbox_item.cc b/notification-ex/checkbox_item.cc index c4e1e0c6..73211d2d 100644 --- a/notification-ex/checkbox_item.cc +++ b/notification-ex/checkbox_item.cc @@ -18,7 +18,7 @@ #include "notification-ex/checkbox_item.h" #include "notification-ex/checkbox_item_implementation.h" -#include "notification-ex/item_factory.h" +#include "notification-ex/factory_manager.h" #include "notification-ex/exception.h" #ifdef LOG_TAG @@ -64,7 +64,7 @@ AbstractItem& CheckBoxItem::FindByID(std::string id) { if (GetId() == id) return *this; - return ItemFactory::GetNullItem(); + return FactoryManager::GetInst().GetNullItem(); } std::string CheckBoxItem::GetTitle(void) const { diff --git a/notification-ex/default_item_factory.cc b/notification-ex/default_item_factory.cc new file mode 100644 index 00000000..569b4d9f --- /dev/null +++ b/notification-ex/default_item_factory.cc @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include + +#include "notification-ex/default_item_factory.h" +#include "notification-ex/button_item.h" +#include "notification-ex/group_item.h" +#include "notification-ex/entry_item.h" +#include "notification-ex/text_item.h" +#include "notification-ex/exception.h" +#include "notification-ex/input_selector_item.h" +#include "notification-ex/progress_item.h" +#include "notification-ex/icon_item.h" +#include "notification-ex/icon_text_item.h" +#include "notification-ex/image_item.h" +#include "notification-ex/checkbox_item.h" +#include "notification-ex/chat_message_item.h" +#include "notification-ex/time_item.h" + +#ifdef LOG_TAG +#undef LOG_TAG +#endif + +#define LOG_TAG "NOTIFICATION_EX" + +using namespace std; +namespace notification { +namespace item { + +unique_ptr DefaultItemFactory::CreateItem(AbstractItem::Type type) { + switch (type) { + case AbstractItem::NullObject : + THROW(NOTIFICATION_ERROR_INVALID_PARAMETER); + case AbstractItem::Text : + return unique_ptr(new TextItem("","")); + case AbstractItem::Icon : + return unique_ptr(new IconItem("")); + case AbstractItem::Image : + return unique_ptr(new ImageItem("")); + case AbstractItem::Button : + return unique_ptr(new ButtonItem("")); + case AbstractItem::ChatMessage : + return unique_ptr(new ChatMessageItem("", + nullptr, nullptr, nullptr, nullptr, ChatMessageItem::Type::user)); + case AbstractItem::CheckBox : + return unique_ptr(new CheckBoxItem("", "")); + case AbstractItem::IconText : + return unique_ptr(new IconTextItem("", nullptr, nullptr)); + case AbstractItem::InputSelector : + return unique_ptr(new InputSelectorItem()); + case AbstractItem::Group : + return unique_ptr(new GroupItem()); + case AbstractItem::Entry : + return unique_ptr(new EntryItem("")); + case AbstractItem::Progress : + return unique_ptr(new ProgressItem(0.0, 0.0, 0.0)); + case AbstractItem::Time : + return unique_ptr(new TimeItem()); + case AbstractItem::Custom : + return unique_ptr(new ButtonItem("")); + } + + return nullptr; +} + +} // namespace item +} // namespace notification diff --git a/notification-ex/default_item_factory.h b/notification-ex/default_item_factory.h new file mode 100644 index 00000000..489bd401 --- /dev/null +++ b/notification-ex/default_item_factory.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef NOTIFICATION_EX_DEFAULT_ITEM_FACTORY_H_ +#define NOTIFICATION_EX_DEFAULT_ITEM_FACTORY_H_ + +#include + +#include "notification-ex/iitem_factory.h" + +namespace notification { +namespace item { + +class EXPORT_API DefaultItemFactory : public IItemFactory { + public: + virtual ~DefaultItemFactory() = default; + std::unique_ptr CreateItem(AbstractItem::Type type); +}; + +} // namespace item +} // namespace notification + +#endif // NOTIFICATION_EX_DEFAULT_ITEM_FACTORY_H_ diff --git a/notification-ex/entry_item.cc b/notification-ex/entry_item.cc index b3a1674f..143a311d 100644 --- a/notification-ex/entry_item.cc +++ b/notification-ex/entry_item.cc @@ -20,7 +20,7 @@ #include "notification-ex/entry_item.h" #include "notification-ex/entry_item_implementation.h" -#include "notification-ex/item_factory.h" +#include "notification-ex/factory_manager.h" #ifdef LOG_TAG #undef LOG_TAG @@ -69,7 +69,7 @@ void EntryItem::Deserialize(Bundle b) { AbstractItem& EntryItem::FindByID(std::string id) { if (GetId() == id) return *this; - return ItemFactory::GetNullItem(); + return FactoryManager::GetInst().GetNullItem(); } std::string EntryItem::GetText() const { diff --git a/notification-ex/factory_manager.cc b/notification-ex/factory_manager.cc new file mode 100644 index 00000000..19df26f7 --- /dev/null +++ b/notification-ex/factory_manager.cc @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include "notification-ex/factory_manager.h" +#include "notification-ex/default_item_factory.h" +#include "notification-ex/null_item.h" + +#ifdef LOG_TAG +#undef LOG_TAG +#endif + +#define LOG_TAG "NOTIFICATION_EX" + +using namespace std; +namespace notification { +namespace item { + +FactoryManager& FactoryManager::GetInst() { + static FactoryManager manager; + + return manager; +} + +void FactoryManager::RegisterFactory(std::unique_ptr factory) { + factory_ = std::move(factory); +} + +std::unique_ptr FactoryManager::CreateItem( + AbstractItem::Type type) { + if (factory_.get() == nullptr) + factory_.reset(new DefaultItemFactory()); + + return factory_->CreateItem(type); +} + +AbstractItem& FactoryManager::GetNullItem() { + static NullItem item; + return item; +} + +} // namespace item +} // namespace notification diff --git a/notification-ex/factory_manager.h b/notification-ex/factory_manager.h new file mode 100644 index 00000000..e2030003 --- /dev/null +++ b/notification-ex/factory_manager.h @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef NOTIFICATION_EX_FACTORY_MANAGER_H_ +#define NOTIFICATION_EX_FACTORY_MANAGER_H_ + +#include +#include +#include + +#include "notification-ex/iitem_factory.h" + +namespace notification { +namespace item { + +class EXPORT_API FactoryManager { + public: + static FactoryManager& GetInst(); + void RegisterFactory(std::unique_ptr factory); + std::unique_ptr CreateItem(AbstractItem::Type type); + AbstractItem& GetNullItem(); + + private: + FactoryManager() {} + + private: + std::unique_ptr factory_; +}; + +} // namespace item +} // namespace notification + +#endif // NOTIFICATION_EX_FACTORY_MANAGER_H_ diff --git a/notification-ex/group_item.cc b/notification-ex/group_item.cc index f3fa086b..2b526448 100644 --- a/notification-ex/group_item.cc +++ b/notification-ex/group_item.cc @@ -22,7 +22,7 @@ #include "notification-ex/group_item.h" #include "notification-ex/group_item_implementation.h" -#include "notification-ex/item_factory.h" +#include "notification-ex/factory_manager.h" #include "notification-ex/exception.h" #ifdef LOG_TAG @@ -90,13 +90,13 @@ void GroupItem::Deserialize(Bundle b) { if (str_arr.size() == 0) return; - ItemFactory factory; for (string str : str_arr) { Bundle serialized(str); string type_str = serialized.GetString(GROUP_CHILDREN_TYPE_KEY); AbstractItem::Type child_type = static_cast(strtol(type_str.c_str(), NULL, 10)); - shared_ptr child = factory.CreateItem(child_type); + shared_ptr child = + FactoryManager::GetInst().CreateItem(child_type); child.get()->Deserialize(serialized); AddChild(child); } @@ -107,7 +107,7 @@ AbstractItem& GroupItem::FindByID(std::string id) { if (i.get()->GetId() == id) return *i; } - return ItemFactory::GetNullItem(); + return FactoryManager::GetInst().GetNullItem(); } void GroupItem::AddChild(shared_ptr child) { diff --git a/notification-ex/icon_text_item.cc b/notification-ex/icon_text_item.cc index 80c62ee2..bac2a7be 100644 --- a/notification-ex/icon_text_item.cc +++ b/notification-ex/icon_text_item.cc @@ -18,7 +18,7 @@ #include "notification-ex/icon_text_item.h" #include "notification-ex/icon_text_item_implementation.h" -#include "notification-ex/item_factory.h" +#include "notification-ex/factory_manager.h" #include "notification-ex/exception.h" #ifdef LOG_TAG @@ -56,15 +56,15 @@ Bundle IconTextItem::Serialize() { } void IconTextItem::Deserialize(Bundle b) { - ItemFactory factory; - AbstractItem::Deserialize(b); - std::shared_ptr icon = factory.CreateItem(AbstractItem::Icon); + std::shared_ptr icon = + FactoryManager::GetInst().CreateItem(AbstractItem::Icon); icon.get()->Deserialize(Bundle(b.GetString(ICONTEXT_PATH_KEY))); impl_->icon_ = std::static_pointer_cast(icon); - std::shared_ptr text = factory.CreateItem(AbstractItem::Text); + std::shared_ptr text = + FactoryManager::GetInst().CreateItem(AbstractItem::Text); text.get()->Deserialize(Bundle(b.GetString(ICONTEXT_TITLE_KEY))); impl_->text_ = std::static_pointer_cast(text); } @@ -73,7 +73,7 @@ AbstractItem& IconTextItem::FindByID(std::string id) { if (GetId() == id) return *this; - return ItemFactory::GetNullItem(); + return FactoryManager::GetInst().GetNullItem(); } IconItem& IconTextItem::GetIconItem() const { diff --git a/notification-ex/iitem_factory.h b/notification-ex/iitem_factory.h new file mode 100644 index 00000000..aec8652e --- /dev/null +++ b/notification-ex/iitem_factory.h @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef NOTIFICATION_EX_IITEM_FACTORY_H_ +#define NOTIFICATION_EX_IITEM_FACTORY_H_ + +#include +#include +#include + +#include "notification-ex/abstract_item.h" + +namespace notification { +namespace item { + +class EXPORT_API IItemFactory { + public: + virtual ~IItemFactory() = default; + virtual std::unique_ptr CreateItem(AbstractItem::Type type) = 0; +}; + +} // namespace item +} // namespace notification + +#endif // NOTIFICATION_EX_ITEM_FACTORY_H_ diff --git a/notification-ex/image_item.cc b/notification-ex/image_item.cc index 991f16cc..4c437b9b 100644 --- a/notification-ex/image_item.cc +++ b/notification-ex/image_item.cc @@ -18,7 +18,7 @@ #include "notification-ex/image_item.h" #include "notification-ex/image_item_implementation.h" -#include "notification-ex/item_factory.h" +#include "notification-ex/factory_manager.h" #include "notification-ex/exception.h" #ifdef LOG_TAG @@ -64,7 +64,7 @@ AbstractItem& ImageItem::FindByID(std::string id) { if (GetId() == id) return *this; - return ItemFactory::GetNullItem(); + return FactoryManager::GetInst().GetNullItem(); } std::string ImageItem::GetImagePath() const { diff --git a/notification-ex/input_selector_item.cc b/notification-ex/input_selector_item.cc index 73f4f7b2..17385a74 100644 --- a/notification-ex/input_selector_item.cc +++ b/notification-ex/input_selector_item.cc @@ -22,7 +22,7 @@ #include "notification-ex/input_selector_item.h" #include "notification-ex/input_selector_item_implementation.h" -#include "notification-ex/item_factory.h" +#include "notification-ex/factory_manager.h" #ifdef LOG_TAG #undef LOG_TAG @@ -71,7 +71,7 @@ void InputSelectorItem::Deserialize(Bundle b) { AbstractItem& InputSelectorItem::FindByID(std::string id) { if (GetId() == id) return *this; - return ItemFactory::GetNullItem(); + return FactoryManager::GetInst().GetNullItem(); } list InputSelectorItem::GetContents() const { diff --git a/notification-ex/item_factory.cc b/notification-ex/item_factory.cc deleted file mode 100644 index 1dc20eec..00000000 --- a/notification-ex/item_factory.cc +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#include - -#include "notification-ex/item_factory.h" -#include "notification-ex/button_item.h" -#include "notification-ex/group_item.h" -#include "notification-ex/null_item.h" -#include "notification-ex/entry_item.h" -#include "notification-ex/text_item.h" -#include "notification-ex/exception.h" -#include "notification-ex/input_selector_item.h" -#include "notification-ex/progress_item.h" -#include "notification-ex/icon_item.h" -#include "notification-ex/icon_text_item.h" -#include "notification-ex/image_item.h" -#include "notification-ex/checkbox_item.h" -#include "notification-ex/chat_message_item.h" -#include "notification-ex/time_item.h" - -#ifdef LOG_TAG -#undef LOG_TAG -#endif - -#define LOG_TAG "NOTIFICATION_EX" - -using namespace std; -namespace notification { -namespace item { - -unique_ptr ItemFactory::CreateItem(AbstractItem::Type type) { - switch (type) { - case AbstractItem::NullObject : - THROW(NOTIFICATION_ERROR_INVALID_PARAMETER); - case AbstractItem::Text : - return unique_ptr(new TextItem("","")); - case AbstractItem::Icon : - return unique_ptr(new IconItem("")); - case AbstractItem::Image : - return unique_ptr(new ImageItem("")); - case AbstractItem::Button : - return unique_ptr(new ButtonItem("")); - case AbstractItem::ChatMessage : - return unique_ptr(new ChatMessageItem("", - nullptr, nullptr, nullptr, nullptr, ChatMessageItem::Type::user)); - case AbstractItem::CheckBox : - return unique_ptr(new CheckBoxItem("", "")); - case AbstractItem::IconText : - return unique_ptr(new IconTextItem("", nullptr, nullptr)); - case AbstractItem::InputSelector : - return unique_ptr(new InputSelectorItem()); - case AbstractItem::Group : - return unique_ptr(new GroupItem()); - case AbstractItem::Entry : - return unique_ptr(new EntryItem("")); - case AbstractItem::Progress : - return unique_ptr(new ProgressItem(0.0, 0.0, 0.0)); - case AbstractItem::Time : - return unique_ptr(new TimeItem()); - case AbstractItem::Custom : - return unique_ptr(new ButtonItem("")); - } - - return nullptr; -} - -AbstractItem& ItemFactory::GetNullItem() { - static NullItem item; - return item; -} - -} // namespace item -} // namespace notification diff --git a/notification-ex/item_factory.h b/notification-ex/item_factory.h deleted file mode 100644 index 70249f1d..00000000 --- a/notification-ex/item_factory.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef NOTIFICATION_EX_ITEM_FACTORY_H_ -#define NOTIFICATION_EX_ITEM_FACTORY_H_ - -#include -#include -#include - -#include "notification-ex/abstract_item.h" - -namespace notification { -namespace item { - -class EXPORT_API ItemFactory { - public: - std::unique_ptr CreateItem(AbstractItem::Type type); - static AbstractItem& GetNullItem(); -}; - -} // namespace item -} // namespace notification - -#endif // NOTIFICATION_EX_ITEM_FACTORY_H_ diff --git a/notification-ex/item_inflator.cc b/notification-ex/item_inflator.cc index 183f940d..ffb014f3 100644 --- a/notification-ex/item_inflator.cc +++ b/notification-ex/item_inflator.cc @@ -18,7 +18,7 @@ #include -#include "notification-ex/item_factory.h" +#include "notification-ex/factory_manager.h" #include "notification-ex/item_inflator.h" #ifdef LOG_TAG @@ -31,8 +31,9 @@ using namespace std; namespace notification { namespace item { -shared_ptr ItemInflator::Create(ItemFactory factory, Bundle b) { - shared_ptr item = factory.CreateItem(AbstractItem::GetType(b)); +shared_ptr ItemInflator::Create(Bundle b) { + shared_ptr item = + FactoryManager::GetInst().CreateItem(AbstractItem::GetType(b)); item.get()->Deserialize(b); return item; } diff --git a/notification-ex/item_inflator.h b/notification-ex/item_inflator.h index b0a4122b..0f2e9dfb 100644 --- a/notification-ex/item_inflator.h +++ b/notification-ex/item_inflator.h @@ -22,14 +22,13 @@ #include #include "notification-ex/abstract_item.h" -#include "notification-ex/item_factory.h" namespace notification { namespace item { class EXPORT_API ItemInflator { public: - static std::shared_ptr Create(ItemFactory factory, Bundle b); + static std::shared_ptr Create(Bundle b); }; } // namespace item diff --git a/notification-ex/progress_item.cc b/notification-ex/progress_item.cc index 8868cfe7..65200758 100644 --- a/notification-ex/progress_item.cc +++ b/notification-ex/progress_item.cc @@ -21,7 +21,7 @@ #include "notification-ex/exception.h" #include "notification-ex/progress_item.h" #include "notification-ex/progress_item_implementation.h" -#include "notification-ex/item_factory.h" +#include "notification-ex/factory_manager.h" #ifdef LOG_TAG #undef LOG_TAG @@ -77,7 +77,7 @@ void ProgressItem::Deserialize(Bundle b) { AbstractItem& ProgressItem::FindByID(std::string id) { if (GetId() == id) return *this; - return ItemFactory::GetNullItem(); + return FactoryManager::GetInst().GetNullItem(); } float ProgressItem::GetCurrent() const { diff --git a/notification-ex/text_item.cc b/notification-ex/text_item.cc index f01d3e03..d8837828 100644 --- a/notification-ex/text_item.cc +++ b/notification-ex/text_item.cc @@ -20,7 +20,7 @@ #include "notification-ex/text_item.h" #include "notification-ex/text_item_implementation.h" -#include "notification-ex/item_factory.h" +#include "notification-ex/factory_manager.h" #ifdef LOG_TAG #undef LOG_TAG @@ -67,7 +67,7 @@ void TextItem::Deserialize(Bundle b) { AbstractItem& TextItem::FindByID(std::string id) { if (GetId() == id) return *this; - return ItemFactory::GetNullItem(); + return FactoryManager::GetInst().GetNullItem(); } void TextItem::SetContents(std::string contents) { diff --git a/notification-ex/time_item.cc b/notification-ex/time_item.cc index c375d167..c84563a4 100644 --- a/notification-ex/time_item.cc +++ b/notification-ex/time_item.cc @@ -18,7 +18,7 @@ #include "notification-ex/time_item.h" #include "notification-ex/time_item_implementation.h" -#include "notification-ex/item_factory.h" +#include "notification-ex/factory_manager.h" #include "notification-ex/exception.h" #ifdef LOG_TAG @@ -86,7 +86,7 @@ AbstractItem& TimeItem::FindByID(std::string id) { if (GetId() == id) return *this; - return ItemFactory::GetNullItem(); + return FactoryManager::GetInst().GetNullItem(); } time_t TimeItem::GetTime() const { diff --git a/unittest/src/test_button_item.cc b/unittest/src/test_button_item.cc index 167aa951..33208320 100644 --- a/unittest/src/test_button_item.cc +++ b/unittest/src/test_button_item.cc @@ -37,8 +37,7 @@ TEST_F(ButtonItemTest, FindByIDNullItemReturn) { TEST_F(ButtonItemTest, SerializeDeserializeGetTitle) { ButtonItem item("title"); Bundle b = item.Serialize(); - ItemFactory factory; - shared_ptr gen_item = ItemInflator::Create(factory, b); + shared_ptr gen_item = ItemInflator::Create(b); ASSERT_EQ(gen_item.get()->GetType(), item.GetType()); ButtonItem* gen_btn = static_cast(gen_item.get()); diff --git a/unittest/src/test_chat_message_item.cc b/unittest/src/test_chat_message_item.cc index 6952b381..abca4866 100644 --- a/unittest/src/test_chat_message_item.cc +++ b/unittest/src/test_chat_message_item.cc @@ -63,8 +63,7 @@ TEST_F(ChatMessageItemTest, FindByIDNullItemReturn) { TEST_F(ChatMessageItemTest, SerializeDeserialize) { Bundle b = ChatMessageItemTest::item->Serialize(); - ItemFactory factory; - std::shared_ptr gen_item = ItemInflator::Create(factory, b); + std::shared_ptr gen_item = ItemInflator::Create(b); ChatMessageItem* gen_message = static_cast(gen_item.get()); ASSERT_EQ(gen_message->GetNameItem().GetContents(), "name"); ASSERT_EQ(gen_message->GetTextItem().GetContents(), "text"); diff --git a/unittest/src/test_checkbox_item.cc b/unittest/src/test_checkbox_item.cc index 6fd38dd1..8aa0e6b3 100644 --- a/unittest/src/test_checkbox_item.cc +++ b/unittest/src/test_checkbox_item.cc @@ -55,8 +55,7 @@ TEST_F(CheckBoxItemTest, FindByIDNullItemReturn) { TEST_F(CheckBoxItemTest, SerializeDeserialize) { Bundle b = CheckBoxItemTest::item->Serialize(); - ItemFactory factory; - std::shared_ptr gen_item = ItemInflator::Create(factory, b); + std::shared_ptr gen_item = ItemInflator::Create(b); ASSERT_EQ(CheckBoxItemTest::item->GetType(), gen_item.get()->GetType()); CheckBoxItem* gen_checkbox = static_cast(gen_item.get()); diff --git a/unittest/src/test_entry_item.cc b/unittest/src/test_entry_item.cc index b81d8f99..da933d33 100644 --- a/unittest/src/test_entry_item.cc +++ b/unittest/src/test_entry_item.cc @@ -48,8 +48,7 @@ TEST_F(EntryItemTest, FindByIDNullItemReturn) { TEST_F(EntryItemTest, SerializeDeserialize) { EntryItem item("entry_id"); Bundle b = item.Serialize(); - ItemFactory factory; - std::shared_ptr gen_item = ItemInflator::Create(factory, b); + std::shared_ptr gen_item = ItemInflator::Create(b); ASSERT_EQ(gen_item.get()->GetType(), item.GetType()); EntryItem* gen_effect = static_cast(gen_item.get()); diff --git a/unittest/src/test_group_item.cc b/unittest/src/test_group_item.cc index cbe87ef1..6288c8df 100644 --- a/unittest/src/test_group_item.cc +++ b/unittest/src/test_group_item.cc @@ -43,8 +43,7 @@ TEST_F(GroupItemTest, SerializeDeserialize) { item.AddChild(std::make_shared("btn2", "test2")); Bundle b = item.Serialize(); - ItemFactory factory; - shared_ptr gen_item = ItemInflator::Create(factory, b); + shared_ptr gen_item = ItemInflator::Create(b); ASSERT_EQ(gen_item.get()->GetType(), item.GetType()); GroupItem* gen_group = static_cast(gen_item.get()); diff --git a/unittest/src/test_icon_item.cc b/unittest/src/test_icon_item.cc index 8deb06dc..cd2fdbfa 100644 --- a/unittest/src/test_icon_item.cc +++ b/unittest/src/test_icon_item.cc @@ -52,8 +52,7 @@ TEST_F(IconItemTest, FindByIDNullItemReturn) { TEST_F(IconItemTest, SerializeDeserialize) { Bundle b = IconItemTest::item->Serialize(); - ItemFactory factory; - std::shared_ptr gen_item = ItemInflator::Create(factory, b); + std::shared_ptr gen_item = ItemInflator::Create(b); ASSERT_EQ(IconItemTest::item->GetType(), gen_item.get()->GetType()); IconItem* gen_icon = static_cast(gen_item.get()); diff --git a/unittest/src/test_icon_text_item.cc b/unittest/src/test_icon_text_item.cc index dfe8f727..423d0522 100644 --- a/unittest/src/test_icon_text_item.cc +++ b/unittest/src/test_icon_text_item.cc @@ -55,8 +55,7 @@ TEST_F(IconTextItemTest, FindByIDNullItemReturn) { TEST_F(IconTextItemTest, SerializeDeserialize) { Bundle b = IconTextItemTest::item->Serialize(); - ItemFactory factory; - std::shared_ptr gen_item = ItemInflator::Create(factory, b); + std::shared_ptr gen_item = ItemInflator::Create(b); IconTextItem* gen_icon = static_cast(gen_item.get()); ASSERT_EQ(IconTextItemTest::item->GetIconItem().GetImagePath(), gen_icon->GetIconItem().GetImagePath()); ASSERT_EQ(IconTextItemTest::item->GetTextItem().GetContents(), gen_icon->GetTextItem().GetContents()); diff --git a/unittest/src/test_image_item.cc b/unittest/src/test_image_item.cc index 42a5caa6..5aa45e2d 100644 --- a/unittest/src/test_image_item.cc +++ b/unittest/src/test_image_item.cc @@ -53,8 +53,7 @@ TEST_F(ImageItemTest, FindByIDNullItemReturn) { TEST_F(ImageItemTest, SerializeDeserialize) { Bundle b = ImageItemTest::item->Serialize(); - ItemFactory factory; - std::shared_ptr gen_item = ItemInflator::Create(factory, b); + std::shared_ptr gen_item = ItemInflator::Create(b); ASSERT_EQ(ImageItemTest::item->GetType(), gen_item.get()->GetType()); ImageItem* gen_image = static_cast(gen_item.get()); diff --git a/unittest/src/test_input_selector_item.cc b/unittest/src/test_input_selector_item.cc index 9c56bc6b..d2db27d9 100644 --- a/unittest/src/test_input_selector_item.cc +++ b/unittest/src/test_input_selector_item.cc @@ -27,8 +27,7 @@ TEST_F(InputSelectorItemTest, SerializeDeserialize) { item.SetContents(contents); Bundle b = item.Serialize(); - ItemFactory factory; - shared_ptr gen_item = ItemInflator::Create(factory, b); + shared_ptr gen_item = ItemInflator::Create(b); ASSERT_EQ(gen_item.get()->GetType(), item.GetType()); InputSelectorItem* gen_input = static_cast(gen_item.get()); diff --git a/unittest/src/test_progress_item.cc b/unittest/src/test_progress_item.cc index 435fface..d62aab38 100644 --- a/unittest/src/test_progress_item.cc +++ b/unittest/src/test_progress_item.cc @@ -21,8 +21,7 @@ class ProgressItemTest : public ::testing::Test { TEST_F(ProgressItemTest, SerializeDeserializeGetTitle) { ProgressItem item(1.0, 10.0, 100.0); Bundle b = item.Serialize(); - ItemFactory factory; - shared_ptr gen_item = ItemInflator::Create(factory, b); + shared_ptr gen_item = ItemInflator::Create(b); ASSERT_EQ(gen_item.get()->GetType(), item.GetType()); ProgressItem* gen_progress = static_cast(gen_item.get()); diff --git a/unittest/src/test_text_item.cc b/unittest/src/test_text_item.cc index 316e2cda..49ea0fc4 100644 --- a/unittest/src/test_text_item.cc +++ b/unittest/src/test_text_item.cc @@ -50,8 +50,7 @@ TEST_F(TexttItemTest, FindByIDNullItemReturn) { TEST_F(TexttItemTest, SerializeDeserializeGetContents) { TextItem item("text_id", "contents"); Bundle b = item.Serialize(); - ItemFactory factory; - std::shared_ptr gen_item = ItemInflator::Create(factory, b); + std::shared_ptr gen_item = ItemInflator::Create(b); ASSERT_EQ(gen_item.get()->GetType(), item.GetType()); TextItem* gen_text = static_cast(gen_item.get()); diff --git a/unittest/src/test_time_item.cc b/unittest/src/test_time_item.cc index e0514f3a..f595277a 100644 --- a/unittest/src/test_time_item.cc +++ b/unittest/src/test_time_item.cc @@ -54,8 +54,7 @@ TEST_F(TimeItemTest, FindByIDNullItemReturn) { TEST_F(TimeItemTest, SerializeDeserialize) { Bundle b = TimeItemTest::item->Serialize(); - ItemFactory factory; - std::shared_ptr gen_item = ItemInflator::Create(factory, b); + std::shared_ptr gen_item = ItemInflator::Create(b); ASSERT_EQ(TimeItemTest::item->GetType(), gen_item.get()->GetType()); TimeItem* gen_time = static_cast(gen_item.get());