Release version 0.5.85
[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   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   void Deserialize(tizen_base::Bundle b) override;
86
87   /**
88    * @brief Checks the item type exist in this notification.
89    * @since_tizen 5.5
90    * @param[in] type notification item type
91    * @return true if the item type exists
92    */
93   bool IsItemTypeExist(int type) override;
94
95   /**
96    * @brief Gets the type of ProgressItem.
97    * @since_tizen 5.5
98    * @return AbstractItem::Type::Progress
99    */
100   int GetType() const override;
101
102   /**
103    * @brief Gets the current value of progress.
104    * @since_tizen 5.5
105    * @return The current value of progress
106    */
107   float GetCurrent() const;
108
109   /**
110    * @brief Sets the current value of progress.
111    * @since_tizen 5.5
112    * @param[in] current The current value of progress
113    */
114   void SetCurrent(float current);
115
116   /**
117    * @brief Gets the minimum value of progress.
118    * @since_tizen 5.5
119    * @return The minimum value of progress
120    */
121   float GetMin() const;
122
123   /**
124    * @brief Gets the maximum value of progress.
125    * @since_tizen 5.5
126    * @return The maximum value of progress
127    */
128   float GetMax() const;
129
130   /**
131    * @brief Sets the type of progress.
132    * @since_tizen 5.5
133    * @param[in] type The type of progress
134    */
135   void SetProgressType(ProgressItem::Type type);
136
137   /**
138    * @brief Gets the type of progress.
139    * @since_tizen 5.5
140    * @return The type of progress
141    */
142   Type GetProgressType() const;
143
144    /**
145    * @brief Sets the default unit of progress.
146    * @details the unit is valid when the progress type is default.
147    * @since_tizen 5.5
148    * @param[in] unit The unit of progress
149    */
150   void SetDefaultUnit(std::string unit);
151
152   /**
153    * @brief Gets the default unit of progress.
154    * @details the unit is valid when the progress type is default.
155    * @since_tizen 5.5
156    * @return The type of progress
157    */
158   std::string GetDefaultUnit() const;
159
160  private:
161   class Impl;
162   std::unique_ptr<Impl> impl_;
163 };
164
165 }  // namespace item
166 }  // namespace notification
167
168 #endif  // NOTIFICATION_EX_PROGRESS_ITEM_H_