To not to GetSharedPath if there is no image item in chat-message item
[platform/core/api/notification.git] / notification-ex / factory_manager.cc
1 /*
2  * Copyright (c) 2019 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 #include <dlog.h>
18
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"
23
24 #ifdef LOG_TAG
25 #undef LOG_TAG
26 #endif
27
28 #define LOG_TAG "NOTIFICATION_EX"
29
30 using namespace std;
31 namespace notification {
32 namespace item {
33
34 FactoryManager& FactoryManager::GetInst() {
35   static FactoryManager manager;
36   return manager;
37 }
38
39 void FactoryManager::RegisterFactory(std::unique_ptr<IItemFactory> factory) {
40   item_factory_ = std::move(factory);
41 }
42
43 void FactoryManager::RegisterFactory(std::unique_ptr<IActionFactory> factory) {
44   action_factory_ = std::move(factory);
45 }
46
47 std::unique_ptr<AbstractItem> FactoryManager::CreateItem(int type) {
48   if (item_factory_.get() == nullptr)
49     item_factory_.reset(new DefaultItemFactory());
50
51   return item_factory_->CreateItem(type);
52 }
53
54 std::unique_ptr<AbstractAction> FactoryManager::CreateAction(int type) {
55   if (action_factory_.get() == nullptr)
56     action_factory_.reset(new DefaultActionFactory());
57
58   return action_factory_->CreateAction(type);
59 }
60
61 AbstractItem& FactoryManager::GetNullItem() {
62   static NullItem item;
63   return item;
64 }
65
66 }  // namespace item
67 }  // namespace notification