838aa603efd36d006213a39a6fb8a8e37eee1e72
[platform/framework/native/appfw.git] / inc / FLclTimeRule.h
1 //
2 // Copyright (c) 2012 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 /**
18  * @file                FLclTimeRule.h
19  * @brief               This is the header file for the %TimeRule class.
20  *
21  * This header file contains declarations of the %TimeRule class.
22  */
23 #ifndef _FLCL_TIME_RULE_H_
24 #define _FLCL_TIME_RULE_H_
25
26 #include <FBaseObject.h>
27 #include <FSysSystemTime.h>
28
29 namespace Tizen { namespace Locales
30 {
31
32 /**
33  * @class               TimeRule
34  * @brief               This class is for setting and getting the time rule.
35  *
36  * @since               2.0
37  *
38  * @final       This class is not intended for extension.
39  *
40  * The %TimeRule class defines the time rule and provides methods for setting and getting it.
41  * This class does not execute any operation with its value and is mainly used when periodically repeated time rules are defined.
42  * For example, the daylight saving time rule.
43  *
44  * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/locales/time_rules.htm">Time Rules</a>.
45  *
46  * @see         Tizen::Locales::TimeZone
47  */
48
49 /**
50 * @enum Month
51 *
52 * Defines the months. @n
53 * The indexing is 1-based.
54 *
55 * @since                2.0
56 */
57 enum Month
58 {
59         JANUARY = 1,    /**< January    */
60         FEBRUARY,       /**< February   */
61         MARCH,          /**< March              */
62         APRIL,          /**< April              */
63         MAY,            /**< May                */
64         JUNE,           /**< June               */
65         JULY,           /**< July               */
66         AUGUST,         /**< August             */
67         SEPTEMBER,      /**< September  */
68         OCTOBER,        /**< October    */
69         NOVEMBER,       /**< November   */
70         DECEMBER,       /**< December   */
71         MONTH_UNDEFINED = -1    // Undefined
72 };
73
74
75 /**
76 * @enum DayOfWeek
77 *
78 * Defines the days of the week. @n
79 * The indexing is 1-based.
80 *
81 * @since                2.0
82 */
83 enum DayOfWeek
84 {
85         SUNDAY = 1,                 /**< Sunday */
86         MONDAY,                     /**< Monday */
87         TUESDAY,                    /**< Tuesday */
88         WEDNESDAY,                  /**< Wednesday */
89         THURSDAY,                   /**< Thursday */
90         FRIDAY,                     /**< Friday */
91         SATURDAY,                   /**< Saturday */
92         DAY_OF_WEEK_UNDEFINED = -1  //*< Undefined */
93 };
94
95 /**
96  * @enum Week
97  *
98  * Defines the week.
99  *
100  * @since               2.0
101  */
102 enum Week
103 {
104         FIRST_WEEK = 1,             /**< The first week */
105         SECOND_WEEK = 2,            /**< The second week */
106         THIRD_WEEK = 3,             /**< The third week */
107         FOURTH_WEEK = 4,            /**< The fourth week */
108         FIFTH_WEEK = 5,             /**< The fifth week */
109         SIXTH_WEEK = 6,             /**< The sixth week */
110         LAST_WEEK = -2,             /**< The last week */
111         WEEK_UNDEFINED = -1         //*< Undefined */
112 };
113
114 class _OSP_EXPORT_ TimeRule
115         : public Tizen::Base::Object
116 {
117 public:
118         /**
119          * Initializes the current instance of %TimeRule with the values of the specified %TimeRule instance. @n
120          * Copying of objects using this copy constructor is allowed.
121          *
122          * @since                       2.0
123          *
124          * @param[in]           timeRule                        An instance of %TimeRule
125          */
126         TimeRule(const TimeRule& timeRule);
127
128         /**
129          * Assigns the value of the specified instance to the current instance of %TimeRule. @n
130          * Copying of objects using this copy assignment operator is allowed.
131          *
132          * @since                       2.0
133          *
134          * @param[in]           timeRule                        An instance of %TimeRule
135          */
136         TimeRule& operator =(const TimeRule& timeRule);
137
138         /**
139          * This is the destructor for this class. @n
140          * This destructor overrides Tizen::Base::Object::~Object().
141          *
142          * @since               2.0
143          */
144         virtual ~TimeRule(void);
145
146         /**
147          * Initializes the current instance of %TimeRule with the specified @c month, @c day, @c hour,
148          * @c minute, and @c timeMode.
149          *
150          * @since                       2.0
151          *
152          * @param[in]           month                           The month
153          * @param[in]           day                                     The day
154          * @param[in]           hour                            The hour
155          * @param[in]           minute                          The minute
156          * @param[in]           timeMode                        The time mode - TIME_MODE_UTC, TIME_MODE_STANDARD, or TIME_MODE_WALL
157          */
158         TimeRule(Month month, int day, int hour = 0, int minute = 0, Tizen::System::TimeMode timeMode = Tizen::System::TIME_MODE_WALL);
159
160         /**
161          * Initializes the current instance of %TimeRule with the specified @c month, @c week,
162          * @c dayOfWeek, @c hour, @c minute, and @c timeMode.
163          *
164          * @since                       2.0
165          *
166          * @param[in]           month                           The month
167          * @param[in]           week                            The week
168          * @param[in]           dayOfWeek                       The day of the week
169          * @param[in]           hour                            The hour
170          * @param[in]           minute                          The minute
171          * @param[in]           timeMode                        The time mode - TIME_MODE_UTC, TIME_MODE_STANDARD, or TIME_MODE_WALL
172          */
173         TimeRule(Month month, Week week, DayOfWeek dayOfWeek,
174                 int hour = 0, int minute = 0, Tizen::System::TimeMode timeMode = Tizen::System::TIME_MODE_WALL);
175
176         /**
177          * Initializes the current instance of %TimeRule with the specified @c month, @c day,
178          * @c dayOfWeek, @c onOrAfterDay setting, @c hour, @c minute, and @c timeMode.
179          *
180          * @since                       2.0
181          *
182          * @param[in]           month                           The month
183          * @param[in]           day                                     The day
184          * @param[in]           dayOfWeek                       The day of the week
185          * @param[in]           onOrAfterDay            Set to @c true to select the first @c dayOfWeek
186          *                                        @b on @b or @b after @c day, @n
187          *                                        else @c false to select the last @c dayOfWeek
188          *                                        @b on @b or @b before @c day
189          * @param[in]           hour                            The hour
190          * @param[in]           minute                          The minute
191          * @param[in]           timeMode                        The time mode - TIME_MODE_UTC, TIME_MODE_STANDARD, or TIME_MODE_WALL
192          */
193         TimeRule(Month month, int day, DayOfWeek dayOfWeek,
194                 bool onOrAfterDay, int hour = 0, int minute = 0, Tizen::System::TimeMode timeMode = Tizen::System::TIME_MODE_WALL);
195
196         /**
197          * Gets the month.
198          *
199          * @since                       2.0
200          *
201          * @return                      The month
202          */
203         Month GetMonth(void) const;
204
205         /**
206          * Gets the day.
207          *
208          * @since                       2.0
209          *
210          * @return                      An integer value indicating the day, @n
211          *                                        else @c -1 if the value of day is undefined
212          */
213         int GetDay(void) const;
214
215         /**
216          * Gets the week.
217          *
218          * @since                       2.0
219          *
220          * @return                      The week, @n
221          *                                        else @c -1 if the value of week is undefined
222          */
223         Week GetWeek(void) const;
224
225         /**
226          * Gets the day of the week.
227          *
228          * @since                       2.0
229          *
230          * @return                      The day of the week, @n
231          *                                        else @c -1 if the value of day of the week is undefined
232          */
233         DayOfWeek GetDayOfWeek(void) const;
234
235         /**
236          * Gets the hour.
237          *
238          * @since                       2.0
239          *
240          * @return                      An integer value indicating the hour
241          */
242         int GetHour(void) const;
243
244         /**
245          * Gets the minute.
246          *
247          * @since                       2.0
248          *
249          * @return                      An integer value indicating the minute
250          */
251         int GetMinute(void) const;
252
253         /**
254          * Gets the time mode.
255          *
256          * @since                       2.0
257          *
258          * @return                      An instance of Tizen::System::TimeMode
259          */
260         Tizen::System::TimeMode GetTimeMode(void) const;
261
262         /**
263          * Gets the value of the @c onOrAfterDay field.
264          *
265          * @since                       2.0
266          *
267          * @return                      A @c boolean value of the @c onOrAfterDay field
268          */
269         bool IsOnOrAfterDay(void) const;
270
271         /**
272          * Checks whether the value of the specified instance is equal to that of the current instance.
273          *
274          * @since                       2.0
275          *
276          * @return                      @c true if the value of the specified instance is equal to that of the current instance, @n
277          *                                        else @c false
278          * @param[in]           obj The object to compare with the current instance
279          */
280         virtual bool Equals(const Tizen::Base::Object& obj) const;
281
282         /**
283          * Gets the hash value of the current instance.
284          *
285          * @since                       2.0
286          *
287          * @return                      The hash value of the current instance
288          */
289         virtual int GetHashCode(void) const;
290
291 private:
292         /**
293          * Initializes a %TimeRule instance with given values.
294          *
295          * @return                      An error code
296          * @param[in]           month                                   The month
297          * @param[in]           day                                             The day
298          * @param[in]           week                                    The week
299          * @param[in]           dayOfWeek                               The day of week
300          * @param[in]           beforeAfter                             If @c after is ON_OR_AFTER_DAY, this rule selects the first @c dayOfWeek
301          *                                                                                      @b on @b or @b after @c day.
302          *                                                                                      If @c after is ON_OR_BEFORE_DAY, this rule selects the last @c dayOfWeek
303          *                                                                                      @b on @b or @b before @c day.
304          * @param[in]           hour                                    The hour
305          * @param[in]           minute                                  The minute
306          * @param[in]           timeMode                                The time mode - TIME_MODE_UTC, TIME_MODE_STANDARD, TIME_MODE_WALL
307          */
308         void SetValue(Month month, int day, Week week,
309                 DayOfWeek dayOfWeek, bool onOrAfterDay, int hour,
310                 int minute, Tizen::System::TimeMode timeMode);
311
312         int GetRuleMode(void) const;
313
314         static const int DAY_UNDEFINED = -1;
315
316         Month __month;
317         int __day;
318         Week __week;
319         DayOfWeek __dayOfWeek;
320         int __hour;
321         int __minute;
322         Tizen::System::TimeMode __timeMode;
323         bool __onOrAfterDay;
324
325
326         friend class _TimeRuleImpl;
327         class _TimeRuleImpl* __pTimeRuleImpl;
328
329         friend class _TimeZoneImpl;
330         friend class _LocaleData;
331 }; // TimeRule
332
333 }} // Tizen::Locales
334 #endif  // _FLCL_TIME_RULE_H_