Add progress item implementation
[platform/core/api/notification.git] / notification-ex / item_factory.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 <memory>
20
21 #include "notification-ex/item_factory.h"
22 #include "notification-ex/button_item.h"
23 #include "notification-ex/group_item.h"
24 #include "notification-ex/null_item.h"
25 #include "notification-ex/exception.h"
26 #include "notification-ex/input_selector_item.h"
27 #include "notification-ex/progress_item.h"
28
29 #ifdef LOG_TAG
30 #undef LOG_TAG
31 #endif
32
33 #define LOG_TAG "NOTIFICATION_EX"
34
35 using namespace std;
36 namespace notification {
37 namespace item {
38
39 shared_ptr<AbstractItem> ItemFactory::CreateItem(AbstractItem::Type type) {
40   switch (type) {
41   case AbstractItem::NullObject :
42     THROW(NOTIFICATION_ERROR_INVALID_PARAMETER);
43   case AbstractItem::Text :
44     return make_shared<ButtonItem>("");
45   case AbstractItem::Icon :
46     return make_shared<ButtonItem>("");
47   case AbstractItem::Image :
48     return make_shared<ButtonItem>("");
49   case AbstractItem::Button :
50     return make_shared<ButtonItem>("");
51   case AbstractItem::ChatMessage :
52     return make_shared<ButtonItem>("");
53   case AbstractItem::CheckBox :
54     return make_shared<ButtonItem>("");
55   case AbstractItem::IconText :
56     return make_shared<ButtonItem>("");
57   case AbstractItem::InputSelector :
58     return make_shared<InputSelectorItem>();
59   case AbstractItem::Group :
60     return make_shared<GroupItem>();
61   case AbstractItem::Effect :
62     return make_shared<ButtonItem>("");
63   case AbstractItem::Progress :
64     return make_shared<ProgressItem>(0.0, 0.0, 0.0);
65   case AbstractItem::Custom :
66     return make_shared<ButtonItem>("");
67   }
68
69   return nullptr;
70 }
71
72 AbstractItem& ItemFactory::GetNullItem() {
73   static NullItem item;
74   return item;
75 }
76
77 }  // namespace item
78 }  // namespace notification