|
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 one namespace and every objects, |
|
15 * properties and events it holds. |
|
16 * |
|
17 */ |
|
18 |
|
19 #ifndef __MDSNAMESPACE_H__ |
|
20 #define __MDSNAMESPACE_H__ |
|
21 |
|
22 #include <e32base.h> |
|
23 #include <s32file.h> |
|
24 |
|
25 #include "mdsitemdef.h" |
|
26 |
|
27 class CMdsObjectDef; |
|
28 class CMdsEventDef; |
|
29 class CMdsRelationDef; |
|
30 class CMdCSerializationBuffer; |
|
31 class CMdsPropertyDef; |
|
32 class CMdsSchema; |
|
33 |
|
34 /** |
|
35 * Metadata namespace class |
|
36 * |
|
37 * This class is responsible for holding information about everything |
|
38 * which namespace can contain (name, objects, event, relations) |
|
39 * |
|
40 */ |
|
41 class CMdsNamespaceDef : public CMdsItemDef |
|
42 { |
|
43 friend class CMdsSchema; |
|
44 friend class CMdsImportExport; |
|
45 |
|
46 public: |
|
47 /** |
|
48 * Create new namespace object |
|
49 * @param aId id of namespace |
|
50 * @param aName name of namespace |
|
51 * @param aReadOnly read-only namespace flag |
|
52 * @return pointer to new created namespace |
|
53 */ |
|
54 static CMdsNamespaceDef* NewL( TDefId aId, const TDesC& aName, TBool aReadOnly, |
|
55 TUint32 aVendorId ); |
|
56 |
|
57 /** |
|
58 * Create new namespace object |
|
59 * @param aId id of namespace |
|
60 * @param aName name of namespace |
|
61 * @param aReadOnly read-only namespace flag |
|
62 * @return pointer to new created namespace |
|
63 */ |
|
64 static CMdsNamespaceDef* NewLC( TDefId aId, const TDesC& aName, TBool aReadOnly, |
|
65 TUint32 aVendorId ); |
|
66 |
|
67 virtual ~CMdsNamespaceDef(); |
|
68 |
|
69 inline TBool GetReadOnly() const; |
|
70 |
|
71 inline TBool GetFirstRead() const; |
|
72 |
|
73 inline void UnsetFirstRead(); |
|
74 |
|
75 inline void SetBaseObject( CMdsObjectDef* const aBaseObject ); |
|
76 |
|
77 inline TInt32 GetVendorId() const; |
|
78 |
|
79 inline void SetVendorId(TInt32 aVendorId); |
|
80 |
|
81 /** |
|
82 * Add object to namespace and return pointer to it, |
|
83 * if object already exist function leaves with KErrAlreadyExists |
|
84 * @param objName name of the object definition |
|
85 * @param parName name of the object parent |
|
86 * @return pointer to new object definition or leave with error |
|
87 */ |
|
88 CMdsObjectDef* AddObjectDefL( const TDesC& aObjectName, const TDesC& aParentName, CMdsSchema* aDefaultSchema ); |
|
89 |
|
90 /** |
|
91 * Add relation to array |
|
92 * @param relName name of relation |
|
93 */ |
|
94 void AddRelationDefL( const TDesC& aRelationName ); |
|
95 |
|
96 /** |
|
97 * Add event to event array |
|
98 * @param objName name of event |
|
99 * @param aPriority priority of event |
|
100 */ |
|
101 void AddEventDefL( const TDesC& aEventName, TInt32 aPriority ); |
|
102 |
|
103 /** |
|
104 * Gets object def by object def id. |
|
105 * @param aId objectdef id |
|
106 * @return a pointer to object definition |
|
107 */ |
|
108 const CMdsObjectDef* GetObjectByIdL( TDefId aId ) const; |
|
109 |
|
110 /** |
|
111 * Gets event def by devent def id. |
|
112 * @param aId eventdef id |
|
113 * @return a pointer to event definition |
|
114 */ |
|
115 const CMdsEventDef* GetEventByIdL( TDefId aId ) const; |
|
116 |
|
117 /** |
|
118 * Gets relation def by relation def id. |
|
119 * @param aId relationdef id |
|
120 * @return a pointer to relation definition |
|
121 */ |
|
122 const CMdsRelationDef* GetRelationByIdL( TDefId aId ) const; |
|
123 |
|
124 /** |
|
125 * Gets property def by property def id. |
|
126 * @param aId property id |
|
127 * @return a pointer to relation property |
|
128 */ |
|
129 const CMdsPropertyDef* GetPropertyL( TDefId aId ) const; |
|
130 |
|
131 /** |
|
132 * Import object, event and relation defs from default DB. |
|
133 */ |
|
134 void ImportFromDBL(); |
|
135 |
|
136 /** |
|
137 * Adds new object definition to DB. |
|
138 * @param aId object def id |
|
139 * @param aParentId parent object def id |
|
140 * @param aFlags flags for the new object |
|
141 * @param aName new object def name |
|
142 */ |
|
143 void AddObjectDefL( TDefId aId, TDefId aParentId, TInt aFlags, const TDesC& aName ); |
|
144 |
|
145 /** |
|
146 * Adds new relation definition to DB. |
|
147 * @param aId relation def id |
|
148 * @param aRelationName new relation name |
|
149 */ |
|
150 void AddRelationDefL( TDefId aId, const TDesC& aRelationName ); |
|
151 |
|
152 /** |
|
153 * Adds new event definition to DB. |
|
154 * @param aId event def id |
|
155 * @param aEventName new event name |
|
156 * @param aPriority |
|
157 */ |
|
158 void AddEventDefL( TDefId aId, const TDesC& aEventName, TInt32 aPriority ); |
|
159 |
|
160 /** |
|
161 * Get required size of serialized buffer when this is serialized. |
|
162 * |
|
163 * @return required size of serialized buffer |
|
164 */ |
|
165 TUint32 RequiredBufferSize(); |
|
166 |
|
167 /** |
|
168 * Serialize own data to serialized buffer (correct position must be set |
|
169 * before calling) and return new position of serialized buffer. |
|
170 * |
|
171 * @param aBuffer serialized buffer. |
|
172 */ |
|
173 TMdCOffset SerializeL(CMdCSerializationBuffer& aBuffer, TMdCOffset aFreeSpace); |
|
174 |
|
175 /** |
|
176 * Search for relation, using name |
|
177 * @param objName name of object to search for |
|
178 * @return pointer to found object or NULL |
|
179 */ |
|
180 CMdsRelationDef* GetRelationDef( const TDesC& aRelationName ) const; |
|
181 |
|
182 /** |
|
183 * Search for event, using name |
|
184 * @param objName name of object to search for |
|
185 * @return pointer to found object or NULL |
|
186 */ |
|
187 CMdsEventDef* GetEventDef( const TDesC& aEventName ) const; |
|
188 |
|
189 /** |
|
190 * Search for object, using name |
|
191 * @param objName name of object to search for |
|
192 * @return pointer to found object or NULL |
|
193 */ |
|
194 CMdsObjectDef* GetObjectDef( const TDesC& aObjectName ) const; |
|
195 |
|
196 |
|
197 private: |
|
198 |
|
199 /** |
|
200 * default constructor |
|
201 */ |
|
202 inline CMdsNamespaceDef( TDefId aId, TBool aReadOnly, |
|
203 TUint32 aVendorId ); |
|
204 |
|
205 /** |
|
206 * Second phase constructor |
|
207 * @param aName name of namespace |
|
208 */ |
|
209 void ConstructL( const TDesC& aName ); |
|
210 |
|
211 void StoreToDBL(TBool aStoreOnlyNamespace = EFalse ); |
|
212 void MergeObjectsL( CMdsNamespaceDef* aNamespace, const TBool& aDryRun ); |
|
213 void MergeRelationsL( CMdsNamespaceDef* aNamespace, const TBool& aDryRun ); |
|
214 void MergeEventsL( CMdsNamespaceDef* aNamespace, const TBool& aDryRun ); |
|
215 |
|
216 private: |
|
217 enum TNamespaceDefFlags |
|
218 { |
|
219 ENamespaceDefFlagsReadOnly = 0x0001, |
|
220 ENamespaceDefFlagsFirstRead = 0x0002, |
|
221 }; |
|
222 |
|
223 private: |
|
224 /** |
|
225 * Store every namespace read from schema file. |
|
226 */ |
|
227 RPointerArray<CMdsObjectDef> iObjectDefs; |
|
228 |
|
229 /** |
|
230 * Store every namespace read from schema file. |
|
231 */ |
|
232 RPointerArray<CMdsEventDef> iEventDefs; |
|
233 |
|
234 /** |
|
235 * Store every namespace read from schema file. |
|
236 */ |
|
237 RPointerArray<CMdsRelationDef> iRelationDefs; |
|
238 |
|
239 TInt32 iVendorId; |
|
240 |
|
241 /** |
|
242 * Namespace flags: readOnly, firstRead |
|
243 */ |
|
244 TUint32 iFlags; |
|
245 |
|
246 /** |
|
247 * Pointer to base object |
|
248 * DO NOT DELETE, NOT OWN !!! |
|
249 */ |
|
250 static CMdsObjectDef* iBaseObject; |
|
251 }; |
|
252 |
|
253 #include "mdsnamespacedef.inl" |
|
254 |
|
255 #endif // __MDSNAMESPACE_H__ |