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 |
|
25 namespace TMS { |
|
26 |
|
27 /** |
|
28 * Mixin class for phone timer |
|
29 */ |
|
30 class TMSTimerObsrv |
|
31 { |
|
32 |
|
33 public: // New functions |
|
34 |
|
35 /** |
|
36 * Destructor |
|
37 */ |
|
38 virtual ~TMSTimerObsrv(){}; |
|
39 |
|
40 /** |
|
41 * This function is called after on timeout |
|
42 */ |
|
43 virtual void HandleTimeOutL() = 0; |
|
44 }; |
|
45 |
|
46 // CLASS DECLARATION |
|
47 |
|
48 /** |
|
49 * Utility class for timer |
|
50 */ |
|
51 class TMSTimer : public CTimer |
|
52 { |
|
53 public: |
|
54 // Constructors and destructor |
|
55 |
|
56 /** |
|
57 * Two-phased constructor. |
|
58 */ |
|
59 IMPORT_C static TMSTimer* NewL( |
|
60 TInt aPriority = CActive::EPriorityStandard); |
|
61 |
|
62 /** |
|
63 * Destructor. |
|
64 */ |
|
65 IMPORT_C virtual ~TMSTimer(); |
|
66 |
|
67 public: |
|
68 // New functions |
|
69 |
|
70 /** |
|
71 * The Callback function is called after the interval |
|
72 * All former request will be canceled first |
|
73 */ |
|
74 IMPORT_C void After(TTimeIntervalMicroSeconds32 anInterval, |
|
75 TCallBack aCallBack); |
|
76 |
|
77 /** |
|
78 * Use the maxin class to notify the timer |
|
79 * All former request will be canceled first |
|
80 */ |
|
81 IMPORT_C void After(TTimeIntervalMicroSeconds32 anInterval, |
|
82 TMSTimerObsrv* aObserver); |
|
83 |
|
84 /** |
|
85 * Cancel the timer if needed |
|
86 */ |
|
87 IMPORT_C void CancelTimer(); |
|
88 |
|
89 protected: |
|
90 // Functions from base classes |
|
91 |
|
92 /** |
|
93 * From CTimer::RunL() |
|
94 */ |
|
95 virtual void RunL(); |
|
96 |
|
97 /** |
|
98 * From CTimer::RunL() |
|
99 */ |
|
100 virtual TInt RunError(TInt aError); |
|
101 |
|
102 /** |
|
103 * From CTimer::DoCancel() |
|
104 */ |
|
105 virtual void DoCancel(); |
|
106 |
|
107 private: |
|
108 |
|
109 /** |
|
110 * C++ default constructor. |
|
111 */ |
|
112 TMSTimer(TInt aPriority); |
|
113 |
|
114 /** |
|
115 * By default Symbian OS constructor is private. |
|
116 */ |
|
117 void ConstructL(); |
|
118 |
|
119 // By default, prohibit copy constructor |
|
120 TMSTimer(const TMSTimer&); |
|
121 |
|
122 // Prohibit assigment operator |
|
123 TMSTimer& operator = (const TMSTimer&); |
|
124 |
|
125 private: |
|
126 // Data |
|
127 |
|
128 // Used by After( anInterval, aCallBack ) |
|
129 TCallBack iCallBack; |
|
130 |
|
131 // Used by After( anInterval, aObserver ) |
|
132 TMSTimerObsrv* iTimerObserver; |
|
133 }; |
|
134 |
|
135 } // namespace TMS |
|
136 |
|
137 #endif // TMSTIMER_H |
|
138 |
|
139 // End of File |
|