|
1 /* |
|
2 * Copyright (c) 2009 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: Class to hold description about schema |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef __MDSSCHEMA_H__ |
|
19 #define __MDSSCHEMA_H__ |
|
20 |
|
21 #include <e32base.h> |
|
22 #include "mdccommon.h" |
|
23 |
|
24 class CMdsNamespaceDef; |
|
25 class CMdsObjectDef; |
|
26 class CMdsClauseBuffer; |
|
27 |
|
28 |
|
29 |
|
30 /** |
|
31 * Metadata object class |
|
32 * |
|
33 * This class is responsible for holding information about one object |
|
34 * |
|
35 */ |
|
36 class CMdsSchema : public CBase |
|
37 { |
|
38 friend class CMdsImportExport; |
|
39 |
|
40 public: |
|
41 /** |
|
42 * Create new objectdef object |
|
43 * @param aId id of object |
|
44 * @param aName name of object |
|
45 * @param aParent parent to actual object |
|
46 * @return pointer to new created object |
|
47 */ |
|
48 static CMdsSchema* NewL( ); |
|
49 |
|
50 /** |
|
51 * Create new objectdef object |
|
52 * @param aId id of object |
|
53 * @param aName name of object |
|
54 * @param aParent parent to actual object |
|
55 * @return pointer to new created object |
|
56 */ |
|
57 static CMdsSchema* NewLC( ); |
|
58 |
|
59 virtual ~CMdsSchema(); |
|
60 |
|
61 /** |
|
62 * Create tables to store whole Schema into DB |
|
63 */ |
|
64 void StoreToDBL(); |
|
65 |
|
66 /** |
|
67 * Check and return namespace searching by Id |
|
68 */ |
|
69 const CMdsNamespaceDef* GetNamespaceByIdL( TDefId aId ); |
|
70 |
|
71 /** |
|
72 * Check if namespace exists to avoid duplication |
|
73 * @param aName namespace name to search for |
|
74 * @return address of existing namespace or NULL |
|
75 */ |
|
76 CMdsNamespaceDef* GetNamespace( const TDesC& aName ); |
|
77 |
|
78 /** |
|
79 * Adds default BaseObject "Object" |
|
80 */ |
|
81 void AddDefaultObjectL(); |
|
82 |
|
83 /** |
|
84 * Adds default KMdEDefaultNameSpace |
|
85 */ |
|
86 void AddDefaultNamespaceL(); |
|
87 |
|
88 /** |
|
89 * Returns NamespaceDefsCount |
|
90 */ |
|
91 TInt NamespaceDefsCount() const; |
|
92 |
|
93 /** |
|
94 * Returns reference to the NamespaceDefs |
|
95 */ |
|
96 const RPointerArray<CMdsNamespaceDef>& NamespaceDefs() const; |
|
97 |
|
98 void SerializeToSharedMemoryL(); |
|
99 |
|
100 TInt SharedMemoryHandleL(); |
|
101 |
|
102 protected: |
|
103 |
|
104 /** |
|
105 * Add object and it's parents properties names and types to clause |
|
106 * parameters |
|
107 * @param aObject object which properties should be add |
|
108 * @param aClause clause where add instructions to sql execute |
|
109 */ |
|
110 void AddObjectToSqlClauseL( CMdsObjectDef* aObject, CMdsClauseBuffer* aClause, |
|
111 const TBool& aAddText ); |
|
112 |
|
113 /** |
|
114 * Add namespace to array of existing ones |
|
115 * @param aName namespace name |
|
116 * @param aReadOnly namespace read-only flag |
|
117 * @param aNamespaceDefId namespaceDefd, or zero (none) to get automatic one |
|
118 * @return new added namespace |
|
119 */ |
|
120 CMdsNamespaceDef* NamespaceAddL( const TDesC& aName, const TBool aReadOnly, |
|
121 TInt32 aVendorId, TDefId aNamespaceDefId = 0 ); |
|
122 |
|
123 /** |
|
124 * Combine two schemas and put it to one in aSchema |
|
125 * @param aSchema schema where to add readed schema |
|
126 */ |
|
127 void MergeNamespacesL( CMdsSchema& aSchema ); |
|
128 |
|
129 void MergeElementsL( CMdsSchema& aSchema, const TBool& aDryRun ); |
|
130 |
|
131 /** |
|
132 * Create tables to store whole Schema into DB (internal) |
|
133 */ |
|
134 void StoreSchemaToDBL(); |
|
135 |
|
136 void StoreNamespacesAndBaseObjectL(); |
|
137 |
|
138 void CreateCol2PropTableL(); |
|
139 |
|
140 void AddCol2PropObjectL( CMdsObjectDef* aObject, CMdsObjectDef* aChildObject, |
|
141 TUint32& aPropertyColumnCounter, TBool aText ); |
|
142 |
|
143 /** |
|
144 * Create tables for objects |
|
145 */ |
|
146 void CreateObjectTablesL(); |
|
147 |
|
148 private: |
|
149 inline CMdsSchema(); |
|
150 |
|
151 /** |
|
152 * 2nd phase constructor |
|
153 * @param aName name of property |
|
154 */ |
|
155 void ConstructL(); |
|
156 |
|
157 /** |
|
158 * Deletes all namespaces and clean it's array |
|
159 */ |
|
160 void Reset(); |
|
161 |
|
162 /** |
|
163 * Creates property index for a object table. |
|
164 */ |
|
165 void CreatePropertyIndexL( const TDesC& aPropertyName, const TDesC& aTableName, TDefId aNamespaceId ); |
|
166 |
|
167 class TPropertyInfo |
|
168 { |
|
169 public: |
|
170 TPropertyInfo( const TDesC& aTableName, const TDesC& aPropertyName, TDefId aNamespaceId ) : |
|
171 iTableName( aTableName ), iPropertyName( aPropertyName ) |
|
172 { |
|
173 iNamespaceId = aNamespaceId; |
|
174 } |
|
175 |
|
176 TPtrC iTableName; |
|
177 TPtrC iPropertyName; |
|
178 TDefId iNamespaceId; |
|
179 }; |
|
180 |
|
181 private: // data |
|
182 /** |
|
183 * Store every namespace read from schema file. |
|
184 */ |
|
185 RPointerArray<CMdsNamespaceDef> iNamespaceDefs; |
|
186 |
|
187 RArray<TPropertyInfo> iProperties; |
|
188 |
|
189 /** |
|
190 * Default base object, parent to all others |
|
191 */ |
|
192 CMdsObjectDef* iBaseObject; |
|
193 |
|
194 RChunk iSerializedSchema; |
|
195 |
|
196 TBool iSerialized; |
|
197 |
|
198 TInt iSchemaHandle; |
|
199 }; |
|
200 |
|
201 #endif // __MDSSCHEMA_H__ |