|
1 /* |
|
2 * Copyright (c) 2007 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: Object pool for storing destinations and connection |
|
15 * methods. |
|
16 * |
|
17 */ |
|
18 |
|
19 #ifndef CMOBJECTPOOL_H |
|
20 #define CMOBJECTPOOL_H |
|
21 |
|
22 class CCmPluginBaseEng; |
|
23 class CCmPluginBase; |
|
24 class CCmManagerImpl; |
|
25 |
|
26 // User includes |
|
27 #include "cmdestinationimpl.h" |
|
28 #include <e32def.h> |
|
29 |
|
30 /** |
|
31 * Object pool to hold destination implementations and |
|
32 * connetion method implementations |
|
33 * |
|
34 * The get and remove functions must be used in pairs |
|
35 */ |
|
36 NONSHARABLE_CLASS( CCMObjectPool ) : public CBase |
|
37 { |
|
38 |
|
39 public: |
|
40 CCMObjectPool(CCmManagerImpl& aCmManagerImpl); |
|
41 virtual ~CCMObjectPool(); |
|
42 /** |
|
43 * If the destinaton impl is in the pool returns a pointer to it. |
|
44 * If the destinaton impl is not in the pool creates it. |
|
45 * |
|
46 * @param aDestinationId - ID of the destination requested |
|
47 * @return pointer to the destination - ownership passed |
|
48 */ |
|
49 CCmDestinationImpl* GetDestinationL( TUint32 aDestinationId ); |
|
50 /** |
|
51 * If the destinaton impl is in the pool returns a pointer to it. |
|
52 * If the destinaton impl is not in the pool creates it. |
|
53 * |
|
54 * @param aName - name of the destination requested |
|
55 * @return pointer to the destination - ownership passed |
|
56 */ |
|
57 CCmDestinationImpl* GetDestinationL( const TDesC& aName ); |
|
58 |
|
59 /** |
|
60 * Creates a destination if it does not exist. |
|
61 * |
|
62 * @param aName - name of the destination requested |
|
63 * @param aDestId - predefined id for the destination |
|
64 * @return pointer to the destination - ownership passed |
|
65 */ |
|
66 CCmDestinationImpl* CreateDestinationL( const TDesC& aName, TUint32 aDestId ); |
|
67 |
|
68 /** |
|
69 * Returns a pointer to an allready existing connecton method |
|
70 * |
|
71 * @param aCmId - ID of the CM requested |
|
72 * @param aParentDest - parent destination |
|
73 * @return plugin instance - ownership passed |
|
74 */ |
|
75 CCmPluginBase* GetConnectionMethodL( TUint32 aCmId, |
|
76 CCmDestinationImpl* aParentDest ); |
|
77 /** |
|
78 * Creates cm and places it into the pool. |
|
79 * |
|
80 * @param aImplementationUid - Bearer Type |
|
81 * @param aParams Init params for the plugin |
|
82 * @return plugin instance - ownership passed |
|
83 */ |
|
84 CCmPluginBase* CreateConnectionMethodL( TUint32 aImplementationUid, |
|
85 TCmPluginInitParam& aParams ); |
|
86 |
|
87 /** |
|
88 * Creates cm and places it into the pool. |
|
89 * |
|
90 * @param aImplementationUid - Bearer Type |
|
91 * @param aParams Init params for the plugin |
|
92 * @param aConnMethodId Predefined id for the connection method. |
|
93 * @return plugin instance - ownership passed |
|
94 */ |
|
95 CCmPluginBase* CreateConnectionMethodL( TUint32 aImplementationUid, |
|
96 TCmPluginInitParam& aParams, |
|
97 TUint32 aConnMethodId ); |
|
98 |
|
99 /** |
|
100 * Creates cm and places it into the pool. |
|
101 * |
|
102 * @param pluginBaseEng - Object to put in the pool |
|
103 * @return plugin instance - ownership passed |
|
104 */ |
|
105 CCmPluginBase* CreateConnectionMethodL( CCmPluginBaseEng* pluginBaseEng ); |
|
106 |
|
107 /** |
|
108 * Insert cm and places it into the pool. |
|
109 * API doesn't use CCmPluginBase. So, nothing returns |
|
110 * |
|
111 * @param pluginBaseEng - Object to put in the pool |
|
112 */ |
|
113 void InsertConnectionMethodL( CCmPluginBaseEng* pluginBaseEng ); |
|
114 |
|
115 /** |
|
116 * Removes a destination impl from the object pool. |
|
117 * |
|
118 * @param aDestination - the destination to remove |
|
119 */ |
|
120 void RemoveDestination( CCmDestinationImpl* aDestination ); |
|
121 |
|
122 /** |
|
123 * Removes a destination data from the object pool. |
|
124 * |
|
125 * @param aDestination - the destination to remove |
|
126 */ |
|
127 void RemoveDestination( CCmDestinationData* aDestination ); |
|
128 |
|
129 /** |
|
130 * Removes a connection method impl from the object pool. |
|
131 * |
|
132 * @param aDestinationId - ID of the connection method to remove |
|
133 */ |
|
134 void RemoveConnectionMethodL( CCmPluginBase* aCM ); |
|
135 |
|
136 /** |
|
137 * Removes a connection method impl from the object pool. |
|
138 * |
|
139 * @param aDestinationId - ID of the connection method to remove |
|
140 */ |
|
141 void RemoveConnectionMethodL( CCmPluginBaseEng* aCM ); |
|
142 |
|
143 /** |
|
144 * This is called after the new destination have been updated |
|
145 * This function updates the iDestinationId |
|
146 * field in the TObjectPoolDestinationItem |
|
147 * |
|
148 * @param aDestination - the destination to change |
|
149 */ |
|
150 void DestinationUpdated( CCmDestinationImpl* aDestination ); |
|
151 |
|
152 /** |
|
153 * This is called after the new cm have been updated |
|
154 * This function updates the Id |
|
155 * field |
|
156 * |
|
157 * @param aCM - the CM to change |
|
158 */ |
|
159 void ConnMethodUpdatedL( CCmPluginBaseEng* aCM ); |
|
160 |
|
161 private: |
|
162 class TObjectPoolDestinationItem |
|
163 { |
|
164 public: |
|
165 TObjectPoolDestinationItem( |
|
166 CCmDestinationData* aDestinationItem, |
|
167 TUint32 aDestinationId); |
|
168 TInt iDestinationId; |
|
169 CCmDestinationData* iDestinationItem; |
|
170 }; |
|
171 class TObjectPoolCMItem |
|
172 { |
|
173 public: |
|
174 TObjectPoolCMItem( |
|
175 CCmPluginBaseEng* iConnectionMethodItem, |
|
176 TUint32 iConnectionMethodId); |
|
177 TInt iConnectionMethodId; |
|
178 CCmPluginBaseEng* iConnectionMethodItem; |
|
179 }; |
|
180 private: |
|
181 CCmManagerImpl& iCmManagerImpl; |
|
182 // object pool for holding destination implementations |
|
183 RArray<TObjectPoolDestinationItem> iDestinationArray; |
|
184 // object pool for holding connetion method implementations |
|
185 RArray<TObjectPoolCMItem> iConnectionMethodArray; |
|
186 }; |
|
187 |
|
188 #endif // CMOBJECTPOOL_H |