|
1 /* |
|
2 * Copyright (c) 2002 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 * This is the definition for CDosEvent class. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef __DOSEVENT_H__ |
|
21 #define __DOSEVENT_H__ |
|
22 |
|
23 #include "doseventrcvservice.h" |
|
24 |
|
25 class CDosEventRcvService; |
|
26 class CDosWaitingEvent; |
|
27 |
|
28 /** |
|
29 * It represents an event type that has at least one listener. It forms part of a list of |
|
30 * of events that is checked by the EventManager when an event arrives to the DosServer. |
|
31 * It maintains a list of listeners wishing to receive the type of event. |
|
32 */ |
|
33 NONSHARABLE_CLASS( CDosEvent ) : public CBase |
|
34 { |
|
35 public: |
|
36 /** |
|
37 * Constructor. |
|
38 */ |
|
39 inline CDosEvent(); |
|
40 |
|
41 /** |
|
42 * Destructor. |
|
43 */ |
|
44 ~CDosEvent(); |
|
45 |
|
46 /** |
|
47 * NewL function that creates the object. |
|
48 * @param aEvent Unique Id of the event. |
|
49 * @return A pinter to the newly created object. |
|
50 */ |
|
51 static CDosEvent* NewL(TUint aEvent); |
|
52 |
|
53 /** |
|
54 * The function compares two events. It's used to maintain an order in the Event array owned by |
|
55 * CEventManagerBase. |
|
56 * @param aFirst One event. |
|
57 * @param aSecond The other event. |
|
58 * @return -1 if first < second, 1 if first > second or 0 if equal. |
|
59 */ |
|
60 static TInt Compare(const CDosEvent& aFirst,const CDosEvent& aSecond); |
|
61 |
|
62 /** |
|
63 * Returns the event Id. |
|
64 * @return Event Id. |
|
65 */ |
|
66 inline TUint Event() const; |
|
67 |
|
68 /** |
|
69 * Returns the number of listeners registered to this event. |
|
70 * @return Number of listeners. |
|
71 */ |
|
72 inline TInt ListenerCount() const; |
|
73 |
|
74 /** |
|
75 * Adds a listener to the event's list. |
|
76 * @param aListener A pointer to the listener to be added. |
|
77 */ |
|
78 void AddListener(CDosEventRcvService* aListener); |
|
79 |
|
80 /** |
|
81 * Removes a listener from the event's list. |
|
82 * @param aListener A pointer to the listener to be removed. |
|
83 */ |
|
84 void RemoveListener(CDosEventRcvService* aListener); |
|
85 |
|
86 /** |
|
87 * It delivers an event to all the listeners in the event's list. |
|
88 * @param aEvent A pointer to the event. |
|
89 */ |
|
90 void InformListeners(CDosWaitingEvent* aEvent); |
|
91 |
|
92 private: |
|
93 /** |
|
94 * Symbian two-phased constructor. |
|
95 * @param aEvent Unique Id of the event type. |
|
96 */ |
|
97 void ConstructL(TUint aEvent); |
|
98 |
|
99 /** |
|
100 * It tells if a certain listener is registered for this event type. |
|
101 * @param aListener A pointer to the listener to be checked. |
|
102 * @return ETrue if the listener is on the list, EFalse otherwise. |
|
103 */ |
|
104 TBool ListenerRegistered(CDosEventRcvService* aListener); |
|
105 |
|
106 private: |
|
107 //A list of clients listening to this event type. |
|
108 TSglQue<CDosEventRcvService> iListenerList; |
|
109 |
|
110 //Use to browser trough the iListenerList. |
|
111 TSglQueIter<CDosEventRcvService> iListenerIter; |
|
112 |
|
113 //Id of the event. |
|
114 TUint iEventName; |
|
115 |
|
116 //Number of listeners in the list. |
|
117 TInt iListenerCount; |
|
118 }; |
|
119 |
|
120 #include "dosevent.inl" |
|
121 |
|
122 #endif // __DOSEVENT_H__ |