|
1 /* |
|
2 * Copyright (c) 2010 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 * Utility class for CTimer object |
|
16 * |
|
17 */ |
|
18 |
|
19 #ifndef TMSTIMER_H |
|
20 #define TMSTIMER_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32base.h> |
|
24 #include <glib.h> |
|
25 |
|
26 namespace TMS { |
|
27 |
|
28 /** |
|
29 * TMSTimerObserver observer. |
|
30 */ |
|
31 class TMSTimerObserver |
|
32 { |
|
33 public: |
|
34 |
|
35 /** |
|
36 * Called upon timer timeout. |
|
37 */ |
|
38 virtual void TimerEvent() = 0; |
|
39 }; |
|
40 |
|
41 // CLASS DECLARATION |
|
42 /** |
|
43 * TMSTimer - Timer service. |
|
44 */ |
|
45 class TMSTimer : protected CTimer |
|
46 { |
|
47 public: |
|
48 |
|
49 /** |
|
50 * Two-phased constructor. |
|
51 */ |
|
52 IMPORT_C static TMSTimer* NewL(gint aPriority = CActive::EPriorityStandard); |
|
53 |
|
54 /** |
|
55 * Destructor. |
|
56 */ |
|
57 IMPORT_C virtual ~TMSTimer(); |
|
58 |
|
59 /** |
|
60 * Call callback method upon timer timeout event. |
|
61 * All former request will be canceled first |
|
62 */ |
|
63 IMPORT_C void NotifyAfter(gint timeout, TCallBack aCallBack); |
|
64 |
|
65 /** |
|
66 * Call client observer upon timer timeout event. |
|
67 * All former request will be canceled first |
|
68 */ |
|
69 IMPORT_C void NotifyAfter(gint timeout, TMSTimerObserver& observer); |
|
70 |
|
71 /** |
|
72 * Cancel the timer |
|
73 */ |
|
74 IMPORT_C void CancelNotify(); |
|
75 |
|
76 /** |
|
77 * Determines if the timer is running. |
|
78 */ |
|
79 IMPORT_C gboolean IsRunning(); |
|
80 |
|
81 protected: |
|
82 |
|
83 /** |
|
84 * From CTimer::RunL() |
|
85 */ |
|
86 virtual void RunL(); |
|
87 |
|
88 /** |
|
89 * From CTimer::RunL() |
|
90 */ |
|
91 virtual TInt RunError(TInt aError); |
|
92 |
|
93 /** |
|
94 * From CTimer::DoCancel() |
|
95 */ |
|
96 virtual void DoCancel(); |
|
97 |
|
98 private: |
|
99 |
|
100 /** |
|
101 * C++ default constructor. |
|
102 */ |
|
103 TMSTimer(gint aPriority); |
|
104 |
|
105 /** |
|
106 * Symbian OS constructor. |
|
107 */ |
|
108 void ConstructL(); |
|
109 |
|
110 // By default, prohibit copy constructor |
|
111 TMSTimer(const TMSTimer&); |
|
112 |
|
113 // Prohibit assigment operator |
|
114 TMSTimer& operator = (const TMSTimer&); |
|
115 |
|
116 private: |
|
117 |
|
118 // Optional callback instead of observer |
|
119 TCallBack iCallBack; |
|
120 |
|
121 // Observer for notify service. |
|
122 TMSTimerObserver* iObserver; |
|
123 }; |
|
124 |
|
125 } //namespace TMS |
|
126 |
|
127 #endif //TMSTIMER_H |
|
128 |