Implementation of ImmutableString
[platform/framework/native/appfw.git] / inc / FSysVibrator.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        FSysVibrator.h
19  * @brief       This is the header file for the %Vibrator class.
20  *
21  * This header file contains the declarations of the %Vibrator class.
22  */
23
24 #ifndef _FSYS_VIBRATOR_H_
25 #define _FSYS_VIBRATOR_H_
26
27 #include <FBaseObject.h>
28
29 namespace Tizen { namespace System
30 {
31
32 /**
33  * @class   Vibrator
34  * @brief   This class handles the vibration functionality of the device.
35  *
36  * @since   2.0
37  *
38  * The %Vibrator class handles the vibration functionality of a device. It allows you to manage the device's vibrator parameters, such as vibration count and level.
39  *
40  * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/system/vibrator_mgmt.htm">Vibrator Management</a>.
41  *
42  * The following example demonstrates how to use the %Vibrator class.
43  *
44  * @code
45  *
46  * #include <FBase.h>
47  * #include <FSystem.h>
48  *
49  * using namespace Tizen::Base;
50  * using namespace Tizen::System;
51  *
52  * class MyVibratorClass
53  * {
54  * public:
55  *  result VibratorExample(void);
56  * private:
57  *  Vibrator vibrator;
58  * };
59  *
60  * result
61  * MyVibratorClass::VibratorExample(void)
62  * {
63  *      result r = vibrator.Construct();
64  *      if (IsFailed(r))
65  *      {
66  *              goto CATCH;
67  *      }
68  *
69  *      // Initializes the vibration pattern
70  *      IntensityDurationVibrationPattern patterns[4] = {{2000, 50}, {1000, 0}, {500, -1}, {1000, 80}};
71  *      int length = sizeof(patterns);
72
73  *      // Vibrates with a given pattern and repeats count
74  *      vibrator.Start(patterns, length, 3);
75  *
76  *      return E_SUCCESS;
77  *
78  * CATCH:
79  *      // Do some exception handling
80  *      return r;
81  * }
82  * @endcode
83  */
84
85 /**
86  * @struct      IntensityDurationVibrationPattern
87  * @brief       This struct has the specified duration and a vibration intensity level.
88  *
89  * The %IntensityDurationVibrationPattern struct has the specified duration and a vibration intensity level. This can be used with Vibrator::Start(IntensityDurationVibrationPattern[] patterns, int length, int repeatCount) as a custom pattern.
90  *
91  * @since 2.1
92  */
93 struct _OSP_EXPORT_ IntensityDurationVibrationPattern
94 {
95         int duration; /**< The duration in milliseconds when the vibrator is on @n
96                         *       The @c duration is not allowed a negative value.
97                         */
98         int intensity; /**< The vibration intensity [@c -1~ @c 100]: @n
99                         *       @li The system default vibration intensity (-1)
100                         *       @li The silent vibration intensity (0)
101                         *       @li The minimum vibration intensity (1)
102                         *       @li The maximum vibration intensity (100)
103                         */
104 };
105
106
107 class _OSP_EXPORT_ Vibrator
108         : public Tizen::Base::Object
109 {
110
111 public:
112         /**
113          * This is the default constructor for this class.
114          *
115          * @since   2.0
116          *
117          * @remarks The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor.
118          */
119         Vibrator(void);
120
121         /**
122          * This is the destructor for this class. @n
123          * This destructor overrides Tizen::Base::Object::~Object().
124          *
125          * @since   2.0
126          *
127          * @remarks If the instance is destroyed before the vibration stops, the vibration is stopped forcefully.
128          */
129         virtual ~Vibrator(void);
130
131         /**
132          * Initializes this instance of %Vibrator.
133          *
134          * @since       2.0
135          *
136          * @return      An error code
137          * @exception   E_SUCCESS           The method is successful.
138          * @exception   E_SYSTEM            An unknown operating system error has occurred.
139          *
140          */
141         result Construct(void);
142
143
144         /**
145          * Vibrates the device with a specified array pattern that has vibration intensity and duration. @n
146          * The %Start() method returns the result immediately so that the vibration occurs simultaneously as the device runs. @n
147          * If this method is called again before the previous vibration stops, the previous vibration is canceled and the new vibration starts immediately. @n
148          * If a new vibrator instance triggers the vibration, the vibrator merges the previous vibration pattern with the new one in the overlapped time. @n
149          * If the system alert occurs such as ring vibration and a system event notification, the vibration can be interrupted. @n
150          * If the application is terminated, the vibration is canceled.
151          *
152          * @since 2.1
153          * @privlevel   public
154          * @privilege   %http://tizen.org/privilege/vibrator
155          *
156          * @return      An error code
157          *
158          * @param[in]   patterns                        An array of @c IntensityDurationVibrationPattern
159          * @param[in]   length                          The length of @c patterns
160          * @param[in]   repeatCount                           The number of times the pattern repeats @n This value must be between @c 1 to @c 100.
161          * @exception   E_SUCCESS           The method is successful.
162          * @exception    E_PRIVILEGE_DENIED  The application does not have the privilege to call this method.
163          * @exception   E_INVALID_ARG       A specified input parameter is invalid.
164          * @exception E_OPERATION_FAILED The device operation has failed.
165          * @remarks The vibration intensity does not apply the change, even if the system default vibration intensity is changed after starting vibration.
166          * @see  IntensityDurationVibrationPattern
167          */
168         result Start(IntensityDurationVibrationPattern* patterns, int length, int repeatCount = 1);
169
170         /**
171          * Vibrates the device with the specified pattern and level. @n
172          * The %Start() method returns the result immediately so that the vibration occurs simultaneously as the device runs.
173          * If this method is called again before the previous vibration stops, the previous vibration is canceled and the new vibration starts immediately.
174          *
175          * @brief       <i>[Deprecated]</i>
176          * @deprecated This method is deprecated. Instead of using this method, use Start(IntensityDurationVibrationPattern*, int, int).
177          * @since 2.0
178          * @privlevel   public
179          * @privilege   %http://tizen.org/privilege/vibrator
180          *
181          * @return      An error code
182          * @param[in]   onPeriod    The period in milliseconds when the vibrator is on @n
183          *                          It should be greater than @c 0.
184          * @param[in]   offPeriod   The period in milliseconds when the vibrator is off @n
185          *                          It should be equal to or greater than @c 0.
186          * @param[in]   count       The number of times to execute the given pattern @n
187          *                          It should be greater than @c 0.
188          * @param[in]   level       The vibration level @n
189          *                          Ranges from [@c 0~ @c 100], where '@c 0' is a special case indicating the system default level.
190          * @exception   E_SUCCESS           The method is successful.
191          * @exception   E_PRIVILEGE_DENIED  The application does not have the privilege to call this method.
192          * @exception   E_INVALID_ARG       A specified input parameter is invalid.
193          * @exception   E_DEVICE_BUSY       The device cannot be approached because of other operations.
194          * @exception   E_DEVICE_FAILED     The device operation has failed.
195          * @remarks     Various devices may have different vibration capabilities.
196          *              If the device supports only one level of vibration, then a level value between [@c 0~ @c 100] results in the default vibration.
197          *              If the device supports many levels of vibration, then a level value @c 0 results in the system default vibration, value @c 1 results in the lowest frequency vibration, value @c 100 results in the highest frequency vibration, and intermediate values result in intermediate vibration levels. @n
198          *              Devices have implementation-specific limits for the total duration of the vibration, and vibration cuts off at that limit even if the duration parameter is greater than the limit.
199          *
200          */
201         result Start(long onPeriod, long offPeriod, int count, int level = 0);
202
203         /**
204          * Vibrates the device for the specified duration at the specified @c level. @n
205          * The %Start() method returns the result immediately so that the vibration occurs simultaneously as the device runs.
206          * If this method is called again before the previous vibration stops, the previous vibration is canceled and the new vibration starts immediately.
207          *
208          * @brief       <i>[Deprecated]</i>
209          * @deprecated This method is deprecated. Instead of using this method, use Start(IntensityDurationVibrationPattern*, int, int).
210          * @since       2.0
211          * @privlevel   public
212          * @privilege   %http://tizen.org/privilege/vibrator
213          *
214          * @return      An error code
215          * @param[in]   milliseconds    The duration for the vibration in milliseconds @n
216          *                              It should be greater than @c 0.
217          * @param[in]   level           The vibration level @n
218          *                              Ranges from [@c 0~ @c 100], where ' @c 0' is a special case indicating the system default level.
219          * @exception   E_SUCCESS       The method is successful.
220          * @exception   E_PRIVILEGE_DENIED  The application does not have the privilege to call this method.
221          * @exception   E_INVALID_ARG       A specified input parameter is invalid.
222          * @exception   E_DEVICE_BUSY       The device cannot be approached because of other operations.
223          * @exception   E_DEVICE_FAILED     The device operation has failed.
224          * @remarks     Various devices have different vibration capabilities. @n
225          *              If the device supports only one level of vibration, then a level value between [@c 0~ @c 100] results in the default vibration.
226          *              If the device supports many levels of vibration, then a level value @c 0 results in the system default vibration, value @c 1 results in the lowest frequency vibration, value @c 100 results in the highest frequency vibration, and intermediate values result in intermediate vibration levels. @n
227          *              Devices have implementation-specific limits for the total duration of the vibration, and vibration cuts off at that limit even if the duration parameter is greater than the limit.
228          *
229          */
230         result Start(long milliseconds, int level = 0);
231
232         /**
233          * Turns the vibrator off.
234          *
235          * @since   2.0
236          * @privlevel   public
237          * @privilege   %http://tizen.org/privilege/vibrator
238          *
239          * @return      An error code
240          * @exception   E_SUCCESS           The method is successful.
241          * @exception   E_PRIVILEGE_DENIED  The application does not have the privilege to call this method.
242          * @exception   E_DEVICE_FAILED     The device operation has failed.
243          *
244          */
245         result Stop(void);
246
247 private:
248         /**
249          * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
250          */
251         Vibrator(const Vibrator& value);
252
253         /**
254          * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
255          */
256         Vibrator& operator =(const Vibrator& value);
257
258 private:
259         friend class _VibratorImpl;
260         class _VibratorImpl* __pVibratorImpl;
261
262 }; // Vibrator
263
264 } } // Tizen::System
265
266 #endif