2 * Copyright (c) 2019 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include "notification-ex/factory_manager.h"
20 #include "notification-ex/default_item_factory.h"
21 #include "notification-ex/default_action_factory.h"
22 #include "notification-ex/null_item.h"
28 #define LOG_TAG "NOTIFICATION_EX"
31 namespace notification {
34 FactoryManager& FactoryManager::GetInst() {
35 static FactoryManager manager;
39 void FactoryManager::RegisterFactory(std::unique_ptr<IItemFactory> factory) {
40 item_factory_ = std::move(factory);
43 void FactoryManager::RegisterFactory(std::unique_ptr<IActionFactory> factory) {
44 action_factory_ = std::move(factory);
47 std::unique_ptr<AbstractItem> FactoryManager::CreateItem(int type) {
48 if (item_factory_.get() == nullptr)
49 item_factory_.reset(new DefaultItemFactory());
51 return item_factory_->CreateItem(type);
54 std::unique_ptr<AbstractAction> FactoryManager::CreateAction(int type) {
55 if (action_factory_.get() == nullptr)
56 action_factory_.reset(new DefaultActionFactory());
58 return action_factory_->CreateAction(type);
61 AbstractItem& FactoryManager::GetNullItem() {
67 } // namespace notification