|
1 /* |
|
2 * Copyright (c) 2005-2009 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 "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * Name : Lwtimer.h |
|
16 * Part of : LightWeightTimer |
|
17 * This header file is included by the subsystems needing timer |
|
18 * services, but are not responsible for creating the |
|
19 * CTimerManager instance. |
|
20 * Version : SIP/4.0 |
|
21 * |
|
22 */ |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 /** |
|
28 @internalComponent |
|
29 */ |
|
30 |
|
31 |
|
32 #ifndef LWTIMER_H |
|
33 #define LWTIMER_H |
|
34 |
|
35 // INCLUDES |
|
36 #include <e32def.h> |
|
37 |
|
38 // TYPEDEFS |
|
39 |
|
40 //Each timer is associated with an identifier of this type. When a timer is |
|
41 //startedt, TTimerId is returned to the user. |
|
42 //When a timer expires, its TTimerId is passed in the callback. |
|
43 //If the user wishes to stop a certain timer, it must pass the TTimerId of the |
|
44 // timer in question to the Lightweight timer subsystem. |
|
45 typedef TUint32 TTimerId; |
|
46 |
|
47 |
|
48 // CLASS DECLARATION |
|
49 |
|
50 /** |
|
51 * When a timer expires, this interface is called by the Lightweight timer |
|
52 * subsystem. |
|
53 */ |
|
54 class MExpirationHandler |
|
55 { |
|
56 public: // Virtual destructor |
|
57 |
|
58 virtual ~MExpirationHandler() {} |
|
59 |
|
60 public: // New pure virtual functions |
|
61 |
|
62 /** |
|
63 * Indicates that a timer has expired. |
|
64 * |
|
65 * @param aTimerId Identifies the expired timer |
|
66 * @param aTimerParam User specified value which was given when the timer |
|
67 * was set. It can be used to identify the timer in case multiple timers |
|
68 * are running simultaneously. Value is NULL if the timer was set using |
|
69 * CTimerManager::StartL without parameter aTimerParam. Ownership isn't |
|
70 * transferred. |
|
71 */ |
|
72 virtual void TimerExpiredL(TTimerId aTimerId, TAny* aTimerParam) = 0; |
|
73 }; |
|
74 |
|
75 |
|
76 /** |
|
77 * MTimerManager provides methods for starting and stopping timers. |
|
78 */ |
|
79 class MTimerManager |
|
80 { |
|
81 public: // Enumerations |
|
82 enum TTimerIdValues |
|
83 { |
|
84 //TimerId value for a non-existent timer. This value is never returned |
|
85 //to the user of the Lightweight timer subsystem. |
|
86 KNoSuchTimer = 0, |
|
87 |
|
88 //TimerId for an internal dummy timer, which is used simulate a longer |
|
89 //timer without having to use RTimer::At(). This value is never |
|
90 //returned to the user of the Lightweight timer subsystem. |
|
91 KReservedTimer = 1 |
|
92 }; |
|
93 |
|
94 public: // New pure virtual functions |
|
95 |
|
96 /** |
|
97 * Creates a new timer and starts it. |
|
98 * |
|
99 * @pre aObserver != NULL |
|
100 * |
|
101 * @see See also this method 'MExpirationHandler::TimerExpiredL' |
|
102 * |
|
103 * @param aObserver IN: Callback to use when timer expires. Ownership is |
|
104 * not transferred. |
|
105 * @param aMilliseconds Timer duration in milliseconds (with 32 bits, the |
|
106 * max value is ~50 days) |
|
107 * @return value TimerId value identifying the new timer |
|
108 */ |
|
109 virtual TTimerId StartL(MExpirationHandler* aObserver, |
|
110 TUint aMilliseconds) = 0; |
|
111 |
|
112 /** |
|
113 * Creates a new timer and starts it. |
|
114 * |
|
115 * @pre aObserver != NULL |
|
116 * |
|
117 * @see See also this method 'MExpirationHandler::TimerExpiredL' |
|
118 * |
|
119 * @param aObserver IN: Callback to use when timer expires. Ownership is |
|
120 * not transferred. |
|
121 * @param aMilliseconds Timer duration in milliseconds (with 32 bits, the |
|
122 * max value is ~50 days) |
|
123 * @param aTimerParam User specified value which will be passed to the |
|
124 * aObserver function MExpirationHandler::TimerExpiredL when the timer |
|
125 * expires. Ownership isn't transferred. |
|
126 * @return value TimerId value identifying the new timer |
|
127 */ |
|
128 virtual TTimerId StartL(MExpirationHandler* aObserver, |
|
129 TUint aMilliseconds, |
|
130 TAny* aTimerParam) = 0; |
|
131 |
|
132 /** |
|
133 * Stops the specified timer. |
|
134 * |
|
135 * This function doesn't leave in case of error, as it is thought that this |
|
136 * function is usually also called from destructors. |
|
137 * |
|
138 * @param aTimerId Identifies the timer to be stopped |
|
139 * @return value KErrNone: successful |
|
140 * KErrNotFound : no such timer exists |
|
141 */ |
|
142 virtual TInt Stop(TTimerId aTimerId) = 0; |
|
143 |
|
144 /** |
|
145 * Checks if there exists a timer which hasn't expired yet, with the |
|
146 * specified TimerId. |
|
147 * |
|
148 * @param aTimerId Identifies the timer |
|
149 * @return value ETrue: timer exists, KFalse: no such timer |
|
150 */ |
|
151 virtual TBool IsRunning(TTimerId aTimerId) const = 0; |
|
152 |
|
153 /** |
|
154 * Checks how long it will take until the timer expires, with the |
|
155 * specified TimerId. |
|
156 * |
|
157 * @param aTimerId Identifies the timer |
|
158 * @param aExpiresAfterInMillisecs on return contains expires after |
|
159 * value as milliseconds |
|
160 * @return value KErrNone: successful |
|
161 * KErrNotFound : no such timer exists |
|
162 */ |
|
163 virtual TInt ExpiresAfter(TTimerId aTimerId, |
|
164 TUint& aExpiresAfterInMillisecs) const = 0; |
|
165 }; |
|
166 |
|
167 #endif // end of LWTIMER_H |
|
168 |
|
169 // End of File |