|
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 "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 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef CIPTVTESTEVENTWAITER_H |
|
21 #define CIPTVTESTEVENTWAITER_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32base.h> |
|
25 #include <e32cmn.h> |
|
26 |
|
27 // CONSTANTS |
|
28 |
|
29 // MACROS |
|
30 |
|
31 // DATA TYPES |
|
32 |
|
33 // FUNCTION PROTOTYPES |
|
34 |
|
35 // FORWARD DECLARATIONS |
|
36 class MIptvTestEventWaiterObserver; |
|
37 class CIptvTestEvent; |
|
38 |
|
39 // CLASS DECLARATION |
|
40 |
|
41 /** |
|
42 * |
|
43 * CIptvTestEventWaiter USAGE: |
|
44 * |
|
45 * Implement callbacks from MIptvTestEventWaiterObserver. |
|
46 * Create your own event class inherited from CIptvTestEvent. |
|
47 * Create instance. |
|
48 * |
|
49 * Add events that are expected to happen with CIptvTestEventWaiter::AddEvent method. |
|
50 * - Two queues: sequential events and others |
|
51 * |
|
52 * When event happen, call CIptvTestEventWaiter::EventHappened(event) |
|
53 * - This will compare the event to the ones in queues with CIptvTestEvent::Compare() method. |
|
54 * First tries to find not sequential events and then last sequential event in queue. |
|
55 * - If event is not found or it's timedout MIptvTestEventWaiterObserver::EventWaiterErrorL is called. |
|
56 * |
|
57 * @since |
|
58 */ |
|
59 |
|
60 class CIptvTestEventWaiter : public CActive |
|
61 { |
|
62 public: |
|
63 public: // Constructors and destructor |
|
64 |
|
65 /** |
|
66 * Two-phased constructor. |
|
67 */ |
|
68 IMPORT_C static CIptvTestEventWaiter* NewL(MIptvTestEventWaiterObserver& aObserver); |
|
69 |
|
70 /** |
|
71 * Destructor. |
|
72 */ |
|
73 IMPORT_C virtual ~CIptvTestEventWaiter(); |
|
74 |
|
75 public: // New functions |
|
76 |
|
77 /** |
|
78 * Checks if events have timeouted |
|
79 */ |
|
80 IMPORT_C TInt CheckTimeouts(); |
|
81 |
|
82 /** |
|
83 * Will add an event to queue and also check all events if they have timeouted |
|
84 */ |
|
85 IMPORT_C TInt AddEvent(CIptvTestEvent* aEvent, TBool aSequential); |
|
86 |
|
87 /** |
|
88 * Will check the event against the events in queue |
|
89 * If event is found it is returned in aQueuedEvent |
|
90 * If event is not found the first event in event queue is returned in aQueuedEvent |
|
91 */ |
|
92 IMPORT_C TInt EventHappened(CIptvTestEvent* aEvent, CIptvTestEvent** aQueuedEvent); |
|
93 |
|
94 /** |
|
95 * Resets the event waiter system. All events are deleted. |
|
96 */ |
|
97 IMPORT_C TInt Reset(); |
|
98 |
|
99 /** |
|
100 * Returns the amount of events left in queues |
|
101 */ |
|
102 IMPORT_C TInt GetEventCount(); |
|
103 |
|
104 protected: //from base classes |
|
105 |
|
106 // from CActive |
|
107 |
|
108 /* |
|
109 * RunL() |
|
110 * |
|
111 * Handle request completion events |
|
112 * |
|
113 */ |
|
114 void RunL(); |
|
115 |
|
116 /* |
|
117 * DoCancel() |
|
118 * |
|
119 * Cancel any outstanding requests |
|
120 * |
|
121 */ |
|
122 void DoCancel(); |
|
123 |
|
124 private: |
|
125 |
|
126 /** |
|
127 * C++ default constructor. |
|
128 */ |
|
129 CIptvTestEventWaiter(MIptvTestEventWaiterObserver& aObserver); |
|
130 |
|
131 /** |
|
132 * By default Symbian 2nd phase constructor is private. |
|
133 */ |
|
134 void ConstructL(); |
|
135 |
|
136 private: // Data |
|
137 |
|
138 private: |
|
139 |
|
140 // Events which should happen sequential |
|
141 RPointerArray<CIptvTestEvent> iEventQueue; |
|
142 |
|
143 // Events which have no particular order where they happen |
|
144 RPointerArray<CIptvTestEvent> iEventDump; |
|
145 |
|
146 RPointerArray<CIptvTestEvent> iPastEvents; |
|
147 |
|
148 MIptvTestEventWaiterObserver& iObserver; |
|
149 |
|
150 RTimer iTimer; |
|
151 }; |
|
152 |
|
153 #endif // CIPTVTESTEVENTWAITER_H |
|
154 |
|
155 // End of File |