Merge "Revert "Revert "Use tizen_base::Bundle""" into tizen
[platform/core/api/notification.git] / notification-ex / progress_item.h
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 #ifndef NOTIFICATION_EX_PROGRESS_ITEM_H_
18 #define NOTIFICATION_EX_PROGRESS_ITEM_H_
19
20 #include <string>
21 #include <memory>
22 #include <list>
23
24 #include "notification-ex/abstract_item.h"
25
26 namespace notification {
27 namespace item {
28
29 /**
30  * @brief The class for ProgressItem type notification.
31  * @details
32  * @since_tizen 5.5
33  */
34 class EXPORT_API ProgressItem : public AbstractItem {
35  public:
36   /**
37    * @brief Constructor
38    * @since_tizen 5.5
39    * @param[in] min The minimum value of ProgressItem
40    * @param[in] current The current value ProgressItem
41    * @param[in] max The maximum value of ProgressItem
42    * @param[in] action The action for ProgressItem
43    */
44   ProgressItem(float min, float current, float max,
45       std::shared_ptr<AbstractAction> action = std::shared_ptr<AbstractAction>({}));
46
47   /**
48    * @brief Constructor
49    * @since_tizen 5.5
50    * @param[in] id The ProgressItem id
51    * @param[in] min The minimum value of ProgressItem
52    * @param[in] current The current value ProgressItem
53    * @param[in] max The maximum value of ProgressItem
54    * @param[in] action The action for ProgressItem
55    */
56   ProgressItem(std::string id, float min, float current, float max,
57       std::shared_ptr<AbstractAction> action = std::shared_ptr<AbstractAction>({}));
58
59   /**
60    * @brief Destructor
61    * @since_tizen 5.5
62    */
63   virtual ~ProgressItem();
64
65  public:
66   enum Type {
67     Default,
68     Time,
69     Percent,
70     Pending,
71   };
72
73   /**
74    * @brief Serialize the data of ProgressItem.
75    * @since_tizen 5.5
76    * @return Bundle type data
77    */
78   virtual tizen_base::Bundle Serialize() const override;
79
80   /**
81    * @brief Deserialize the serialized data.
82    * @since_tizen 5.5
83    * @param[in] b The serialized Bundle data
84    */
85   virtual void Deserialize(tizen_base::Bundle b) override;
86
87   /**
88    * @brief Finds the AbstractItem using by notification item id.
89    * @since_tizen 5.5
90    * @param[in] id notification item id
91    * @return AbstractItem object
92    */
93   virtual AbstractItem& FindByID(std::string id) override;
94
95   /**
96    * @brief Checks the item type exist in this notification.
97    * @since_tizen 5.5
98    * @param[in] type notification item type
99    * @return true if the item type exists
100    */
101   bool IsItemTypeExist(int type) override;
102
103   /**
104    * @brief Gets the type of ProgressItem.
105    * @since_tizen 5.5
106    * @return AbstractItem::Type::Progress
107    */
108   int GetType() const override;
109
110   /**
111    * @brief Gets the current value of progress.
112    * @since_tizen 5.5
113    * @return The current value of progress
114    */
115   float GetCurrent() const;
116
117   /**
118    * @brief Sets the current value of progress.
119    * @since_tizen 5.5
120    * @param[in] current The current value of progress
121    */
122   void SetCurrent(float current);
123
124   /**
125    * @brief Gets the minimum value of progress.
126    * @since_tizen 5.5
127    * @return The minimum value of progress
128    */
129   float GetMin() const;
130
131   /**
132    * @brief Gets the maximum value of progress.
133    * @since_tizen 5.5
134    * @return The maximum value of progress
135    */
136   float GetMax() const;
137
138   /**
139    * @brief Sets the type of progress.
140    * @since_tizen 5.5
141    * @param[in] type The type of progress
142    */
143   void SetProgressType(ProgressItem::Type type);
144
145   /**
146    * @brief Gets the type of progress.
147    * @since_tizen 5.5
148    * @return The type of progress
149    */
150   Type GetProgressType() const;
151
152    /**
153    * @brief Sets the default unit of progress.
154    * @details the unit is valid when the progress type is default.
155    * @since_tizen 5.5
156    * @param[in] unit The unit of progress
157    */
158   void SetDefaultUnit(std::string unit);
159
160   /**
161    * @brief Gets the default unit of progress.
162    * @details the unit is valid when the progress type is default.
163    * @since_tizen 5.5
164    * @return The type of progress
165    */
166   std::string GetDefaultUnit() const;
167
168  private:
169   class Impl;
170   std::unique_ptr<Impl> impl_;
171 };
172
173 }  // namespace item
174 }  // namespace notification
175
176 #endif  // NOTIFICATION_EX_PROGRESS_ITEM_H_