williamr@2
|
1 |
/// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
|
williamr@2
|
2 |
/// All rights reserved.
|
williamr@2
|
3 |
/// This component and the accompanying materials are made available
|
williamr@2
|
4 |
/// under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
|
williamr@2
|
5 |
/// which accompanies this distribution, and is available
|
williamr@2
|
6 |
/// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
|
williamr@2
|
7 |
///
|
williamr@2
|
8 |
/// Initial Contributors:
|
williamr@2
|
9 |
/// Nokia Corporation - initial contribution.
|
williamr@2
|
10 |
///
|
williamr@2
|
11 |
/// Contributors:
|
williamr@2
|
12 |
///
|
williamr@2
|
13 |
/// Description:
|
williamr@2
|
14 |
/// All rights reserved.
|
williamr@2
|
15 |
/// This component and the accompanying materials are made available
|
williamr@2
|
16 |
/// under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
|
williamr@2
|
17 |
/// which accompanies this distribution, and is available
|
williamr@2
|
18 |
/// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
|
williamr@2
|
19 |
/// Initial Contributors:
|
williamr@2
|
20 |
/// Nokia Corporation - initial contribution.
|
williamr@2
|
21 |
/// Contributors:
|
williamr@2
|
22 |
/// This contains the definitions of CDataDelete, CDataNoDelete, CIntAttribute, CNode, and CTypedNode.
|
williamr@2
|
23 |
/// CDataNoDelete is a base class to CDataDelete and are essentially a wrapper around an HBufC16.
|
williamr@2
|
24 |
/// The node owns the data that is added to it and therefore is responsible for deleting all its data,
|
williamr@2
|
25 |
/// hence theses two classes allow a user to have non deletable data. Internally to the node it is also
|
williamr@2
|
26 |
/// sometimes necessary to change the data into either deletable or non-deletable data api's are provided
|
williamr@2
|
27 |
/// for this.
|
williamr@2
|
28 |
/// CIntAttribute is wrapper around a TInt, this is provided as the nodes attribute value is a CBase* however
|
williamr@2
|
29 |
/// it might be desirable to store integer's in here. Attribute value is owned by the node therefore the node is
|
williamr@2
|
30 |
/// responsible for deleting it.
|
williamr@2
|
31 |
/// CNode is the basis for constructing a tree. It consists of an array of child nodes, node type, a parent node,
|
williamr@2
|
32 |
/// an array of attributes, and a data member. Internally the data member is defined as CDataNoDelete however
|
williamr@2
|
33 |
/// to the user all the exported api's take an HBufC16*. Data is owned by the node and is destroyed by the node,
|
williamr@2
|
34 |
/// However in certain circumstances this is not desirable hence the api's to make the data non-deletable. The
|
williamr@2
|
35 |
/// node type is defined as a TAny* however normal usage would use the templated node - CTypedNode. The node type
|
williamr@2
|
36 |
/// is used to identify groups of nodes. The attribute array is fairy simple and consists of AttributeType and
|
williamr@2
|
37 |
/// AttributeValue. AttributeType can be defined by using the templated class and should be a 32bit value. AttributeValue
|
williamr@2
|
38 |
/// can be any object derived from CBase and the node takes ownership therefore the node delete's it.
|
williamr@2
|
39 |
/// Basic usage should be to use the templated class in order to make use of the templated types (TNodeType,TAttributeType).
|
williamr@2
|
40 |
/// Create a node for example:
|
williamr@2
|
41 |
/// CTypedNode<CNode*, const TDesC*> *tree = CTypedNode<CNode*, const TDesC*>::NewL(0,0);
|
williamr@2
|
42 |
/// add a new child:
|
williamr@2
|
43 |
/// CNODE *TestChildNode1 = tree->AppendNodeL(aTempNodeForNodeType);
|
williamr@2
|
44 |
/// add some data:
|
williamr@2
|
45 |
/// TestChildNode1->SetDataL(aHBufC16);
|
williamr@2
|
46 |
/// add an attribute:
|
williamr@2
|
47 |
/// TestChildNode1->->AddAttributeL(aTAttributeType,aCBasePointerAttributeValue);
|
williamr@2
|
48 |
/// Explanation of individual api's is documented below.
|
williamr@2
|
49 |
///
|
williamr@2
|
50 |
|
williamr@2
|
51 |
|
williamr@2
|
52 |
|
williamr@2
|
53 |
|
williamr@2
|
54 |
#ifndef __CNODE_H__
|
williamr@2
|
55 |
#define __CNODE_H__
|
williamr@2
|
56 |
|
williamr@2
|
57 |
#include <e32base.h>
|
williamr@2
|
58 |
#include <f32file.h>
|
williamr@2
|
59 |
|
williamr@2
|
60 |
|
williamr@2
|
61 |
/**
|
williamr@2
|
62 |
@file
|
williamr@2
|
63 |
@publishedAll
|
williamr@2
|
64 |
@released
|
williamr@2
|
65 |
*/
|
williamr@2
|
66 |
|
williamr@2
|
67 |
//Granularity of arrays
|
williamr@2
|
68 |
const TInt KGranularity = 5;
|
williamr@2
|
69 |
|
williamr@2
|
70 |
//enum of panic reasons
|
williamr@2
|
71 |
enum TNodePanic
|
williamr@2
|
72 |
{
|
williamr@2
|
73 |
ENodeBadArgument,
|
williamr@2
|
74 |
ENodeNoChildren,
|
williamr@2
|
75 |
ENoData,
|
williamr@2
|
76 |
EAttributeFailure
|
williamr@2
|
77 |
};
|
williamr@2
|
78 |
|
williamr@2
|
79 |
//node panic function
|
williamr@2
|
80 |
inline void Panic(TNodePanic aPanic);
|
williamr@2
|
81 |
|
williamr@2
|
82 |
//Wrapper around an HBufC16 doesn't delete data
|
williamr@2
|
83 |
//##ModelId=3B666BCC0303
|
williamr@2
|
84 |
class CDataNoDelete : public CBase
|
williamr@2
|
85 |
/** Provides a wrapper around an HBufC16: the buffer is not deleted when the object is deleted.
|
williamr@2
|
86 |
*/
|
williamr@2
|
87 |
{
|
williamr@2
|
88 |
public:
|
williamr@2
|
89 |
//##ModelId=3B666BCC032D
|
williamr@2
|
90 |
CDataNoDelete(HBufC16* aData);
|
williamr@2
|
91 |
//##ModelId=3B666BCC032C
|
williamr@2
|
92 |
virtual ~CDataNoDelete();
|
williamr@2
|
93 |
//##ModelId=3B666BCC0324
|
williamr@2
|
94 |
HBufC16* SetData(HBufC16* aData);
|
williamr@2
|
95 |
//##ModelId=3B666BCC0322
|
williamr@2
|
96 |
virtual void ResetDataPointer(HBufC16* aData);
|
williamr@2
|
97 |
//##ModelId=3B666BCC0321
|
williamr@2
|
98 |
HBufC16* Data();
|
williamr@2
|
99 |
|
williamr@2
|
100 |
protected:
|
williamr@2
|
101 |
/** The wrapped buffer. */
|
williamr@2
|
102 |
//##ModelId=3B666BCC0319
|
williamr@2
|
103 |
HBufC16* iData;
|
williamr@2
|
104 |
};
|
williamr@2
|
105 |
|
williamr@2
|
106 |
//Wrapper around an HBufC16 does delete data
|
williamr@2
|
107 |
//##ModelId=3B666BCC0399
|
williamr@2
|
108 |
class CDataDelete : public CDataNoDelete
|
williamr@2
|
109 |
/** Provides a wrapper around an HBufC16: the buffer is deleted when the
|
williamr@2
|
110 |
object is deleted.
|
williamr@2
|
111 |
*/
|
williamr@2
|
112 |
{
|
williamr@2
|
113 |
public:
|
williamr@2
|
114 |
//##ModelId=3B666BCC03B7
|
williamr@2
|
115 |
CDataDelete(HBufC16* aData);
|
williamr@2
|
116 |
//##ModelId=3B666BCC03B0
|
williamr@2
|
117 |
virtual ~CDataDelete();
|
williamr@2
|
118 |
//##ModelId=3B666BCC03AE
|
williamr@2
|
119 |
virtual void ResetDataPointer(HBufC16* aData);
|
williamr@2
|
120 |
};
|
williamr@2
|
121 |
|
williamr@2
|
122 |
//Wrapper around an HBufC16 does delete data (FileName)
|
williamr@2
|
123 |
// After Removing referenced File
|
williamr@2
|
124 |
//##ModelId=3B666BC7026F
|
williamr@2
|
125 |
class CFileDataDelete : public CDataNoDelete
|
williamr@2
|
126 |
/** Provides a wrapper around a filename: the referenced file is deleted when the object is deleted.
|
williamr@2
|
127 |
*/
|
williamr@2
|
128 |
{
|
williamr@2
|
129 |
public:
|
williamr@2
|
130 |
//##ModelId=3B666BC7028F
|
williamr@2
|
131 |
CFileDataDelete(HBufC16* aData);
|
williamr@2
|
132 |
//##ModelId=3B666BC7028E
|
williamr@2
|
133 |
virtual ~CFileDataDelete();
|
williamr@2
|
134 |
//##ModelId=3B666BC70285
|
williamr@2
|
135 |
virtual void ResetDataPointer(HBufC16* aData);
|
williamr@2
|
136 |
private:
|
williamr@2
|
137 |
//##ModelId=3B666BC70284
|
williamr@2
|
138 |
void RemoveFile();
|
williamr@2
|
139 |
};
|
williamr@2
|
140 |
|
williamr@2
|
141 |
//Wrapper around a TInt used for attribute values in order to allow the node to call a dtor
|
williamr@2
|
142 |
//##ModelId=3B666BC6023E
|
williamr@2
|
143 |
class CIntAttribute : public CBase
|
williamr@2
|
144 |
/** Provides an object wrapper around a TInt value. */
|
williamr@2
|
145 |
{
|
williamr@2
|
146 |
public:
|
williamr@2
|
147 |
//##ModelId=3B666BC6025B
|
williamr@2
|
148 |
inline CIntAttribute(TInt aInteger);
|
williamr@2
|
149 |
//##ModelId=3B666BC6025A
|
williamr@2
|
150 |
inline TInt Int() const;
|
williamr@2
|
151 |
private:
|
williamr@2
|
152 |
//##ModelId=3B666BC60264
|
williamr@2
|
153 |
CIntAttribute();
|
williamr@2
|
154 |
//##ModelId=3B666BC60253
|
williamr@2
|
155 |
TInt iInteger;
|
williamr@2
|
156 |
};
|
williamr@2
|
157 |
|
williamr@2
|
158 |
//
|
williamr@2
|
159 |
// Node class
|
williamr@2
|
160 |
// Normal usage would be to use CTypedNode in order to use specific templated types
|
williamr@2
|
161 |
//
|
williamr@2
|
162 |
|
williamr@2
|
163 |
//##ModelId=3B666BCD02D2
|
williamr@2
|
164 |
class CNode : public CBase
|
williamr@2
|
165 |
{
|
williamr@2
|
166 |
public:
|
williamr@2
|
167 |
//##ModelId=3B666BCE0139
|
williamr@2
|
168 |
IMPORT_C ~CNode();
|
williamr@2
|
169 |
|
williamr@2
|
170 |
//NewL parameters aType to indentify the type of node, CNode* to set the parent of this node
|
williamr@2
|
171 |
//##ModelId=3B666BCE0125
|
williamr@2
|
172 |
IMPORT_C static CNode* NewL(TAny* aType,CNode* aParent);
|
williamr@2
|
173 |
|
williamr@2
|
174 |
//Deletes a child node which is passed in as a parameter
|
williamr@2
|
175 |
//##ModelId=3B666BCE011C
|
williamr@2
|
176 |
IMPORT_C void DeleteChildNode(CNode* aNode);
|
williamr@2
|
177 |
|
williamr@2
|
178 |
//Deletes all the child nodes haging of this node
|
williamr@2
|
179 |
//##ModelId=3B666BCE011B
|
williamr@2
|
180 |
IMPORT_C void DeleteAllChildNodes();
|
williamr@2
|
181 |
|
williamr@2
|
182 |
//Creates a new node and adds it to the childlist, reference to new node is returned. Can leave if it can't allocate memory for a new node
|
williamr@2
|
183 |
//Type of node is the parameter
|
williamr@2
|
184 |
//##ModelId=3B666BCE0108
|
williamr@2
|
185 |
IMPORT_C CNode& AppendNodeL(TAny* aType = 0);
|
williamr@2
|
186 |
|
williamr@2
|
187 |
//Appends a node which is passed in as a parameter to this node, so its added to the childlist
|
williamr@2
|
188 |
//##ModelId=3B666BCE00FD
|
williamr@2
|
189 |
IMPORT_C void AppendNodeToThisNodeL(CNode* aNode);
|
williamr@2
|
190 |
|
williamr@2
|
191 |
//Sets the data in the node to the parameter that is passed in. It's deletable and the node will delete it in dtor
|
williamr@2
|
192 |
//Push aDataNowNodeOwns onto the CleanupStack before calling then pop off on return
|
williamr@2
|
193 |
//##ModelId=3B666BCE00F3
|
williamr@2
|
194 |
IMPORT_C void SetDataL(HBufC16* aDataNowNodeOwns);
|
williamr@2
|
195 |
|
williamr@2
|
196 |
//returns the data stored in the node, which is returned as an HBufC16*
|
williamr@2
|
197 |
//##ModelId=3B666BCE00EB
|
williamr@2
|
198 |
IMPORT_C HBufC16* Data() const;
|
williamr@2
|
199 |
|
williamr@2
|
200 |
//WARNING this function can leave as it deletes the wrapper object and then creates
|
williamr@2
|
201 |
//a new non deletable wrapper object and sets the data pointer inside the new object
|
williamr@2
|
202 |
//IF THIS LEAVES YOU WILL LOSE YOUR DATA
|
williamr@2
|
203 |
//##ModelId=3B666BCE00EA
|
williamr@2
|
204 |
IMPORT_C void SetDataNoDeleteL();
|
williamr@2
|
205 |
|
williamr@2
|
206 |
//WARNING this function can leave as it deletes the wrapper object and then creates
|
williamr@2
|
207 |
//a new deletable wrapper object then sets the pointer in the new object
|
williamr@2
|
208 |
//##ModelId=3B666BCE00E9
|
williamr@2
|
209 |
IMPORT_C void ClearSetDataNoDeleteL();
|
williamr@2
|
210 |
|
williamr@2
|
211 |
// Sets the data in the node to the FileName parameter that is passed in.
|
williamr@2
|
212 |
// It's deletable and the node will delete it, and the file it refers to in dtor
|
williamr@2
|
213 |
// Push aDataLocationNowNodeOwns onto the CleanupStack before calling then pop off on return
|
williamr@2
|
214 |
//##ModelId=3B666BCE00DF
|
williamr@2
|
215 |
IMPORT_C void SetFileDataL(HBufC16* aFileDataLocationNowNodeOwns);
|
williamr@2
|
216 |
|
williamr@2
|
217 |
//Resets the data pointer to point to aData parameter will delete the data that is owned by the node
|
williamr@2
|
218 |
//##ModelId=3B666BCE00D5
|
williamr@2
|
219 |
IMPORT_C void ResetDataPointer(HBufC16* aData);
|
williamr@2
|
220 |
|
williamr@2
|
221 |
//returns a reference to the absolute root of the tree
|
williamr@2
|
222 |
//##ModelId=3B666BCE00CB
|
williamr@2
|
223 |
IMPORT_C const CNode& Root() const;
|
williamr@2
|
224 |
|
williamr@2
|
225 |
//returns a child node which is stored in the array of children. The child node is accessed by the index that is the parameter.
|
williamr@2
|
226 |
//##ModelId=3B666BCE00C1
|
williamr@2
|
227 |
IMPORT_C CNode* Child(TInt aByIndex) const;
|
williamr@2
|
228 |
|
williamr@2
|
229 |
//Returns either the first child of this node if the parameter is NULL. Or it returns the next chld in the array after
|
williamr@2
|
230 |
//the child passed in as a parameter
|
williamr@2
|
231 |
//##ModelId=3B666BCE00AE
|
williamr@2
|
232 |
IMPORT_C CNode* NextChild(const CNode* aNode = NULL) const;
|
williamr@2
|
233 |
|
williamr@2
|
234 |
//returns the previous child to the child passed in as a parameter. The node parameter is a reference because its the child previous
|
williamr@2
|
235 |
//to the node passed in which obviously must exist
|
williamr@2
|
236 |
//##ModelId=3B666BCE00A4
|
williamr@2
|
237 |
IMPORT_C CNode* PrevChild(const CNode& aNode) const;
|
williamr@2
|
238 |
|
williamr@2
|
239 |
//Returns the parent of this node
|
williamr@2
|
240 |
//##ModelId=3B666BCE00A3
|
williamr@2
|
241 |
IMPORT_C CNode* Parent() const;
|
williamr@2
|
242 |
|
williamr@2
|
243 |
//WARNING this function can leave as it calls AppendNodeToThisNode. The aParent parameter is the node to which you would like to make
|
williamr@2
|
244 |
//the parent of 'this' node.
|
williamr@2
|
245 |
//It removes itself from the childlist of it's current parent
|
williamr@2
|
246 |
//##ModelId=3B666BCE0099
|
williamr@2
|
247 |
IMPORT_C void ReparentL(CNode* aParent);
|
williamr@2
|
248 |
|
williamr@2
|
249 |
//Returns the next sibling which means in effect that it asks for the next child of its parent.
|
williamr@2
|
250 |
//Sibling means brother or sister.
|
williamr@2
|
251 |
//##ModelId=3B666BCE0090
|
williamr@2
|
252 |
IMPORT_C CNode* NextSibling() const;
|
williamr@2
|
253 |
|
williamr@2
|
254 |
//Returns the previous sibling which means in effect that it asks for the previous child of its parent.
|
williamr@2
|
255 |
//Sibling means brother or sister.
|
williamr@2
|
256 |
//##ModelId=3B666BCE008F
|
williamr@2
|
257 |
IMPORT_C CNode* PrevSibling() const;
|
williamr@2
|
258 |
|
williamr@2
|
259 |
//returns the number of children that this node has
|
williamr@2
|
260 |
//##ModelId=3B666BCE0085
|
williamr@2
|
261 |
IMPORT_C TInt NumberImmediateChildren() const;
|
williamr@2
|
262 |
|
williamr@2
|
263 |
//Deletes the attribute of which is of aAttributeType (the parameter)
|
williamr@2
|
264 |
//WARNING Attribute values of nodes will be deleted as the node owns them if you don't want it deleted then use a wrapper
|
williamr@2
|
265 |
//##ModelId=3B666BCE007C
|
williamr@2
|
266 |
IMPORT_C void DeleteAttribute(TAny* aAttributeType);
|
williamr@2
|
267 |
|
williamr@2
|
268 |
//Deletes all the attributes of this node
|
williamr@2
|
269 |
//WARNING Attribute values of nodes will be deleted as the node owns them if you don't want it deleted then use a wrapper
|
williamr@2
|
270 |
//##ModelId=3B666BCE007B
|
williamr@2
|
271 |
IMPORT_C void DeleteAllAttributes();
|
williamr@2
|
272 |
|
williamr@2
|
273 |
//remove an attribute without deleting it, this is done by simply setting the attributeValue pointer to NULL
|
williamr@2
|
274 |
//WARNING you are now responsiblefor the destruction of this attribute value
|
williamr@2
|
275 |
//##ModelId=3B666BCE0071
|
williamr@2
|
276 |
IMPORT_C void RemoveAttributeNoDelete(TAny* aAttributeType);
|
williamr@2
|
277 |
|
williamr@2
|
278 |
// Returns the number of attributes that this node has
|
williamr@2
|
279 |
//##ModelId=3B666BCE0067
|
williamr@2
|
280 |
IMPORT_C TInt AttributeCount() const;
|
williamr@2
|
281 |
|
williamr@2
|
282 |
//Returns the type of attribute (AttributeType) at a given index...NOT the attributeValue
|
williamr@2
|
283 |
//##ModelId=3B666BCE005D
|
williamr@2
|
284 |
IMPORT_C TAny* AttributeTypeByIndex(TInt aIndex) const;
|
williamr@2
|
285 |
|
williamr@2
|
286 |
//Returns the value of an attribute (AttributeValue) at a given index...NOT the attributeType
|
williamr@2
|
287 |
//##ModelId=3B666BCE003F
|
williamr@2
|
288 |
IMPORT_C CBase* AttributeByIndex(TInt aIndex) const;
|
williamr@2
|
289 |
//##ModelId=3B666BCE0049
|
williamr@2
|
290 |
IMPORT_C CBase* AttributeByIndex(TInt aIndex,TAny*& aType) const;
|
williamr@2
|
291 |
|
williamr@2
|
292 |
//Adds an attribute, parameters are the type of attribute and its value
|
williamr@2
|
293 |
//WARNING node takes ownership of aAttributeValue
|
williamr@2
|
294 |
////Push aAttributeValue onto the CleanupStack before calling then pop off on return
|
williamr@2
|
295 |
//##ModelId=3B666BCE002B
|
williamr@2
|
296 |
IMPORT_C void AddAttributeL(TAny* AttributeType, CBase* aAttributeValue);
|
williamr@2
|
297 |
|
williamr@2
|
298 |
//Adds data to the node and also adds an attribute, parameters are the Data to be added, the type of attribute and its value
|
williamr@2
|
299 |
//WARNING node takes ownership of aData and aAttributeValue
|
williamr@2
|
300 |
////Push aAttributeValue and aData onto the CleanupStack before calling then pop off on return
|
williamr@2
|
301 |
//##ModelId=3B666BCE000D
|
williamr@2
|
302 |
IMPORT_C void AddDataAndAttributeL(HBufC16 *aData, TAny* AttributeType, CBase* aAttributeValue);
|
williamr@2
|
303 |
|
williamr@2
|
304 |
//Returns an attribute value for the given AttributeType(the parameter)
|
williamr@2
|
305 |
//##ModelId=3B666BCE0003
|
williamr@2
|
306 |
IMPORT_C CBase* Attribute(TAny* AttributeType) const;
|
williamr@2
|
307 |
|
williamr@2
|
308 |
//Returns TRUE if the attribute of the given type exists
|
williamr@2
|
309 |
//##ModelId=3B666BCD03E1
|
williamr@2
|
310 |
IMPORT_C TBool AttributeExists(TAny* aAttributeType) const;
|
williamr@2
|
311 |
|
williamr@2
|
312 |
//Returns the node type
|
williamr@2
|
313 |
//##ModelId=3B666BCD03D7
|
williamr@2
|
314 |
IMPORT_C TAny* Type() const;
|
williamr@2
|
315 |
|
williamr@2
|
316 |
//Sets the node type to be aType (the parameter)
|
williamr@2
|
317 |
//##ModelId=3B666BCD03CD
|
williamr@2
|
318 |
IMPORT_C void SetType(TAny* aType);
|
williamr@2
|
319 |
|
williamr@2
|
320 |
|
williamr@2
|
321 |
protected:
|
williamr@2
|
322 |
//ctor
|
williamr@2
|
323 |
//##ModelId=3B666BCD03B9
|
williamr@2
|
324 |
CNode(TAny* aType, CNode* aParent);
|
williamr@2
|
325 |
|
williamr@2
|
326 |
//internal finds a child which is passed in as a parameter
|
williamr@2
|
327 |
//##ModelId=3B666BCD03AF
|
williamr@2
|
328 |
TInt FindChild(const CNode* aNode) const;
|
williamr@2
|
329 |
|
williamr@2
|
330 |
//##ModelId=3B666BCD03A7
|
williamr@2
|
331 |
HBufC16* SetupDeletableOrNonDeleteableDataLC();
|
williamr@2
|
332 |
//##ModelId=3B666BCD03A6
|
williamr@2
|
333 |
void AdjustBasePointers();
|
williamr@2
|
334 |
private:
|
williamr@2
|
335 |
// Reserved for future expansion
|
williamr@2
|
336 |
//##ModelId=3B666BCD039B
|
williamr@2
|
337 |
virtual void Reserved1();
|
williamr@2
|
338 |
//##ModelId=3B666BCD03A5
|
williamr@2
|
339 |
virtual void Reserved1() const;
|
williamr@2
|
340 |
|
williamr@2
|
341 |
protected:
|
williamr@2
|
342 |
//the Type of Node
|
williamr@2
|
343 |
//##ModelId=3B666BCD0392
|
williamr@2
|
344 |
TAny* iType;
|
williamr@2
|
345 |
|
williamr@2
|
346 |
//This Nodes parent
|
williamr@2
|
347 |
//##ModelId=3B666BCD037E
|
williamr@2
|
348 |
CNode *iParent;
|
williamr@2
|
349 |
|
williamr@2
|
350 |
// stores attribute type and value. iTypes must be Flat array
|
williamr@2
|
351 |
//##ModelId=3B666BCD0372
|
williamr@2
|
352 |
CArrayPtrFlat<CBase> iValues;
|
williamr@2
|
353 |
//##ModelId=3B666BCD034C
|
williamr@2
|
354 |
CArrayPtrFlat<TAny> iTypes;
|
williamr@2
|
355 |
|
williamr@2
|
356 |
//##ModelId=3B666BCD0324
|
williamr@2
|
357 |
TInt32* iTypesBasePtr;
|
williamr@2
|
358 |
//##ModelId=3B666BCD0310
|
williamr@2
|
359 |
CDataNoDelete* iDataValue;
|
williamr@2
|
360 |
//
|
williamr@2
|
361 |
//An array of child nodes
|
williamr@2
|
362 |
//##ModelId=3B666BCD02FC
|
williamr@2
|
363 |
CArrayPtr<CNode> *iChildList;
|
williamr@2
|
364 |
private:
|
williamr@2
|
365 |
//##ModelId=3B666BCD02DF
|
williamr@2
|
366 |
TAny* iReserved; // Reserved for future expansion
|
williamr@2
|
367 |
};
|
williamr@2
|
368 |
|
williamr@2
|
369 |
|
williamr@2
|
370 |
//CTypedNode is derived from CNode and is a thin template. TNodeType you should define as a 32 bit value
|
williamr@2
|
371 |
//TAttributeType should be defined as a 32 bit value
|
williamr@2
|
372 |
//FOR EXPLANATION OF API'S SEE ABOVE
|
williamr@2
|
373 |
//##ModelId=3B666BCC01A4
|
williamr@2
|
374 |
template <class TNodeType, class TAttributeType>
|
williamr@2
|
375 |
class CTypedNode : public CNode
|
williamr@2
|
376 |
/** Template class for a node in a node tree.
|
williamr@2
|
377 |
|
williamr@2
|
378 |
The node type is set to the template parameter TNodeType and the attribute type to
|
williamr@2
|
379 |
TAttributeType. These parameters should be pointers to the type required to store
|
williamr@2
|
380 |
the type value: e.g. for a string, a const TDesC*.
|
williamr@2
|
381 |
|
williamr@2
|
382 |
The class is thin template over CNode. */
|
williamr@2
|
383 |
{
|
williamr@2
|
384 |
public:
|
williamr@2
|
385 |
//##ModelId=3B666BCC024A
|
williamr@2
|
386 |
inline static CTypedNode* NewL(TNodeType aType,CNode* aParent);
|
williamr@2
|
387 |
//##ModelId=3B666BCC0248
|
williamr@2
|
388 |
inline void DeleteChildNode(CNode* aNode);
|
williamr@2
|
389 |
//##ModelId=3B666BCC0247
|
williamr@2
|
390 |
inline void DeleteAllChildNodes();
|
williamr@2
|
391 |
//##ModelId=3B666BCC0245
|
williamr@2
|
392 |
inline CTypedNode<TNodeType,TAttributeType>& AppendNodeL(TNodeType aType);
|
williamr@2
|
393 |
//##ModelId=3B666BCC023B
|
williamr@2
|
394 |
inline void AppendNodeToThisNodeL(CNode* aNode);
|
williamr@2
|
395 |
//##ModelId=3B666BCC0228
|
williamr@2
|
396 |
inline void SetDataL(HBufC16* aDataNowNodeOwns);
|
williamr@2
|
397 |
//##ModelId=3B666BCC0227
|
williamr@2
|
398 |
inline void SetDataNoDeleteL();
|
williamr@2
|
399 |
//##ModelId=3B666BCC0221
|
williamr@2
|
400 |
inline void ClearSetDataNoDeleteL();
|
williamr@2
|
401 |
//##ModelId=3B666BCC021F
|
williamr@2
|
402 |
inline void SetFileDataL(HBufC16* aFileDataLocationNowNodeOwns);
|
williamr@2
|
403 |
//##ModelId=3B666BCC021D
|
williamr@2
|
404 |
inline void ResetDataPointer(HBufC16* aData);
|
williamr@2
|
405 |
//##ModelId=3B666BCC0215
|
williamr@2
|
406 |
inline HBufC16* Data() const;
|
williamr@2
|
407 |
//##ModelId=3B666BCC0214
|
williamr@2
|
408 |
inline const CTypedNode& Root() const;
|
williamr@2
|
409 |
//##ModelId=3B666BCC020B
|
williamr@2
|
410 |
inline CTypedNode* Child(TInt aByIndex) const;
|
williamr@2
|
411 |
//##ModelId=3B666BCC0209
|
williamr@2
|
412 |
inline CTypedNode* NextChild(const CNode* aNode = NULL) const;
|
williamr@2
|
413 |
//##ModelId=3B666BCC0201
|
williamr@2
|
414 |
inline CTypedNode* PrevChild( const CNode& aNode) const;
|
williamr@2
|
415 |
//##ModelId=3B666BCC0200
|
williamr@2
|
416 |
inline CTypedNode* Parent() const;
|
williamr@2
|
417 |
//##ModelId=3B666BCC01FE
|
williamr@2
|
418 |
inline void ReparentL(CNode* aParent);
|
williamr@2
|
419 |
//##ModelId=3B666BCC01F5
|
williamr@2
|
420 |
inline CTypedNode* NextSibling() const;
|
williamr@2
|
421 |
//##ModelId=3B666BCC01F4
|
williamr@2
|
422 |
inline CTypedNode* PrevSibling() const;
|
williamr@2
|
423 |
//##ModelId=3B666BCC01EE
|
williamr@2
|
424 |
inline TInt NumberImmediateChildren() const;
|
williamr@2
|
425 |
//##ModelId=3B666BCC01EC
|
williamr@2
|
426 |
inline void DeleteAttribute(TAttributeType aAttributeType);
|
williamr@2
|
427 |
//##ModelId=3B666BCC01EB
|
williamr@2
|
428 |
inline void DeleteAllAttributes();
|
williamr@2
|
429 |
//##ModelId=3B666BCC01E5
|
williamr@2
|
430 |
inline void RemoveAttributeNoDelete(TAttributeType aAttributeType);
|
williamr@2
|
431 |
//##ModelId=3B666BCC01E4
|
williamr@2
|
432 |
inline TInt AttributeCount() const; // Returns the number of attributes
|
williamr@2
|
433 |
//##ModelId=3B666BCC01E2
|
williamr@2
|
434 |
inline TAttributeType AttributeTypeByIndex(TInt aIndex) const;
|
williamr@2
|
435 |
//##ModelId=3B666BCC01DC
|
williamr@2
|
436 |
inline CBase* AttributeByIndex(TInt aIndex) const;
|
williamr@2
|
437 |
//##ModelId=3B666BCC01DE
|
williamr@2
|
438 |
inline CBase* AttributeByIndex(TInt aIndex,TAttributeType& aType) const;
|
williamr@2
|
439 |
//##ModelId=3B666BCC01D9
|
williamr@2
|
440 |
inline void AddAttributeL(TAttributeType aAttributeType, CBase* aAttributeValue);
|
williamr@2
|
441 |
//##ModelId=3B666BCC01D0
|
williamr@2
|
442 |
inline void AddDataAndAttributeL(HBufC16 *aData, TAttributeType aAttributeType, CBase* aAttributeValue);
|
williamr@2
|
443 |
//##ModelId=3B666BCC01CE
|
williamr@2
|
444 |
inline CBase* Attribute(TAttributeType aAttributeType) const;
|
williamr@2
|
445 |
//##ModelId=3B666BCC01CC
|
williamr@2
|
446 |
inline TBool AttributeExists(TAttributeType aAttributeType) const;
|
williamr@2
|
447 |
//##ModelId=3B666BCC01C9
|
williamr@2
|
448 |
inline TNodeType Type() const;
|
williamr@2
|
449 |
//##ModelId=3B666BCC01C7
|
williamr@2
|
450 |
inline void SetType(TNodeType aType);
|
williamr@2
|
451 |
protected:
|
williamr@2
|
452 |
//##ModelId=3B666BCC01C4
|
williamr@2
|
453 |
CTypedNode(TNodeType aType, CNode* aParent);
|
williamr@2
|
454 |
};
|
williamr@2
|
455 |
#include <cnode.inl>
|
williamr@2
|
456 |
#endif
|