|
1 /* |
|
2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Symbian Foundation License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Haptics test (adaptation) plugin timer header file |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef __HWRMHAPTICSTESTPLUGINTIMER_H_ |
|
21 #define __HWRMHAPTICSTESTPLUGINTIMER_H_ |
|
22 |
|
23 #include <hwrmhapticspluginservice.h> |
|
24 |
|
25 /** |
|
26 * An interface for handling timer expiration events. |
|
27 * |
|
28 * @since S60 5.1 |
|
29 */ |
|
30 class MPluginTimerCallback |
|
31 { |
|
32 public: |
|
33 /** |
|
34 * Method that is called when the timer expires. |
|
35 * Must be implemented by classes that support this interface. |
|
36 * |
|
37 * @param aService Pointer to an object that implements |
|
38 * the MHWRMHapticsPluginCallback interface |
|
39 * and thus handles the callbacks from this |
|
40 * test plugin. In practice this is pointer |
|
41 * to the Haptics plugin manager object. |
|
42 * @param aCommandId ID of the command that was being executed |
|
43 * (or actually emulated as being executed) |
|
44 * at the time the timer expired. |
|
45 * @param aTransId Transaction ID of the command that was being executed |
|
46 * (or actually emulated as being executed) |
|
47 * at the time the timer expired. |
|
48 * @param aRetVal (Emulated) return value of the command that was |
|
49 * being executed (or actually emulated as being executed) |
|
50 * at the time the timer expired. |
|
51 */ |
|
52 virtual void GenericTimerFired( MHWRMHapticsPluginCallback* aService, |
|
53 TInt aCommandId, |
|
54 TUint8 aTransId, |
|
55 TInt aRetVal ) = 0; |
|
56 }; |
|
57 |
|
58 |
|
59 /** |
|
60 * Timer class that triggers command execution emulation. (This test |
|
61 * stub emulates the real adaptation layer haptics command execution |
|
62 * and the emulation "round" is triggered from this class). |
|
63 * |
|
64 * @since S60 5.1 |
|
65 */ |
|
66 class CPluginTimer : public CTimer |
|
67 { |
|
68 public: |
|
69 /** |
|
70 * Static method for instantiation. |
|
71 * The instantiation also adds the instance to active scheduler and |
|
72 * triggers start of the (embedded CTimer) timer. |
|
73 * |
|
74 * @param aInterval Timeout value for command execution emulation. |
|
75 * @param aService Pointer to the object that handles the responses |
|
76 * from command execution emulation. I.e., pointer |
|
77 * to an object outside the test stub plugin that |
|
78 * handles responses from all kinds of haptics plugins. |
|
79 * In practice this is the Haptics plugin manager. |
|
80 * @param aCommandId Id of the command whose execution is emulated. |
|
81 * @param aTransId Id of the transaction to which the emulated command |
|
82 * belongs to. |
|
83 * @param aRetVal Return value of the emulated command. |
|
84 * @param aCallback Pointer to the object that further handles the |
|
85 * command emulation (i.e., pointer to the actual test |
|
86 * stub plugin object). |
|
87 */ |
|
88 static CPluginTimer* NewL( |
|
89 const TTimeIntervalMicroSeconds32& aInterval, |
|
90 MHWRMHapticsPluginCallback* aService, |
|
91 TInt aCommandId, |
|
92 TUint8 aTransId, |
|
93 TInt aRetVal, |
|
94 MPluginTimerCallback* aCallback); |
|
95 |
|
96 /** |
|
97 * Destructor |
|
98 */ |
|
99 ~CPluginTimer(); |
|
100 |
|
101 /** |
|
102 * RunL handles (embedded CTimer) timer expirations. |
|
103 * |
|
104 * @see CActive |
|
105 * @see CTimer |
|
106 */ |
|
107 void RunL(); |
|
108 |
|
109 /** |
|
110 * Getter for transaction Id |
|
111 */ |
|
112 TUint8 TransId() const; |
|
113 |
|
114 private: |
|
115 /** |
|
116 * Constructor |
|
117 * |
|
118 * @param aPriority |
|
119 * @param aService Pointer to an object that implements |
|
120 * the MHWRMHapticsPluginCallback interface |
|
121 * and thus handles the callbacks from this |
|
122 * whole test plugin. |
|
123 * @param aCommandId Id of the command for which the timer-based |
|
124 * command execution emulation is started. |
|
125 * @param aTransId Transaction Id |
|
126 * @param aRetVal |
|
127 * @param aCallback Pointer to an object that implements the above |
|
128 * declared MPluginTimerCallback interface. In |
|
129 * practice this is the CHWRMHapticsTestPlugin |
|
130 * object. |
|
131 */ |
|
132 CPluginTimer( TInt aPriority, |
|
133 MHWRMHapticsPluginCallback* aService, |
|
134 TInt aCommandId, |
|
135 TUint8 aTransId, |
|
136 TInt aRetVal, |
|
137 MPluginTimerCallback* aCallback ); |
|
138 |
|
139 /** |
|
140 * Two-phase construction. ConstructL is needed because parent |
|
141 * class (CTimer) requires two-phase construction. |
|
142 */ |
|
143 void ConstructL(); |
|
144 |
|
145 private: // data |
|
146 |
|
147 /** |
|
148 * Pointer to an object that handles responses from this |
|
149 * test plugin (i.e., in practice the Haptics plugin manager). |
|
150 */ |
|
151 MHWRMHapticsPluginCallback* iService; // Not owned |
|
152 |
|
153 /** |
|
154 * Id of the command whose execution is being emulated by |
|
155 * the test plugin |
|
156 */ |
|
157 TInt iCommandId; |
|
158 |
|
159 /** |
|
160 * Id of the transaction to which the command, whose execution |
|
161 * is being emulated by the test plugin, belongs to |
|
162 */ |
|
163 TUint8 iTransId; |
|
164 |
|
165 /** |
|
166 * Return value that the emulated command execution is to return. |
|
167 */ |
|
168 TInt iRetVal; |
|
169 |
|
170 /** |
|
171 * Pointer to an object that further handles the timer expiries |
|
172 * from this CPluginTimer object. |
|
173 * I.e, pointer to the actual test plugin object |
|
174 */ |
|
175 MPluginTimerCallback* iCallback; // Not owned |
|
176 |
|
177 }; |
|
178 |
|
179 |
|
180 #endif // __HWRMHAPTICSTESTPLUGINTIMER_H_ |