|
1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // ss_cmetaextensioncontainer.h |
|
15 // |
|
16 |
|
17 /** |
|
18 @file |
|
19 @prototype |
|
20 @internalTechnology |
|
21 */ |
|
22 |
|
23 #ifndef SYMBIAN_SS_CMETAEXTENSIONCONTAINER |
|
24 #define SYMBIAN_SS_CMETAEXTENSIONCONTAINER |
|
25 |
|
26 #include <elements/metadata.h> |
|
27 |
|
28 #ifdef MEC_UNITTEST |
|
29 // If this file is being built for the unit test we use a simpler |
|
30 // base class that doesn't use the comms transport and async deletion. |
|
31 // Functionally CMecUnitTestRefCountOwnerBase is the same as CRefCountOwnerBase |
|
32 #include "mecunittestrefcountowner.h" |
|
33 |
|
34 class TMetaExtensionContainerSpy; |
|
35 |
|
36 #else |
|
37 // !MEC_UNITTEST |
|
38 #include <comms-infras/ss_nodemessages.h> |
|
39 |
|
40 #endif |
|
41 // MEC_UNITTEST |
|
42 |
|
43 namespace ESock |
|
44 { |
|
45 // Forward declarations - see <comms-infras/ss_rmetaextensioncontainer.h> |
|
46 class RMetaExtensionContainer; |
|
47 class RMetaExtensionContainerC; |
|
48 |
|
49 |
|
50 |
|
51 /** |
|
52 Base class for implementations of containers holding the meta extensions. |
|
53 The lifetime of itself and any extensions it owned by it are ref counted. |
|
54 Extensions owned by the CMetaExtensionContainerImplBase must have been |
|
55 created on the same heap as the container. |
|
56 @prototype |
|
57 @internalTechnology |
|
58 */ |
|
59 NONSHARABLE_CLASS(CMetaExtensionContainerImplBase) : public CRefCountOwnerBase |
|
60 { |
|
61 #ifdef MEC_UNITTEST |
|
62 friend class ::TMetaExtensionContainerSpy; |
|
63 #endif |
|
64 |
|
65 public: |
|
66 /** |
|
67 @prototype |
|
68 @internalTechnology |
|
69 */ |
|
70 enum TMetaExtensionContainerType |
|
71 { |
|
72 EMetaExtensionContainer, |
|
73 EMetaExtensionContainerArray, |
|
74 }; |
|
75 |
|
76 /** |
|
77 Finds the extension specified within the container |
|
78 @param aTypeId The STypeId of the meta extension to find |
|
79 @return A pointer to the meta extension or NULL if it wasn't found |
|
80 */ |
|
81 virtual const Meta::SMetaData* FindExtension(const Meta::STypeId& aTypeId) const = 0; |
|
82 |
|
83 /** |
|
84 Finds the extension specified within the container |
|
85 @param aTypeId The STypeId of the meta extension to find |
|
86 @return A reference to the meta extension |
|
87 @exception KErrNotFound is thrown if the meta extension was not present in the container |
|
88 */ |
|
89 const Meta::SMetaData& FindExtensionL(const Meta::STypeId& aTypeId) const; |
|
90 |
|
91 inline TMetaExtensionContainerType Type() const; |
|
92 |
|
93 protected: |
|
94 CMetaExtensionContainerImplBase(TMetaExtensionContainerType aType) |
|
95 : CRefCountOwnerBase(NULL), iType(aType) |
|
96 { |
|
97 Open(); // Open the first reference |
|
98 } |
|
99 |
|
100 virtual void DeletePtr(); |
|
101 |
|
102 ~CMetaExtensionContainerImplBase() |
|
103 { |
|
104 } |
|
105 |
|
106 private: |
|
107 TMetaExtensionContainerType iType; |
|
108 }; |
|
109 |
|
110 |
|
111 |
|
112 /** |
|
113 An implementation of an appendable container of meta extensions. This implementation can not |
|
114 be created and used directly. Use RMetaExtensionContainer instead. |
|
115 @prototype |
|
116 @internalTechnology |
|
117 */ |
|
118 NONSHARABLE_CLASS(CMetaExtensionContainer) : public CMetaExtensionContainerImplBase |
|
119 { |
|
120 friend class RMetaExtensionContainer; |
|
121 friend class RMetaExtensionContainerC; |
|
122 #ifdef MEC_UNITTEST |
|
123 friend class ::TMetaExtensionContainerSpy; |
|
124 #endif |
|
125 |
|
126 public: |
|
127 /** |
|
128 Finds the extension specified within the container |
|
129 @param aTypeId The STypeId of the meta extension to find |
|
130 @return A pointer to the meta extension or NULL if it wasn't found |
|
131 */ |
|
132 virtual const Meta::SMetaData* FindExtension(const Meta::STypeId& aTypeId) const; |
|
133 |
|
134 /** |
|
135 Adds a meta extension to the container, which will take ownership on success. |
|
136 @param aExtension The meta extension to add |
|
137 @return KErrAlreadyExists If a meta extension of the same type is in the container |
|
138 KErrNone If the meta extension was added successfully |
|
139 Other system-wide error codes |
|
140 */ |
|
141 TInt AppendExtension(const Meta::SMetaData* aExtension); |
|
142 |
|
143 /** |
|
144 Adds a meta extension to the container, which will take ownership on success. |
|
145 @param aExtension The meta extension to add |
|
146 @exception Leaves with KErrAlreadyExists If a meta extension of the same type is in the container, |
|
147 or other system-wide error codes |
|
148 */ |
|
149 void AppendExtensionL(const Meta::SMetaData* aExtension); |
|
150 |
|
151 /** |
|
152 Identifies obsolete containers in the chain and closes references to them |
|
153 */ |
|
154 void Compact(); |
|
155 |
|
156 protected: |
|
157 /** |
|
158 From CRefCountOwnerBase. Use to release any resources owned by the implementation. |
|
159 It is called just before the object is deleted. Always call the DeletePtr in the base |
|
160 class from your implementation. |
|
161 */ |
|
162 virtual void DeletePtr(); |
|
163 |
|
164 private: |
|
165 // Never deleted directly |
|
166 ~CMetaExtensionContainer(); |
|
167 CMetaExtensionContainer(); |
|
168 |
|
169 // Only RMetaExtensionContainer/RMetaExtensionContainerC may create this class |
|
170 static CMetaExtensionContainer* NewLC(const CMetaExtensionContainerImplBase* aBaseContainer); |
|
171 void ConstructL(const CMetaExtensionContainerImplBase* aBaseContainer); |
|
172 |
|
173 /** |
|
174 Retrieves the base meta extension container |
|
175 @return A pointer to the base meta extension container, or NULL if it is a root base container |
|
176 */ |
|
177 const CMetaExtensionContainerImplBase* BaseContainer() const; |
|
178 |
|
179 /** |
|
180 Sets the base container for branched meta extension containers |
|
181 Can only be set once and should be set during construction. |
|
182 The refcount on the base container will be incremented and owned by this CMetaExtensionContainerImplBase. |
|
183 @param aBaseContainer The base meta extension container |
|
184 */ |
|
185 void SetBaseContainer(const CMetaExtensionContainerImplBase* aBaseContainer); |
|
186 |
|
187 /** |
|
188 Remove the base container from the chain |
|
189 */ |
|
190 void RemoveBaseContainer(); |
|
191 |
|
192 /** |
|
193 Find the specified extension by searching only this container |
|
194 @param aTypeId The STypeId of the meta extension to find |
|
195 @return A pointer to the meta extension or NULL if it wasn't found |
|
196 */ |
|
197 const Meta::SMetaData* FindExtensionInThisContainer(const Meta::STypeId& aTypeId) const; |
|
198 |
|
199 private: |
|
200 const CMetaExtensionContainerImplBase* iBaseContainer; |
|
201 mutable RPointerArray<Meta::TMetaDataDeAllocator> iExtensions; |
|
202 }; |
|
203 |
|
204 |
|
205 |
|
206 /** |
|
207 An implementation of a container of meta extension containers. This implementation can not |
|
208 be created and used directly. RMetaExtensionContainer will create this implementation during |
|
209 a call to AppendContainerL. |
|
210 @prototype |
|
211 @internalTechnology |
|
212 */ |
|
213 NONSHARABLE_CLASS(CMetaExtensionContainerArray) : public CMetaExtensionContainerImplBase |
|
214 { |
|
215 friend class RMetaExtensionContainer; |
|
216 friend class RMetaExtensionContainerC; |
|
217 #ifdef MEC_UNITTEST |
|
218 friend class ::TMetaExtensionContainerSpy; |
|
219 #endif |
|
220 |
|
221 public: |
|
222 /** |
|
223 Finds the extension specified within the container |
|
224 @param aTypeId The STypeId of the meta extension to find |
|
225 @return A pointer to the meta extension or NULL if it wasn't found |
|
226 */ |
|
227 virtual const Meta::SMetaData* FindExtension(const Meta::STypeId& aTypeId) const; |
|
228 |
|
229 /** |
|
230 Appends a container to the list of container implementations. |
|
231 @aBaseContainer Appends an existing container. Extensions in aBaseContainer container will override |
|
232 any extensions of the same type already present in the container this method is called on. |
|
233 @return KErrNone on success |
|
234 KErrAlreadyExists if the container is already in the array |
|
235 or any other system-wide error code. |
|
236 */ |
|
237 TInt AppendContainer(const CMetaExtensionContainerImplBase& aContainer); |
|
238 |
|
239 protected: |
|
240 /** |
|
241 From CRefCountOwnerBase. Use to release any resources owned by the implementation. |
|
242 It is called just before the object is deleted. Always call the DeletePtr in the base |
|
243 class from your implementation. |
|
244 */ |
|
245 virtual void DeletePtr(); |
|
246 |
|
247 private: |
|
248 // Never deleted directly |
|
249 ~CMetaExtensionContainerArray(); |
|
250 CMetaExtensionContainerArray(); |
|
251 |
|
252 // Only RMetaExtensionContainer/RMetaExtensionContainerC may create this class |
|
253 static CMetaExtensionContainerArray* NewLC(const CMetaExtensionContainerImplBase* aBaseContainer); |
|
254 void ConstructL(const CMetaExtensionContainerImplBase* aBaseContainer); |
|
255 |
|
256 private: |
|
257 mutable RPointerArray<CMetaExtensionContainerImplBase> iContainers; |
|
258 }; |
|
259 |
|
260 |
|
261 |
|
262 inline CMetaExtensionContainerImplBase::TMetaExtensionContainerType CMetaExtensionContainerImplBase::Type() const |
|
263 { |
|
264 return iType; |
|
265 } |
|
266 |
|
267 } // namespace ESock |
|
268 |
|
269 |
|
270 #endif |
|
271 // SYMBIAN_SS_CMETAEXTENSIONCONTAINER |
|
272 |