70bebc8c81bed043247bb24af61cf3a38d908d6c
[framework/web/wrt-plugins-common.git] / src / modules / API / Haptics / IMotor.h
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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 #ifndef WRTDEVICEAPIS_HAPTICS_IMOTOR_H_
17 #define WRTDEVICEAPIS_HAPTICS_IMOTOR_H_
18
19 #include <dpl/shared_ptr.h>
20 #include "HapticPattern.h"
21 #include "EventStartMotor.h"
22 #include "EventPlayBeep.h"
23
24 namespace WrtDeviceApis {
25 namespace Haptics {
26 namespace Api {
27 class IMotor
28 {
29   public:
30     virtual ~IMotor() = 0;
31
32     /**
33      * Runs this haptic motor.
34      * Result of this operation might be different for different motor types,
35      * e.g. it may cause phone to vibrate.
36      * @param duration Number of miliseconds action should last.
37      * @throw PlatformException If platform error occurs.
38      */
39     virtual void run(unsigned long duration) = 0;
40
41     /**
42      * Runs vibration pattern on this haptic motor.
43      * Result of this operation might be different for different motor types,
44      * e.g. it may cause phone to vibrate.
45      * @param pattern sequence of haptic actions.
46      * @throw PlatformException If platform error occurs.
47      */
48     virtual void run(const HapticPatternPtr& pattern) = 0;
49
50     /**
51      * Runs vibration with event.
52      * Result of this operation might be different for different motor types,
53      * e.g. it may cause phone to vibrate.
54      * @param The event argument is event included duration & pattern.
55      * @throw PlatformException If platform error occurs.
56      */
57     virtual void run(const EventStartMotorPtr& event) = 0;
58
59     /**
60      * Stops this haptic motor.
61      * @throw PlatformException If platform error occurs.
62      */
63     virtual void stopMotor() = 0;
64
65     /**
66      * Cancel this haptic motor.
67      * @throw PlatformException If platform error occurs.
68      */
69     virtual void stopVibration() = 0;
70
71     /**
72        run beep in motor
73        e.g. it may cause phone to beep.
74        @param volume
75        @duration duration Number of miliseconds action should last.
76      **/
77     virtual int playBeep(unsigned long duration,
78             int volume) = 0;
79
80     /**
81        run beep in motor
82        e.g. it may cause phone to beep.
83        @param event
84      **/
85     virtual void playBeep(const EventPlayBeepPtr& event) = 0;
86
87     /**
88        stop beep in motor
89        e.g. it may cause phone to stop beep.
90      **/
91     virtual void stopBeep() = 0;
92 };
93
94 typedef DPL::SharedPtr<IMotor> IMotorPtr;
95 } // Api
96 } // Haptics
97 } // WrtDeviceApis
98
99 #endif /* WRTDEVICEAPIS_HAPTICS_IMOTOR_H_ */