|
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: Inline methods for thin templated RGenericObserverArray |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // ================= HELPER CLASS ======================= |
|
21 /** |
|
22 * Helper inline class to forward requests |
|
23 * from base mediator (typeless) to type specific |
|
24 * mediator. |
|
25 * |
|
26 * @since 2.1 |
|
27 */ |
|
28 template <class T, class P> |
|
29 class TGenObserverNotifyMediatorBase : public MGenObserverNotifyMediatorBase |
|
30 { |
|
31 public: |
|
32 inline TGenObserverNotifyMediatorBase( MGenObserverNotifyMediator<T, P>& aSpecificMediator ) |
|
33 : iSpecificMediator( aSpecificMediator ){} |
|
34 |
|
35 private: |
|
36 inline void MediateNotifyL( TAny* aObserverToNotify, TAny* aNotifyData ) |
|
37 { iSpecificMediator.MediateNotifyL( *( static_cast<T*>( aObserverToNotify ) ), |
|
38 *( static_cast<P*>( aNotifyData ) ) ); } |
|
39 |
|
40 inline void MediateNotifyError( TAny* aObserverToNotify, TInt aLeaveError ) |
|
41 { iSpecificMediator.MediateNotifyError( *( static_cast<T*>( aObserverToNotify ) ), aLeaveError ); } |
|
42 |
|
43 inline void MediateError( TAny* aObserverToNotify, TInt aError ) |
|
44 { iSpecificMediator.MediateError( *( static_cast<T*>( aObserverToNotify ) ), aError ); } |
|
45 |
|
46 private: |
|
47 ///< Observer type specific notify mediator, not owned |
|
48 MGenObserverNotifyMediator<T, P>& iSpecificMediator; |
|
49 }; |
|
50 |
|
51 |
|
52 // ================= MEMBER FUNCTIONS ======================= |
|
53 // C++ default constructor can NOT contain any code, that |
|
54 // might leave. |
|
55 // |
|
56 template <class T, class P> |
|
57 inline RGenericObserverArray<T, P>::RGenericObserverArray() |
|
58 { |
|
59 } |
|
60 |
|
61 // ----------------------------------------------------------------------------- |
|
62 // RGenericObserverArray::Close() |
|
63 // ----------------------------------------------------------------------------- |
|
64 // |
|
65 template <class T, class P> |
|
66 inline void RGenericObserverArray<T, P>::Close() |
|
67 { |
|
68 RGenericObserverArrayBase::Close(); |
|
69 } |
|
70 |
|
71 |
|
72 // ----------------------------------------------------------------------------- |
|
73 // RGenericObserverArray::AddObserver() |
|
74 // ----------------------------------------------------------------------------- |
|
75 // |
|
76 template <class T, class P> |
|
77 inline TInt RGenericObserverArray<T, P>::AddObserver( const T* aObserver ) |
|
78 { |
|
79 return RGenericObserverArrayBase::AddObserver( static_cast<const TAny*>( aObserver ) ); |
|
80 } |
|
81 |
|
82 |
|
83 // ----------------------------------------------------------------------------- |
|
84 // RGenericObserverArray::AddObserverL() |
|
85 // ----------------------------------------------------------------------------- |
|
86 // |
|
87 template <class T, class P> |
|
88 inline void RGenericObserverArray<T, P>::AddObserverL( const T* aObserver ) |
|
89 { |
|
90 User::LeaveIfError( AddObserver( aObserver ) ); |
|
91 } |
|
92 |
|
93 |
|
94 // ----------------------------------------------------------------------------- |
|
95 // RGenericObserverArray::RemoveObserver() |
|
96 // ----------------------------------------------------------------------------- |
|
97 // |
|
98 template <class T, class P> |
|
99 inline TInt RGenericObserverArray<T, P>::RemoveObserver( T* aObserver ) |
|
100 { |
|
101 return RGenericObserverArrayBase::RemoveObserver( static_cast<TAny*>( aObserver ) ); |
|
102 } |
|
103 |
|
104 |
|
105 // ----------------------------------------------------------------------------- |
|
106 // RGenericObserverArray::Count() |
|
107 // ----------------------------------------------------------------------------- |
|
108 // |
|
109 template <class T, class P> |
|
110 inline TInt RGenericObserverArray<T, P>::Count() |
|
111 { |
|
112 return RGenericObserverArrayBase::Count(); |
|
113 } |
|
114 |
|
115 |
|
116 // ----------------------------------------------------------------------------- |
|
117 // RGenericObserverArray::NotifyObservers() |
|
118 // ----------------------------------------------------------------------------- |
|
119 // |
|
120 template <class T, class P> |
|
121 inline void RGenericObserverArray<T, P>::NotifyObservers( MGenObserverNotifyMediator<T, P>& aNotifyMediator, |
|
122 P& aNotifyData ) |
|
123 { |
|
124 TGenObserverNotifyMediatorBase<T, P> baseMediator( aNotifyMediator ); |
|
125 RGenericObserverArrayBase::NotifyObservers( baseMediator, |
|
126 static_cast<TAny*>( &aNotifyData) ); |
|
127 } |
|
128 |
|
129 |
|
130 // ----------------------------------------------------------------------------- |
|
131 // RGenericObserverArray::NotifyObserversFromError() |
|
132 // ----------------------------------------------------------------------------- |
|
133 // |
|
134 template <class T, class P> |
|
135 inline void RGenericObserverArray<T, P>::NotifyObserversFromError( MGenObserverNotifyMediator<T, P>& aNotifyMediator, |
|
136 TInt aError ) |
|
137 { |
|
138 TGenObserverNotifyMediatorBase<T, P> baseMediator( aNotifyMediator ); |
|
139 RGenericObserverArrayBase::NotifyObserversFromError( baseMediator, aError ); |
|
140 } |
|
141 |
|
142 // End of File |
|
143 |