1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 // All rights reserved. |
2 // All rights reserved. |
3 // This component and the accompanying materials are made available |
3 // This component and the accompanying materials are made available |
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 |
4 // under the terms of "Eclipse Public License v1.0" |
5 // which accompanies this distribution, and is available |
5 // which accompanies this distribution, and is available |
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 // |
7 // |
8 // Initial Contributors: |
8 // Initial Contributors: |
9 // Nokia Corporation - initial contribution. |
9 // Nokia Corporation - initial contribution. |
10 // |
10 // |
11 // Contributors: |
11 // Contributors: |
13 // Description: |
13 // Description: |
14 // Meta-database declarations for use in storing comms data |
14 // Meta-database declarations for use in storing comms data |
15 // |
15 // |
16 // |
16 // |
17 |
17 |
18 |
|
19 |
|
20 /** |
18 /** |
21 @file |
19 @file |
22 @publishedPartner |
20 @publishedAll |
23 @released |
21 @released |
24 */ |
22 */ |
25 |
|
26 |
23 |
27 #if (!defined METADATABASE_H) |
24 #if (!defined METADATABASE_H) |
28 #define METADATABASE_H |
25 #define METADATABASE_H |
29 |
26 |
30 |
27 |
31 |
28 |
32 // NetMeta headers |
29 // NetMeta headers |
33 #include <comms-infras/metadata.h> |
30 #include <comms-infras/metadata.h> |
34 #include <comms-infras/metatype.h> |
31 #include <comms-infras/metatype.h> |
|
32 |
|
33 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
34 #include <metadatabase_partner.h> |
|
35 #endif |
35 |
36 |
36 // CommsDat headers |
37 // CommsDat headers |
37 #include <commsdat.h> |
38 #include <commsdat.h> |
38 |
39 |
39 |
40 |
155 Attribute flags for an element in the Meta Database |
156 Attribute flags for an element in the Meta Database |
156 Attributes describe access rights to the data in the database |
157 Attributes describe access rights to the data in the database |
157 @publishedAll |
158 @publishedAll |
158 @released |
159 @released |
159 */ |
160 */ |
160 typedef TUint32 TMDBAttributeFlags; |
161 typedef TUint32 TMDBAttributeFlags; |
161 |
|
162 |
162 |
163 /** |
163 /** |
164 The identifier for any entry in the MetaDatabase. |
164 The identifier for any entry in the MetaDatabase. |
165 It can specify |
165 It can specify |
166 <TableId><ColumnId><RecordId> |
166 <TableId><ColumnId><RecordId> |
172 @publishedAll |
172 @publishedAll |
173 @released |
173 @released |
174 */ |
174 */ |
175 typedef TUint32 TMDBElementId; |
175 typedef TUint32 TMDBElementId; |
176 |
176 |
|
177 |
|
178 // |
|
179 // COMMSDAT RECORD BASE CLASS |
|
180 // Contains fields common to all records |
|
181 // |
|
182 |
|
183 // Element Type Ids |
|
184 |
|
185 /** |
|
186 Field will contain a user-defined numeric tag for a record. |
|
187 Useful for user searches and cheaper to search on a numeric tag than a string name. |
|
188 Can be null. |
|
189 This tag is not automatically connected with the record id itself, |
|
190 which is contained within the ElementId for the record and not in any field. |
|
191 |
|
192 @publishedAll |
|
193 @released |
|
194 */ |
|
195 const TMDBElementId KCDTIdRecordTag = 0x00010000; |
|
196 |
|
197 /** |
|
198 Field will contain a user-defined string tag for a record. |
|
199 This is used to uniquely identify business level information within a record. |
|
200 |
|
201 This field is useful for user searches, however it should be noted that it would be more efficient to use the KCDTIdRecordTag field instead |
|
202 as it is quicker and cheaper to search for a number than for a string. |
|
203 |
|
204 @publishedAll |
|
205 @released |
|
206 */ |
|
207 const TMDBElementId KCDTIdRecordName = 0x00020000; |
|
208 |
|
209 |
|
210 // Element Type Names |
|
211 #define KCDTypeNameRecordTag _S("Id") |
|
212 #define KCDTypeNameRecordName _S("Name") |
|
213 |
|
214 |
177 class CMDBSession : public CBase |
215 class CMDBSession : public CBase |
178 /* |
216 /** |
179 A session with the underlying storage server |
217 A session with the underlying storage server |
180 @publishedAll |
218 @publishedAll |
181 @released |
219 @released |
182 */ |
220 */ |
183 { |
221 { |
200 @leave System-wide error codes if there is an unexpected error |
238 @leave System-wide error codes if there is an unexpected error |
201 |
239 |
202 @pre None |
240 @pre None |
203 @post on success a session has been created and initialised |
241 @post on success a session has been created and initialised |
204 |
242 |
205 @publishedAll |
|
206 */ |
243 */ |
207 IMPORT_C static CMDBSession* NewL(TVersion aRequiredVersion); |
244 IMPORT_C static CMDBSession* NewL(TVersion aRequiredVersion); |
208 |
245 |
209 /** |
246 /** |
210 As NewL and adds Session to the CleanupStack |
247 As NewL and adds Session to the CleanupStack |
211 |
248 |
212 @publishedAll |
|
213 */ |
249 */ |
214 IMPORT_C static CMDBSession* NewLC(TVersion aRequiredVersion); |
250 IMPORT_C static CMDBSession* NewLC(TVersion aRequiredVersion); |
215 |
251 |
216 /** |
252 /** |
217 Virtual Destructor |
253 Virtual Destructor |
218 |
254 |
219 @publishedAll |
|
220 */ |
255 */ |
221 IMPORT_C ~CMDBSession(); |
256 IMPORT_C ~CMDBSession(); |
222 |
257 |
223 |
258 |
224 /** |
259 /** |
225 Close session with storage server. |
260 Close session with storage server. |
226 |
|
227 @publishedAll |
261 @publishedAll |
228 @deprecated v9.1 Destructor is all that is required |
262 @deprecated v9.1 Destructor is all that is required |
229 */ |
263 */ |
230 IMPORT_C void Close(); |
264 IMPORT_C void Close(); |
231 |
265 |
232 |
266 |
233 /** |
267 /** |
234 Lookup latest data format version |
268 Returns the KCDCurrentVersion constant which maps to the KCDVersion1_1 |
235 |
269 constant for backward compatibility reason. Please avoid using this method |
|
270 when creating a CommsDat session object and use explicit schema version |
|
271 instead. |
|
272 |
236 @pre None |
273 @pre None |
237 @post None |
274 @post None |
|
275 |
238 @publishedAll |
276 @publishedAll |
|
277 @deprecated |
|
278 |
239 */ |
279 */ |
240 IMPORT_C static TVersion LatestVersion(); |
280 IMPORT_C static TVersion LatestVersion(); |
241 |
281 |
242 |
282 |
243 /** |
283 /** |
244 Lookup data format version currently in use by client |
284 Lookup data format version currently in use by client |
245 |
285 |
246 @publishedAll |
286 |
247 */ |
287 */ |
248 IMPORT_C TVersion VersionInUse(); |
288 IMPORT_C TVersion VersionInUse(); |
249 |
289 |
250 |
290 |
251 /** |
291 /** |
273 |
313 |
274 @pre None |
314 @pre None |
275 |
315 |
276 @post On success the database is updated with data added, modified or deleted during the transaction |
316 @post On success the database is updated with data added, modified or deleted during the transaction |
277 @post On failure, any open data containers may not be in sync with the database and should be discarded or reloaded |
317 @post On failure, any open data containers may not be in sync with the database and should be discarded or reloaded |
278 @publishedAll |
|
279 */ |
318 */ |
280 IMPORT_C void CommitTransactionL(); |
319 IMPORT_C void CommitTransactionL(); |
281 |
320 |
282 |
321 |
283 /** |
322 /** |
284 Cancel Transaction with database and rollback all associated changes |
323 Cancel Transaction with database and rollback all associated changes |
285 Will not make any changes to the client's containers |
|
286 |
324 |
287 @leave Will fail with KErrNotFound if not in transaction |
325 @leave Will fail with KErrNotFound if not in transaction |
288 |
326 |
289 @pre None - though for correct usage, ensure a transaction is already open |
327 @pre None - though for correct usage, ensure a transaction is already open |
290 @post Any open data containers may not be in sync with the database and should be discarded or reloaded |
328 @post Any open data containers may not be in sync with the database and should be discarded or reloaded |
291 @publishedAll |
|
292 */ |
329 */ |
293 IMPORT_C void RollbackTransactionL(); |
330 IMPORT_C void RollbackTransactionL(); |
294 |
331 |
295 /** |
332 /** |
296 Query if this session is in a transaction with the database |
333 Query if this session is in a transaction with the database |
297 Return code will indicate |
334 Return code will indicate |
298 Not in transaction, |
335 Not in transaction, |
299 Already in transaction for this session, |
336 Already in transaction for this session, |
300 Write-lock not available. Another session has it. |
337 Write-lock not available. Another session has it. |
301 |
|
302 @pre None |
338 @pre None |
303 @publishedAll |
|
304 */ |
339 */ |
305 IMPORT_C TInt IsInTransaction(); |
340 IMPORT_C TInt IsInTransaction(); |
306 |
341 |
307 |
342 |
308 /** |
343 /** |
311 @params aAttributeFlags indicates the requested access level to stored data. |
346 @params aAttributeFlags indicates the requested access level to stored data. |
312 Attributes set by this call will be ignored as restrictions in all database interactions, |
347 Attributes set by this call will be ignored as restrictions in all database interactions, |
313 providing the client has enough platform security capabilities to back up the request |
348 providing the client has enough platform security capabilities to back up the request |
314 |
349 |
315 @pre None |
350 @pre None |
316 @publishedAll |
|
317 */ |
351 */ |
318 IMPORT_C void SetAttributeMask(TMDBAttributeFlags aAttributeFlags); |
352 IMPORT_C void SetAttributeMask(TMDBAttributeFlags aAttributeFlags); |
319 |
353 |
320 |
354 |
321 /** |
355 /** |
392 private: |
424 private: |
393 |
425 |
394 CMDBSessionImpl* iMDBSessionImpl; |
426 CMDBSessionImpl* iMDBSessionImpl; |
395 |
427 |
396 friend class MMetaDatabase; |
428 friend class MMetaDatabase; |
|
429 friend class CommsDatSchema; |
397 }; |
430 }; |
398 |
431 |
399 |
432 |
400 |
433 |
401 |
434 |
402 |
435 |
403 class MMetaDatabase : public Meta::MMetaData |
436 class MMetaDatabase : public Meta::MMetaData |
404 /* |
437 /** |
405 Interface for interaction with a database server |
438 Interface for interaction with a database server |
406 Inherited by each data set type that can be stored |
439 Inherited by each data set type that can be stored |
407 @publishedAll |
440 @publishedAll |
|
441 @released |
408 */ |
442 */ |
409 { |
443 { |
410 public: |
444 public: |
411 |
445 |
412 IMPORT_C virtual ~MMetaDatabase(); |
446 IMPORT_C virtual ~MMetaDatabase(); |
438 Ensure the ElementId for this container fully identifies the target data in the database |
472 Ensure the ElementId for this container fully identifies the target data in the database |
439 <Table><Column><Record> |
473 <Table><Column><Record> |
440 Ensure that the session object has been initialised with the correct dataset version |
474 Ensure that the session object has been initialised with the correct dataset version |
441 Ensure that the session object has appropriate access control attributes to manage the target data in the database |
475 Ensure that the session object has appropriate access control attributes to manage the target data in the database |
442 |
476 |
443 @publishedAll |
|
444 */ |
477 */ |
445 IMPORT_C void LoadL(CMDBSession& aSession); |
478 IMPORT_C void LoadL(CMDBSession& aSession); |
446 |
479 |
447 |
480 |
448 /** |
481 /** |
459 EFalse if no data found that the client is authorised to view |
492 EFalse if no data found that the client is authorised to view |
460 |
493 |
461 May also leave with KErrGeneral or other general error codes. |
494 May also leave with KErrGeneral or other general error codes. |
462 |
495 |
463 On failure, the container should be discarded or repopulated before it is used again |
496 On failure, the container should be discarded or repopulated before it is used again |
464 |
497 |
|
498 Please note - a case insensitive search is done in the case of text based fields |
|
499 |
465 @pre |
500 @pre |
466 |
501 |
467 Populate this container where necessary with valid data to match during the find operation |
502 Populate this container where necessary with valid data to match during the find operation |
468 Ensure the ElementId for this container correcty identifies the target table in the database |
503 Ensure the ElementId for this container correcty identifies the target table in the database |
469 <Table><Column> |
504 <Table><Column> |
470 Ensure that the session object has been initialised with the correct dataset version |
505 Ensure that the session object has been initialised with the correct dataset version |
471 Ensure that the session object has appropriate access control attributes to manage the target data in the database |
506 Ensure that the session object has appropriate access control attributes to manage the target data in the database |
472 @publishedAll |
|
473 */ |
507 */ |
474 IMPORT_C TBool FindL(CMDBSession& aSession); |
508 IMPORT_C TBool FindL(CMDBSession& aSession); |
475 |
509 |
476 |
510 |
477 /** |
511 /** |
497 |
531 |
498 Ensure the ElementId for this container fully identifies the target data in the database |
532 Ensure the ElementId for this container fully identifies the target data in the database |
499 <Table><Column><Record> |
533 <Table><Column><Record> |
500 Ensure that the session object has been initialised with the correct dataset version |
534 Ensure that the session object has been initialised with the correct dataset version |
501 Ensure that the session object has appropriate access control attributes to manage the target data in the database |
535 Ensure that the session object has appropriate access control attributes to manage the target data in the database |
502 @publishedAll |
|
503 */ |
536 */ |
504 IMPORT_C void RefreshL(CMDBSession& aSession); |
537 IMPORT_C void RefreshL(CMDBSession& aSession); |
505 |
538 |
506 |
539 |
507 /** |
540 /** |
526 KErrAlreadyExists |
559 KErrAlreadyExists |
527 |
560 |
528 May also leave with other general error codes if there are unexpected |
561 May also leave with other general error codes if there are unexpected |
529 problems (e.g. KErrNoMemory when out of memory) |
562 problems (e.g. KErrNoMemory when out of memory) |
530 |
563 |
531 |
564 Store will be atomic - all fields stored after success. No fields stored if the function leaves |
|
565 |
532 If StoreL fails or the later commit is not successful, The data in the container will not |
566 If StoreL fails or the later commit is not successful, The data in the container will not |
533 match the data in the database. |
567 match the data in the database. |
534 |
568 |
535 On failure, the container should be discarded or repopulated before it is used again |
569 On failure, the container should be discarded or repopulated before it is used again |
536 |
570 |
540 Ensure the ElementId for this container fully identifies the target location in the database |
574 Ensure the ElementId for this container fully identifies the target location in the database |
541 <Table><Column><Record> |
575 <Table><Column><Record> |
542 Ensure that the session object has been initialised with the correct dataset version |
576 Ensure that the session object has been initialised with the correct dataset version |
543 Ensure that the session object has appropriate access control attributes to manage the target data in the database |
577 Ensure that the session object has appropriate access control attributes to manage the target data in the database |
544 |
578 |
545 @publishedAll |
|
546 */ |
579 */ |
547 IMPORT_C void StoreL(CMDBSession& aSession); |
580 IMPORT_C void StoreL(CMDBSession& aSession); |
548 |
581 |
549 |
582 |
550 /** |
583 /** |
551 Modify all fields in the database that have been changed in this container by the caller |
584 Modify all fields in the database that have been changed in this container by the caller |
552 |
|
553 Only modifies existing data in the database, won't create new fields VCT - is this true?? don't think so |
|
554 |
585 |
555 Modification is atomic for this container. It uses an internal transaction even if |
586 Modification is atomic for this container. It uses an internal transaction even if |
556 no overall transaction set by client. |
587 no overall transaction set by client. |
557 All changed fields in the element are modified in database on success. |
588 All changed fields in the element are modified in database on success. |
558 No fields are altered in the database if the function leaves |
589 No fields are altered in the database if the function leaves |
560 Client can request to ignore access control flags by setting the attribute mask |
591 Client can request to ignore access control flags by setting the attribute mask |
561 CMDBSession::SetAttributeMask() |
592 CMDBSession::SetAttributeMask() |
562 However, only fields that the client has capabilities to alter will be modified.in the database |
593 However, only fields that the client has capabilities to alter will be modified.in the database |
563 A request to modify data in an unauthorised area will cause the function to leave.with |
594 A request to modify data in an unauthorised area will cause the function to leave.with |
564 KErrPermissionDenied |
595 KErrPermissionDenied |
565 |
596 |
566 If field does not exist, the function will leave with |
|
567 KErrNotFound [VCT - surely not] |
|
568 |
597 |
569 May also leave with other general error codes if there are unexpected |
598 May also leave with other general error codes if there are unexpected |
570 problems (e.g. KErrNoMemory when out of memory) |
599 problems (e.g. KErrNoMemory when out of memory) |
571 |
600 |
572 On failure, the container should be discarded or repopulated before it is used again |
601 On failure, the container should be discarded or repopulated before it is used again |
576 Populate this container with valid data for storage |
605 Populate this container with valid data for storage |
577 Ensure the ElementId for this container fully identifies the target data in the database |
606 Ensure the ElementId for this container fully identifies the target data in the database |
578 <Table><Column><Record> |
607 <Table><Column><Record> |
579 Ensure that the session object has been initialised with the correct dataset version |
608 Ensure that the session object has been initialised with the correct dataset version |
580 Ensure that the session object has appropriate access control attributes to manage the target data in the database |
609 Ensure that the session object has appropriate access control attributes to manage the target data in the database |
581 @publishedAll |
|
582 */ |
610 */ |
583 IMPORT_C void ModifyL(CMDBSession& aSession); |
611 IMPORT_C void ModifyL(CMDBSession& aSession); |
584 |
612 |
585 |
613 |
586 /** |
614 /** |
599 @pre Ensure the ElementId for this container fully identifies the target data in the database |
627 @pre Ensure the ElementId for this container fully identifies the target data in the database |
600 <Table><Column><Record> |
628 <Table><Column><Record> |
601 Ensure that the session object has appropriate access control attributes to manage the target data in the database |
629 Ensure that the session object has appropriate access control attributes to manage the target data in the database |
602 Ensure the ElementId for this container correcty identifies the target data in the database |
630 Ensure the ElementId for this container correcty identifies the target data in the database |
603 |
631 |
604 @publishedAll |
|
605 */ |
632 */ |
606 IMPORT_C void DeleteL(CMDBSession& aSession); |
633 IMPORT_C void DeleteL(CMDBSession& aSession); |
607 |
634 |
608 |
635 |
609 /** |
636 /** |
629 @params aSession a valid session object |
656 @params aSession a valid session object |
630 @params aRequestStatus the requestStatus object that will be completed on notification |
657 @params aRequestStatus the requestStatus object that will be completed on notification |
631 |
658 |
632 @pre None |
659 @pre None |
633 @post A notification request will be outstanding |
660 @post A notification request will be outstanding |
634 |
|
635 @publishedAll |
|
636 */ |
661 */ |
637 IMPORT_C TInt RequestNotification(CMDBSession& aSession, |
662 IMPORT_C TInt RequestNotification(CMDBSession& aSession, |
638 TRequestStatus& aRequestStatus); |
663 TRequestStatus& aRequestStatus); |
639 |
664 |
640 /** |
665 /** |
646 |
671 |
647 @pres |
672 @pres |
648 |
673 |
649 There is an outstanding notification request |
674 There is an outstanding notification request |
650 |
675 |
651 @publishedAll |
|
652 */ |
676 */ |
653 IMPORT_C TInt CancelNotification(CMDBSession& aSession, |
677 IMPORT_C TInt CancelNotification(CMDBSession& aSession, |
654 TRequestStatus& aRequestStatus); |
678 TRequestStatus& aRequestStatus); |
655 |
679 |
656 |
680 |
657 protected: |
681 protected: |
658 |
682 |
659 |
683 |
660 explicit MMetaDatabase(); |
684 IMPORT_C explicit MMetaDatabase(); |
661 |
685 |
662 private: |
686 private: |
663 |
687 |
664 /* |
688 /* |
665 @internalComponent |
689 @internalComponent |
666 */ |
690 */ |
667 void DoLoadL(CMDBSessionImpl* aSession, CMDBElement* aElement, CMDBElement* aMapper, TInt& aErr, TMDBElementId aRecordId, TMDBElementId aAttributes); |
691 void DoLoadL(CMDBSessionImpl* aSession, CMDBElement* aElement, CMDBElement* aMapper, TInt& aErr, TMDBElementId aRecordId, TMDBElementId aAttributes, TBool isTheLoadForMapper = EFalse); |
668 |
692 |
669 /* |
693 /* |
670 @internalComponent |
694 @internalComponent |
671 */ |
695 */ |
672 void DoLoadL(CMDBSessionImpl* aSession, CMDBElement* aElement, CMDBElement* aMapper, TInt& aErr, TMDBElementId aRecordId, TMDBElementId aAttributes, RArray<TUint32>& aMatches); |
696 void DoLoadL(CMDBSessionImpl* aSession, CMDBElement* aElement, CMDBElement* aMapper, TInt& aErr, TMDBElementId aRecordId, TMDBElementId aAttributes, RArray<TUint32>& aMatches, TBool isTheLoadForMapper = EFalse); |
673 |
697 |
674 /* |
698 /* |
675 @internalComponent |
699 @internalComponent |
676 */ |
700 */ |
677 void DoFindL(CMDBSessionImpl* aSession, CMDBElement* aElement, CMDBElement* aMapper, TInt& aErr, RArray<TUint32>& candidates, RArray<TUint32>& matches); |
701 void DoFindL(CMDBSessionImpl* aSession, CMDBElement* aElement, CMDBElement* aMapper, TInt& aErr, RArray<TUint32>& candidates, RArray<TUint32>& matches); |
696 |
720 |
697 |
721 |
698 |
722 |
699 |
723 |
700 class CMDBElement : public CBase, public MMetaDatabase |
724 class CMDBElement : public CBase, public MMetaDatabase |
701 /* |
725 /** |
702 Every item stored in the database is represented as a CMDBElement |
726 Every item stored in the database is represented as a CMDBElement |
703 This class contains the id and attributes of every item in the database |
727 This class contains the id and attributes of every item in the database |
704 and for individual fields it also contains the value. |
728 and for individual fields it also contains the value. |
705 |
729 |
706 @publishedAll |
730 @publishedAll |
789 |
804 |
790 The RecordId is part of the ElementId <x><x><RecordId> |
805 The RecordId is part of the ElementId <x><x><RecordId> |
791 |
806 |
792 It identifies a particular instance of this type of Element in the database |
807 It identifies a particular instance of this type of Element in the database |
793 |
808 |
794 @publishedAll |
|
795 */ |
809 */ |
796 IMPORT_C TInt RecordId() const; |
810 IMPORT_C TInt RecordId() const; |
797 |
811 |
798 |
812 |
799 /** |
813 /** |
800 Returns the Attributes of an object of this type. |
814 Returns the Attributes of an object of this type. |
801 |
815 |
802 Attributes express database access rights for the data of this element |
816 Attributes express database access rights for the data of this element |
803 |
817 |
804 @publishedAll |
|
805 */ |
818 */ |
806 IMPORT_C TMDBAttributeFlags Attributes() const; |
819 IMPORT_C TMDBAttributeFlags Attributes() const; |
807 |
820 |
808 // SETTER FUNCTIONS |
821 // SETTER FUNCTIONS |
809 |
822 |
810 /** |
823 /** |
811 Sets the ElementId |
824 Sets the ElementId |
812 |
825 |
813 @publishedAll |
|
814 */ |
826 */ |
815 IMPORT_C void SetElementId(TMDBElementId aElementId); |
827 IMPORT_C void SetElementId(TMDBElementId aElementId); |
816 |
828 |
817 |
829 |
818 /** |
830 /** |
819 Sets the TypeId |
831 Sets the TypeId |
820 |
832 |
821 @publishedAll |
|
822 */ |
833 */ |
823 IMPORT_C void SetTypeId(TMDBElementId aElementId); |
834 IMPORT_C void SetTypeId(TMDBElementId aElementId); |
824 |
835 |
825 |
836 |
826 /** |
837 /** |
827 Sets the RecordId |
838 Sets the RecordId |
828 |
839 |
829 @publishedAll |
|
830 */ |
840 */ |
831 IMPORT_C void SetRecordId(TInt aRecordId); |
841 IMPORT_C void SetRecordId(TInt aRecordId); |
832 |
842 |
833 |
843 |
834 /** |
844 /** |
835 Sets one or more attributes |
845 Sets one or more attributes |
836 |
846 |
837 @publishedAll |
|
838 */ |
847 */ |
839 IMPORT_C void SetAttributes(TMDBAttributeFlags aAttributes); |
848 IMPORT_C void SetAttributes(TMDBAttributeFlags aAttributes); |
840 |
849 |
841 |
850 |
842 /** |
851 /** |
843 Clears one or more attributes |
852 Clears one or more attributes |
844 |
853 |
845 @publishedAll |
|
846 */ |
854 */ |
847 IMPORT_C void ClearAttributes(TMDBAttributeFlags aAttributes); |
855 IMPORT_C void ClearAttributes(TMDBAttributeFlags aAttributes); |
848 |
856 |
849 |
857 |
850 /** |
858 /** |
851 Queries the attributes |
859 Queries the attributes |
852 |
860 |
853 Returns ETrue if all queried attributes are set |
861 Returns ETrue if all queried attributes are set |
854 Returns EFalse if any queried attribute is not set. |
862 Returns EFalse if any queried attribute is not set. |
855 |
|
856 @publishedAll |
|
857 */ |
863 */ |
858 IMPORT_C TBool IsSetAttribute(TMDBAttributeFlags aAttributes) const; |
864 IMPORT_C TBool IsSetAttribute(TMDBAttributeFlags aAttributes) const; |
859 |
865 |
860 |
866 |
861 /** |
867 /** |
862 Queries the state of the field value |
868 Queries the state of the field value |
863 |
869 |
864 Returns ETrue if the value of the element is not set |
870 Returns ETrue if the value of the element is not set |
865 Returns EFalse if the element contains a value |
871 Returns EFalse if the element contains a value |
866 |
872 |
867 @publishedAll |
|
868 */ |
873 */ |
869 IMPORT_C TBool IsNull() const; |
874 IMPORT_C TBool IsNull() const; |
870 |
875 |
871 |
876 |
872 |
877 |
875 /** |
880 /** |
876 Queries the type of the field value |
881 Queries the type of the field value |
877 |
882 |
878 Returns the enumeration TCDFieldValueTypes that represents the value that can be stored in this element |
883 Returns the enumeration TCDFieldValueTypes that represents the value that can be stored in this element |
879 |
884 |
880 @publishedAll |
|
881 */ |
885 */ |
882 |
886 |
883 virtual TCDFieldValueTypes Type()=0; |
887 virtual TCDFieldValueTypes Type()=0; |
884 |
888 |
885 /** |
889 /** |
886 @internalComponent |
890 @internalComponent |
887 */ |
891 */ |
888 TMDBElementId* Data(){return &iElementId;} |
892 TMDBElementId* Data(){return &iElementId;} |
889 |
|
890 /** |
|
891 @internalComponent |
|
892 */ |
|
893 const TMDBElementId* CData(){return &iElementId;} |
|
894 |
|
895 |
|
896 |
893 |
897 protected: |
894 protected: |
898 |
895 |
899 TMDBElementId iElementId; |
896 TMDBElementId iElementId; |
900 |
897 |
924 |
921 |
925 /** |
922 /** |
926 Constructor setting Field's ElementId |
923 Constructor setting Field's ElementId |
927 */ |
924 */ |
928 IMPORT_C CMDBNumFieldBase(TMDBElementId aFieldId); |
925 IMPORT_C CMDBNumFieldBase(TMDBElementId aFieldId); |
929 |
926 |
930 |
927 |
931 /** |
928 /** |
932 Assignment operator for field value |
929 Assignment operator for field value |
933 */ |
930 */ |
934 IMPORT_C CMDBNumFieldBase& operator=(const TInt aValue); |
931 IMPORT_C CMDBNumFieldBase& operator=(const TInt aValue); |
935 |
932 |
936 IMPORT_C void SetMaxLengthL(TInt aLength); |
933 IMPORT_C void SetMaxLengthL(TInt aLength); |
937 TMDBElementId GetL(); |
934 TMDBElementId GetL(); |
938 |
935 |
939 EXP_DATA_VTABLE |
936 EXP_DATA_VTABLE |
940 |
937 |
|
938 |
|
939 private: |
941 virtual TCDFieldValueTypes Type() |
940 virtual TCDFieldValueTypes Type() |
942 { |
941 { |
943 return EInt; |
942 return EInt; |
944 } |
943 } |
945 |
944 |
950 /** |
949 /** |
951 A thin template that guards typed data access in a single CMDBElement |
950 A thin template that guards typed data access in a single CMDBElement |
952 This class describes a single numeric field in the database |
951 This class describes a single numeric field in the database |
953 |
952 |
954 @publishedAll |
953 @publishedAll |
|
954 @released |
955 */ |
955 */ |
956 { |
956 { |
957 public: |
957 public: |
958 |
958 |
959 /** |
959 /** |
960 Default Constructor |
960 Default Constructor |
961 |
|
962 @publishedAll |
|
963 */ |
961 */ |
964 inline CMDBField() |
962 inline CMDBField() |
965 { |
963 { |
966 } |
964 } |
967 |
965 |
968 /** |
966 /** |
969 Constructor setting Field's ElementId |
967 Constructor setting Field's ElementId |
970 |
|
971 @publishedAll |
|
972 */ |
968 */ |
973 inline CMDBField(TMDBElementId aFieldId) |
969 inline CMDBField(TMDBElementId aFieldId) |
974 : CMDBNumFieldBase(aFieldId) |
970 : CMDBNumFieldBase(aFieldId) |
975 { |
971 { |
976 } |
972 } |
977 |
973 |
978 |
974 |
979 /** |
975 /** |
980 Assignment operator for field value |
976 Assignment operator for field value |
981 |
|
982 @publishedAll |
|
983 */ |
977 */ |
984 inline CMDBField<TYPE>& operator=(const TYPE& aValue) |
978 inline CMDBField<TYPE>& operator=(const TYPE& aValue) |
985 { |
979 { |
986 return (CMDBField<TYPE>&)CMDBNumFieldBase::operator=((TInt&)aValue); |
980 return (CMDBField<TYPE>&)CMDBNumFieldBase::operator=((TInt&)aValue); |
987 } |
981 } |
992 return (CMDBField<TYPE>&)CMDBNumFieldBase::operator=(aValue); |
986 return (CMDBField<TYPE>&)CMDBNumFieldBase::operator=(aValue); |
993 } |
987 } |
994 |
988 |
995 /** |
989 /** |
996 Conversion operator for field value |
990 Conversion operator for field value |
997 |
|
998 @publishedAll |
|
999 */ |
991 */ |
1000 inline operator TYPE&() |
992 inline operator TYPE&() |
1001 { |
993 { |
1002 return (TYPE&)iValue; |
994 return (TYPE&)iValue; |
1003 } |
995 } |
1004 |
996 |
1005 /** |
997 /** |
1006 Conversion operator for field value |
998 Conversion operator for field value |
1007 |
|
1008 @publishedAll |
|
1009 */ |
999 */ |
1010 inline CMDBField<TYPE>& GetL() |
1000 inline CMDBField<TYPE>& GetL() |
1011 { |
1001 { |
1012 if(IsNull() && !(ElementId() & KCDChangedFlag)) |
1002 if(IsNull() && !(ElementId() & KCDChangedFlag)) |
1013 { |
1003 { |
1017 return (TYPE&)iValue; |
1007 return (TYPE&)iValue; |
1018 } |
1008 } |
1019 |
1009 |
1020 /** |
1010 /** |
1021 Function for setting a value |
1011 Function for setting a value |
1022 |
|
1023 @publishedAll |
|
1024 */ |
1012 */ |
1025 inline void SetL(const TYPE& aValue) |
1013 inline void SetL(const TYPE& aValue) |
1026 { |
1014 { |
1027 CMDBNumFieldBase::operator=(aValue); |
1015 CMDBNumFieldBase::operator=(aValue); |
1028 } |
1016 } |
1029 |
1017 |
1030 }; |
1018 }; |
1031 |
1019 |
1032 |
1020 |
1033 |
1021 |
1034 ////////////////// |
1022 // |
1035 /** |
1023 /** |
1036 Base Container class qualifying a text field |
1024 Base Container class qualifying a text field |
1037 @internalComponent |
1025 @publishedAll |
1038 */ |
1026 */ |
1039 class CMDBTextFieldBase : public CMDBElement |
1027 class CMDBTextFieldBase : public CMDBElement |
1040 { |
1028 { |
1041 public: |
1029 public: |
1042 /** |
1030 /** |
1339 Conversion operator for field value |
1311 Conversion operator for field value |
1340 which gets the id of the element list |
1312 which gets the id of the element list |
1341 */ |
1313 */ |
1342 IMPORT_C operator TMDBElementId(); |
1314 IMPORT_C operator TMDBElementId(); |
1343 |
1315 |
|
1316 |
|
1317 protected: |
|
1318 |
|
1319 EXP_DATA_VTABLE |
|
1320 |
|
1321 private: |
1344 TCDFieldValueTypes Type() |
1322 TCDFieldValueTypes Type() |
1345 { |
1323 { |
1346 return ELink; |
1324 return ELink; |
1347 } |
1325 } |
1348 |
|
1349 protected: |
|
1350 |
|
1351 EXP_DATA_VTABLE |
|
1352 |
|
1353 public: |
1326 public: |
1354 |
1327 |
1355 // the record referenced by the link id stored in the value of this field. |
1328 // the record referenced by the link id stored in the value of this field. |
1356 CMDBElement* iLinkedRecord; |
1329 CMDBElement* iLinkedRecord; |
1357 |
1330 |
1366 The value of a CMDBRecordLink field as stored in the database is the |
1339 The value of a CMDBRecordLink field as stored in the database is the |
1367 ElementId (<Table><Record>) of the linked record. |
1340 ElementId (<Table><Record>) of the linked record. |
1368 |
1341 |
1369 The linked record itself can be viewed via the iLinkedRecord member and its accessors |
1342 The linked record itself can be viewed via the iLinkedRecord member and its accessors |
1370 |
1343 |
1371 iLinkedRecord must be created explicitly by the client - either on construction, |
1344 If a record is loaded then the iLinkedRecord must be created explicitly |
1372 or by use of the CreateLinkL or SetLinkL functions. Often the linked record is not |
1345 by the client - either on construction, or by use of the CreateLinkL or |
1373 required by a caller. So creating it automatically would just waste memory |
1346 SetLinkL functions. Often the linked record is not required by a caller. |
|
1347 So creating it automatically would just waste memory |
|
1348 |
|
1349 However in the case of an explicit load of a LinkedRecord field the ILinkedRecord |
|
1350 is created. |
1374 |
1351 |
1375 When instantiating iLinkedRecord directly take care to match the object's type to the Type |
1352 When instantiating iLinkedRecord directly take care to match the object's type to the Type |
1376 ID that will be found at the linking element. It is better to use the CreateLinkL or |
1353 ID that will be found at the linking element. It is better to use the CreateLinkL or |
1377 SetLinkL functions to ensure type safety |
1354 SetLinkL functions to ensure type safety |
1378 |
1355 |
1383 */ |
1360 */ |
1384 { |
1361 { |
1385 public : |
1362 public : |
1386 /** |
1363 /** |
1387 Constructor/Destructor |
1364 Constructor/Destructor |
1388 |
|
1389 @publishedAll |
|
1390 */ |
1365 */ |
1391 |
1366 |
1392 inline CMDBRecordLink() |
1367 inline CMDBRecordLink() |
1393 : CMDBRecordLinkBase() {} |
1368 : CMDBRecordLinkBase() {} |
1394 |
1369 |
1395 /** |
1370 /** |
1396 Constructor |
1371 Constructor |
1397 |
|
1398 @publishedAll |
|
1399 */ |
1372 */ |
1400 inline CMDBRecordLink(TMDBElementId aLinkingFieldId) |
1373 inline CMDBRecordLink(TMDBElementId aLinkingFieldId) |
1401 : CMDBRecordLinkBase(aLinkingFieldId) {} |
1374 : CMDBRecordLinkBase(aLinkingFieldId) {} |
1402 |
1375 |
1403 /** |
1376 /** |
1404 Constructor |
1377 Constructor |
1405 |
|
1406 @publishedAll |
|
1407 */ |
1378 */ |
1408 inline CMDBRecordLink(TMDBElementId aLinkingFieldId, RECORD_TYPE* aLinkedRecord) |
1379 inline CMDBRecordLink(TMDBElementId aLinkingFieldId, RECORD_TYPE* aLinkedRecord) |
1409 : CMDBRecordLinkBase(aLinkingFieldId, (CMDBElement*)aLinkedRecord) {} |
1380 : CMDBRecordLinkBase(aLinkingFieldId, (CMDBElement*)aLinkedRecord) {} |
1410 |
1381 |
1411 /** |
|
1412 @publishedAll |
|
1413 */ |
|
1414 inline CMDBRecordLink& operator=(const TMDBElementId aValue) |
1382 inline CMDBRecordLink& operator=(const TMDBElementId aValue) |
1415 { |
1383 { |
1416 return (CMDBRecordLink&)CMDBRecordLinkBase::operator=(aValue); |
1384 return (CMDBRecordLink&)CMDBRecordLinkBase::operator=(aValue); |
1417 } |
1385 } |
1418 |
1386 |
1419 |
1387 |
1420 // SETTERS |
1388 // SETTERS |
1421 |
1389 |
1422 /** |
1390 /** |
1423 Set the field value (this will be validated on StoreL) |
1391 Set the field value (this will be validated on StoreL) |
1424 |
|
1425 @publishedAll |
|
1426 */ |
1392 */ |
1427 inline void SetL(const TMDBElementId aValue) |
1393 inline void SetL(const TMDBElementId aValue) |
1428 { |
1394 { |
1429 CMDBRecordLinkBase::operator=(aValue); |
1395 CMDBRecordLinkBase::operator=(aValue); |
1430 } |
1396 } |
1445 }; |
1409 }; |
1446 |
1410 |
1447 enum TFieldTypeAttributes |
1411 enum TFieldTypeAttributes |
1448 /** |
1412 /** |
1449 To express type information for all MetaDatabase fields |
1413 To express type information for all MetaDatabase fields |
1450 @publishedAll |
1414 */ |
1451 @released |
1415 { |
1452 */ |
1416 ENoAttrs, //< No attributes associated with this field. |
1453 { |
1417 ENotNull, //< Ensures the field contains a value and must not be null. |
1454 ENoAttrs, ///< No attributes associated with this field. |
|
1455 ENotNull, ///< Ensures the field contains a value and must not be null. |
|
1456 }; |
1418 }; |
1457 |
1419 |
1458 typedef struct |
1420 typedef struct |
1459 /** |
1421 /** |
1460 To express type information for all MetaDatabase fields |
1422 To express type information for all MetaDatabase fields |
1461 @publishedAll |
1423 */ |
1462 @released |
1424 { |
1463 */ |
1425 const TMDBElementId iTypeId; //< Identifier for the field. |
1464 { |
1426 const TInt iValType; //< The field type value e.g.EText, EMedText. |
1465 const TMDBElementId iTypeId; ///< Identifier for the field. |
1427 const TFieldTypeAttributes iTypeAttr; //< The field attribute, either ENoAttrs or ENotNull. |
1466 const TInt iValType; ///< The field type value e.g.EText, EMedText. |
1428 const TText * const iTypeName; //< Name of the field type. |
1467 const TFieldTypeAttributes iTypeAttr; ///< The field attribute, either ENoAttrs or ENotNull. |
|
1468 const TText * const iTypeName; ///< Name of the field type. |
|
1469 |
1429 |
1470 } SRecordTypeInfo; |
1430 } SRecordTypeInfo; |
1471 |
1431 |
1472 |
1432 |
1473 #define MDB_GENERIC_TYPE_INFO(a, b, c, d) SGenericRecordTypeInfo(a, b, c, d) |
1433 #define MDB_GENERIC_TYPE_INFO(a, b, c, d) SGenericRecordTypeInfo(a, b, c, d) |
1475 typedef TBuf<64> TGenericTypeName; |
1435 typedef TBuf<64> TGenericTypeName; |
1476 |
1436 |
1477 typedef struct SGenericRecordTypeInfoTag |
1437 typedef struct SGenericRecordTypeInfoTag |
1478 /** |
1438 /** |
1479 To express type information for all MetaDatabase fields |
1439 To express type information for all MetaDatabase fields |
1480 @publishedAll |
|
1481 @released |
|
1482 */ |
1440 */ |
1483 { |
1441 { |
1484 SGenericRecordTypeInfoTag() |
1442 SGenericRecordTypeInfoTag() |
1485 : iTypeId(0), iValType(0), iTypeAttr(ENoAttrs) {} |
1443 : iTypeId(0), iValType(0), iTypeAttr(ENoAttrs) {} |
1486 |
1444 |
1506 TFieldTypeAttributes aAttrType, |
1464 TFieldTypeAttributes aAttrType, |
1507 const TGenericTypeName& aTypeName) |
1465 const TGenericTypeName& aTypeName) |
1508 : iTypeId(aId), iValType(aVal), iTypeAttr(aAttrType), iTypeName(aTypeName) {} |
1466 : iTypeId(aId), iValType(aVal), iTypeAttr(aAttrType), iTypeName(aTypeName) {} |
1509 |
1467 |
1510 |
1468 |
1511 TMDBElementId iTypeId; ///< Identifier for the field type. |
1469 TMDBElementId iTypeId; //< Identifier for the field type. |
1512 TInt iValType; ///< The field type value e.g.EText, EMedText. |
1470 TInt iValType; //< The field type value e.g.EText, EMedText. |
1513 TFieldTypeAttributes iTypeAttr; ///< The type's attribute, either ENoAttrs or ENotNull |
1471 TFieldTypeAttributes iTypeAttr; //< The type's attribute, either ENoAttrs or ENotNull |
1514 TGenericTypeName iTypeName; ///< Name of the field type. |
1472 TGenericTypeName iTypeName; //< Name of the field type. |
1515 } SGenericRecordTypeInfo; |
1473 } SGenericRecordTypeInfo; |
1516 |
1474 |
1517 |
1475 |
1518 |
1476 |
1519 class CMDBRecordBase : public CMDBNumFieldBase |
1477 class CMDBRecordBase : public CMDBNumFieldBase |
1598 @publishedAll |
1556 @publishedAll |
1599 @released |
1557 @released |
1600 */ |
1558 */ |
1601 { |
1559 { |
1602 public: |
1560 public: |
1603 /** |
|
1604 @internalComponent |
|
1605 */ |
|
1606 IMPORT_C CMDBRecordSetBase(); |
1561 IMPORT_C CMDBRecordSetBase(); |
1607 |
1562 |
1608 /** |
|
1609 @internalComponent |
|
1610 */ |
|
1611 IMPORT_C CMDBRecordSetBase(TMDBElementId aElementId); |
1563 IMPORT_C CMDBRecordSetBase(TMDBElementId aElementId); |
1612 |
1564 |
1613 /** |
|
1614 @internalComponent |
|
1615 */ |
|
1616 IMPORT_C ~CMDBRecordSetBase(); |
1565 IMPORT_C ~CMDBRecordSetBase(); |
1617 |
1566 |
1618 inline CMDBRecordSetBase& operator=(const TPtrC& aValue) |
1567 inline CMDBRecordSetBase& operator=(const TPtrC& aValue) |
1619 { |
1568 { |
1620 return (CMDBRecordSetBase&)CMDBTextFieldBase::operator=(aValue); |
1569 return (CMDBRecordSetBase&)CMDBTextFieldBase::operator=(aValue); |