|
1 /* |
|
2 * Copyright (c) 2004 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: Generic observer array. |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef __RGENERICOBSERVERARRAYBASE_H |
|
19 #define __RGENERICOBSERVERARRAYBASE_H |
|
20 |
|
21 // INCLUDES |
|
22 #include <E32Base.h> |
|
23 |
|
24 |
|
25 |
|
26 // CLASS DECLARATION |
|
27 /** |
|
28 * Observer notify mediator base. |
|
29 * |
|
30 * Base interface to manage observer notifications |
|
31 * and notify errors. Typical implementation will |
|
32 * forward notifications to actual type specific |
|
33 * mediator. |
|
34 * |
|
35 * |
|
36 * the observer array management from actual observer |
|
37 * type specific details. (Type specific details will |
|
38 * be implemented by the concrete mediator.) Usage |
|
39 * of mediator base interface allows geneic |
|
40 * observer array implementation. |
|
41 * |
|
42 * @since 2.1 |
|
43 */ |
|
44 |
|
45 NONSHARABLE_CLASS( MGenObserverNotifyMediatorBase ) |
|
46 { |
|
47 public: |
|
48 |
|
49 /** |
|
50 * Observer notification. |
|
51 * This member is internal and not intended for use. |
|
52 */ |
|
53 virtual void MediateNotifyL( TAny* aObserverToNotify, TAny* aNotifyData ) = 0; |
|
54 |
|
55 /** |
|
56 * Observer notification from error. |
|
57 * This member is internal and not intended for use. |
|
58 */ |
|
59 virtual void MediateNotifyError( TAny* aObserverToNotify, TInt aLeaveError ) = 0; |
|
60 |
|
61 |
|
62 /** |
|
63 * Observer notification from error. |
|
64 * This member is internal and not intended for use. |
|
65 */ |
|
66 virtual void MediateError( TAny* aObserverToNotify, TInt aError ) = 0; |
|
67 |
|
68 |
|
69 protected: |
|
70 |
|
71 /** |
|
72 * Protected destructor. |
|
73 */ |
|
74 virtual ~MGenObserverNotifyMediatorBase() {} |
|
75 }; |
|
76 |
|
77 |
|
78 |
|
79 |
|
80 // CLASS DECLARATION |
|
81 /** |
|
82 * Generic observer array. |
|
83 * |
|
84 * Generic observer array to manage observers |
|
85 * and notify them. Observers are managed as |
|
86 * typeless TAny pointers. Notification is done |
|
87 * trough generic MGenObserverNotifyMediatorBase |
|
88 * notify mediator. |
|
89 * |
|
90 * @since 2.1 |
|
91 */ |
|
92 NONSHARABLE_CLASS( RGenericObserverArrayBase ) : private RPointerArrayBase |
|
93 { |
|
94 protected: //protected members for derived classes |
|
95 |
|
96 /** |
|
97 * C++ constructor. |
|
98 * This member is internal and not intended for use. |
|
99 */ |
|
100 RGenericObserverArrayBase(); |
|
101 |
|
102 /** |
|
103 * Closes the array and frees all memory allocated to it. |
|
104 * This member is internal and not intended for use. |
|
105 */ |
|
106 void Close(); |
|
107 |
|
108 /** |
|
109 * Adds observer. |
|
110 * This member is internal and not intended for use. |
|
111 */ |
|
112 TInt AddObserver( const TAny* aObserver ); |
|
113 |
|
114 /** |
|
115 * Removes observer. |
|
116 * This member is internal and not intended for use. |
|
117 */ |
|
118 TInt RemoveObserver( const TAny* aObserver ); |
|
119 |
|
120 /** |
|
121 * Gets observer count. |
|
122 * This member is internal and not intended for use. |
|
123 */ |
|
124 TInt Count(); |
|
125 |
|
126 /** |
|
127 * Observer notify implementation. |
|
128 * This member is internal and not intended for use. |
|
129 */ |
|
130 void NotifyObservers( MGenObserverNotifyMediatorBase& aNotifyMediator, |
|
131 TAny* aNotifyData ); |
|
132 |
|
133 /** |
|
134 * Observer notify implementation. |
|
135 * This member is internal and not intended for use. |
|
136 */ |
|
137 void NotifyObserversFromError( MGenObserverNotifyMediatorBase& aNotifyMediator, |
|
138 TInt aError ); |
|
139 |
|
140 private: //private helpers |
|
141 |
|
142 /** |
|
143 * Private helper. |
|
144 * This member is internal and not intended for use. |
|
145 */ |
|
146 void FinalizeObsArrayAfterNotifyLoop(); |
|
147 |
|
148 |
|
149 private: //Data |
|
150 ///< Flag describing the observer array state, owned |
|
151 TBool iNotifyLoopRunning; |
|
152 }; |
|
153 |
|
154 #endif //__RGENERICOBSERVERARRAYBASE_H |
|
155 // End of File |
|
156 |
|
157 |