1 // Copyright (c) 2004-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 the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // Meta-database declarations for use in storing comms data
27 #if (!defined METADATABASE_H)
28 #define METADATABASE_H
33 #include <comms-infras/metadata.h>
34 #include <comms-infras/metatype.h>
45 1/ Class for expressing a session with the storage server
49 This class contains functions to create and close a session, to set the dataset version
50 and to request database actions such as locking for a transaction.
52 2/ Generic database functionality interface
56 This class uses a CMDBSession object
59 3/ General base class that inherits from MMetaDatabase to express any database element
63 This class contains the ElementId for each MetaDatabase object
64 An element id locates stored data in the comms database.
67 4/ Data classes that each inherit from CMDBElement
73 where T is a basic type value of the field (TInt, TDes, TBool etc)
75 This class derives from
79 to implement the thin template idiom
84 where T is a record of a particular type. This class expresses a soft-link
85 from a field in one record to a record of a different type (i.e. in another table).
86 The TMDBElementId value stored in this field in the repository is the id of an instance
87 of the record of type T
89 This class derives from
93 to implement the thin template idiom
101 base class for record containing specific list of fields - see CommsDatTypesv1_1.h
106 an array of records where T is the record type. This can represent a Table in a database.
111 5/ Other support classes and type definitions
115 The TMDBElementId locates a data object or set of data objects in the database.
117 A TMDBElementId expresses
119 <TableId><ColumnId><RecordId><Attributes>
121 A TMDBElementId has a different format depending on the data type it expresses
123 Table <TableId><0><0>
124 Column <TableId><ColumnId><0>
126 Record <TableId><0><RecordId>
127 Field <TAbleId><ColumnId><RecordId>
132 Attribute settings for any storable element.
133 Attributes express access control for data in the database
142 using namespace Meta;
145 // Private to implementation
146 //@internalTechnology
148 class CMDBSessionImpl;
150 // Forward declarations
155 Attribute flags for an element in the Meta Database
156 Attributes describe access rights to the data in the database
160 typedef TUint32 TMDBAttributeFlags;
164 The identifier for any entry in the MetaDatabase.
166 <TableId><ColumnId><RecordId>
168 The data location in the database
169 The meaning of the data within in the data schema
175 typedef TUint32 TMDBElementId;
177 class CMDBSession : public CBase
179 A session with the underlying storage server
187 Open a session with the storage server and establish data format version in use
188 CommsDat always attempts to support the required version of the client-facing data set.
189 The client must carefully choose the dataset version as it affects binary compatibility
191 @params aRequiredVersion
192 If the requested version is deprecated but still supported, mapping will be performed
193 within CommsDat to maintain Data and Binary compatibility for the client
194 If the requested version is the latest version, no mapping will be performed
195 and deprecated fields will be ignored
196 A client that needs to maintain BC must use a specific version
197 A client that always wants to use the latest dataset can start the session with KCDLatestVersion
199 @leave KErrUnsupported If an old unsupported version is requested
200 @leave System-wide error codes if there is an unexpected error
203 @post on success a session has been created and initialised
207 IMPORT_C static CMDBSession* NewL(TVersion aRequiredVersion);
210 As NewL and adds Session to the CleanupStack
214 IMPORT_C static CMDBSession* NewLC(TVersion aRequiredVersion);
221 IMPORT_C ~CMDBSession();
225 Close session with storage server.
228 @deprecated v9.1 Destructor is all that is required
230 IMPORT_C void Close();
234 Lookup latest data format version
240 IMPORT_C static TVersion LatestVersion();
244 Lookup data format version currently in use by client
248 IMPORT_C TVersion VersionInUse();
252 Open Transaction with storage server and obtain write lock - if not already set
254 @capability WriteDeviceData
256 @leave Will leave with KErrNotAvailable if Database write locked by another process
257 @leave Will report KErrAlreadyInTransaction if transaction this session is already in a transaction
258 @leave Will leave with a system-wide error code if an error occurs during commit
261 @post on success the session has exclusive write access to the database
265 IMPORT_C void OpenTransactionL();
269 Commit Transaction in database.
271 @leave Will leave with KErrNotFound if not in transaction
272 @leave Will leave with a system-wide error code if an error occurs during commit
276 @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
280 IMPORT_C void CommitTransactionL();
284 Cancel Transaction with database and rollback all associated changes
285 Will not make any changes to the client's containers
287 @leave Will fail with KErrNotFound if not in transaction
289 @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
293 IMPORT_C void RollbackTransactionL();
296 Query if this session is in a transaction with the database
297 Return code will indicate
299 Already in transaction for this session,
300 Write-lock not available. Another session has it.
305 IMPORT_C TInt IsInTransaction();
309 Set attributes to ignore for all database operations during this session
311 @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,
313 providing the client has enough platform security capabilities to back up the request
318 IMPORT_C void SetAttributeMask(TMDBAttributeFlags aAttributeFlags);
322 Check flags in attribute mask
323 @params aAttributeFlags indicates the requested access level to stored data
324 Attribute flags that have been set will be ignored as restrictions in all database interactions,
325 providing the client has enough platform security capabilities to back up the request
327 @return ETrue if the flag is set in the session mask
328 This means that the attribute is ignored in database interactions for this session
330 @return EFalse if the flag is not set in the session mask
331 This means that the attribute is obeyed in all database interactions for this session
336 IMPORT_C TBool IsSetAttributeMask(TMDBAttributeFlags aAttributeFlags);
340 Clear attribute mask settings, indicating required access level to stored data
341 Clear flags in the attribute mask for this session
343 Flags indicate the requested access level to stored data
345 Attribute flags that have been set in this function will be cleared from the session's
346 attribute mask and will be obeyed as restrictions in all database interactions,
347 providing the client has enough platform security capabilities to back up the request
353 IMPORT_C void ClearAttributeMask(TMDBAttributeFlags aAttributeFlags);
358 Cancel all notification requests that are outstanding from calls to
359 MMetaDatabase::RequestNotification
360 Individual requests can be cancelled via MMetaDatabase::CancelNotify.
362 @return KErrNone on success or a system-wide error code
368 IMPORT_C TInt CancelAllNotifications();
372 Attempt to create publish/subscribe properties if not already defined.
374 This function is normally called as a setup activity by System components
376 @capability WriteDeviceData - since these properties are created in KUidSystemCategory category.
378 @return KErrNone on success. Otherwise a system-wide error code
384 IMPORT_C TInt PublishProperties();
388 TInt ConstructL( TVersion aRequiredVersion );
394 CMDBSessionImpl* iMDBSessionImpl;
396 friend class MMetaDatabase;
403 class MMetaDatabase : public Meta::MMetaData
405 Interface for interaction with a database server
406 Inherited by each data set type that can be stored
412 IMPORT_C virtual ~MMetaDatabase();
416 LoadL - Load this container with data from the database
418 Any data in the container will be discarded
420 Individual fields may legitimately be NULL in the database, but if no data at all
421 is found for an entire table or record, LoadL will leave with
424 The client can request to ignore access control flags by setting the attribute mask
425 CMDBSession::SetAttributeMask()
426 However, only fields that the client has capabilities to write will be stored in the database
427 A request to read data from an unauthorised area of the database will cause the function to leave.with
430 In a record, fields in an unauthorised column may be silently ignored and returned as NULL
432 May also leave with KErrNoMemory or other general error codes
434 On failure, the container should be discarded or reloaded before it is used again
438 Ensure the ElementId for this container fully identifies the target data in the database
439 <Table><Column><Record>
440 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
445 IMPORT_C void LoadL(CMDBSession& aSession);
449 FindL - Find and Load the data set(s) that match all the data values entered by the
450 client in this container
452 Client can request to ignore access control flags by setting the attribute mask,
453 CMDBSession::SetAttributeMask()
454 However will not load data that the client is not authorised to see (by platsec)
455 even if the client has sets the appropriate attribute mask
459 EFalse if no data found that the client is authorised to view
461 May also leave with KErrGeneral or other general error codes.
463 On failure, the container should be discarded or repopulated before it is used again
467 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
470 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
474 IMPORT_C TBool FindL(CMDBSession& aSession);
478 Refresh all fields in the container that have not been changed by the client
480 The client can request to ignore access control flags by setting the attribute mask,
481 CMDBSession::SetAttributeMask()
482 However, only data that the client has capabilities to view will be loaded
483 Unauthorised data elements will be silently ignored and will remain NULL
485 If no data at all is found the functon will leave with
488 If fields are not accessible for reading the function may leave with
491 May also leave with other general error codes if there are unexpected
492 problems (e.g. KErrNoMemory when out of memory)
494 On failure, the container should be discarded or reloaded before it is used again
498 Ensure the ElementId for this container fully identifies the target data in the database
499 <Table><Column><Record>
500 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
504 IMPORT_C void RefreshL(CMDBSession& aSession);
508 StoreL - Store all fields in the database that have been changed in this container and
509 create new records where necessary.
511 StoreL is atomic for this container. An internal transaction is used even if
512 no overall transaction is set by client.
513 All changed fields in the element are stored in the database on success.
514 No fields or records are stored in the database if the function leaves
516 If a client has an open transaction in the session, the stored data will be available to this session as
517 soon as StoreL completes but will not be visible to other sessions until the transaction completes successfully
519 The client can request to ignore access control flags by setting the attribute mask
520 CMDBSession::SetAttributeMask()
521 However, only fields that the client has capabilities to write will be stored in the database
522 A request to modify data in an unauthorised area of the database will cause the function to leave.with
525 If a field already exists, StoreL will leave with
528 May also leave with other general error codes if there are unexpected
529 problems (e.g. KErrNoMemory when out of memory)
532 If StoreL fails or the later commit is not successful, The data in the container will not
533 match the data in the database.
535 On failure, the container should be discarded or repopulated before it is used again
539 Populate this container with valid data for storage
540 Ensure the ElementId for this container fully identifies the target location in the database
541 <Table><Column><Record>
542 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
547 IMPORT_C void StoreL(CMDBSession& aSession);
551 Modify all fields in the database that have been changed in this container by the caller
553 Only modifies existing data in the database, won't create new fields VCT - is this true?? don't think so
555 Modification is atomic for this container. It uses an internal transaction even if
556 no overall transaction set by client.
557 All changed fields in the element are modified in database on success.
558 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
561 CMDBSession::SetAttributeMask()
562 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
566 If field does not exist, the function will leave with
567 KErrNotFound [VCT - surely not]
569 May also leave with other general error codes if there are unexpected
570 problems (e.g. KErrNoMemory when out of memory)
572 On failure, the container should be discarded or repopulated before it is used again
576 Populate this container with valid data for storage
577 Ensure the ElementId for this container fully identifies the target data in the database
578 <Table><Column><Record>
579 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
583 IMPORT_C void ModifyL(CMDBSession& aSession);
587 Delete fields from the database.
589 Client can request to ignore access control flags by setting the attribute mask,
590 but only fields that the client has capabilities to delete will be removed.
592 A request to delete data in unauthorised area will cause the function to leave
594 @leave If client not authorised to read or write the data, will leave with
596 May also leave with other general error codes if there are unexpected
597 problems (e.g. KErrNoMemory when out of memory)
599 @pre Ensure the ElementId for this container fully identifies the target data in the database
600 <Table><Column><Record>
601 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
606 IMPORT_C void DeleteL(CMDBSession& aSession);
610 RequestNotification - Register for notification of events from all clients of the database
612 aRequestStatus will be completed when the following events occur
617 this aRequestStatus can be cancelled by a call to
619 MMetaDatabase::CancelNotification
621 all outstanding aRequestStatus can be cancelled by a call to
623 CMDBSession::CancelAllNotifications
625 @capability WriteDeviceData
627 @return KErrNone on success. A system wide error on failure
629 @params aSession a valid session object
630 @params aRequestStatus the requestStatus object that will be completed on notification
633 @post A notification request will be outstanding
637 IMPORT_C TInt RequestNotification(CMDBSession& aSession,
638 TRequestStatus& aRequestStatus);
641 CancelNotification - cancel an outstanding notification request
643 note that all outstanding notification requests can be cancelled by a call to
645 CMDBSession::CancelAllNotifications
649 There is an outstanding notification request
653 IMPORT_C TInt CancelNotification(CMDBSession& aSession,
654 TRequestStatus& aRequestStatus);
660 explicit MMetaDatabase();
667 void DoLoadL(CMDBSessionImpl* aSession, CMDBElement* aElement, CMDBElement* aMapper, TInt& aErr, TMDBElementId aRecordId, TMDBElementId aAttributes);
672 void DoLoadL(CMDBSessionImpl* aSession, CMDBElement* aElement, CMDBElement* aMapper, TInt& aErr, TMDBElementId aRecordId, TMDBElementId aAttributes, RArray<TUint32>& aMatches);
677 void DoFindL(CMDBSessionImpl* aSession, CMDBElement* aElement, CMDBElement* aMapper, TInt& aErr, RArray<TUint32>& candidates, RArray<TUint32>& matches);
682 void DoRefreshL(CMDBSessionImpl* aSession, CMDBElement* aElement, CMDBElement* aMapper, TInt &aErr);
687 void DoStoreL(CMDBSessionImpl* aSession, CMDBElement* aElement, CMDBElement* aMapper, TInt &aErr);
692 void DoModifyL(CMDBSessionImpl* aSession, CMDBElement* aElement, CMDBElement* aMapper, TInt &aErr);
700 class CMDBElement : public CBase, public MMetaDatabase
702 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
704 and for individual fields it also contains the value.
718 IMPORT_C CMDBElement();
726 IMPORT_C CMDBElement(TMDBElementId aElementId);
734 IMPORT_C ~CMDBElement();
740 Returns the ElementId of an object of this type.
744 <TableId><ColumnId><RecordId>
746 This identifies the meaning of the field in the database schema
747 It also identifies the type of the data stored in this element
748 and the instance of the type
752 IMPORT_C TMDBElementId ElementId() const;
756 Returns the TypeId of an object of this type.
760 <TableId><ColumnId><x>
762 This identifies the meaning of the data in this element in the database schema
763 It also identifies the type of the data contained in this element
765 For an element that is a Table or a Record, the ColumnId field will be set to
770 IMPORT_C TMDBElementId TypeId() const;
774 Returns the TableId of an object of this type.
776 The TableId is part of the ElementId
780 It identifies the table in the database that holds the data contained in this element
784 IMPORT_C TMDBElementId TableId() const;
788 Returns the RecordId of an object of this type.
790 The RecordId is part of the ElementId <x><x><RecordId>
792 It identifies a particular instance of this type of Element in the database
796 IMPORT_C TInt RecordId() const;
800 Returns the Attributes of an object of this type.
802 Attributes express database access rights for the data of this element
806 IMPORT_C TMDBAttributeFlags Attributes() const;
815 IMPORT_C void SetElementId(TMDBElementId aElementId);
823 IMPORT_C void SetTypeId(TMDBElementId aElementId);
831 IMPORT_C void SetRecordId(TInt aRecordId);
835 Sets one or more attributes
839 IMPORT_C void SetAttributes(TMDBAttributeFlags aAttributes);
843 Clears one or more attributes
847 IMPORT_C void ClearAttributes(TMDBAttributeFlags aAttributes);
851 Queries the attributes
853 Returns ETrue if all queried attributes are set
854 Returns EFalse if any queried attribute is not set.
858 IMPORT_C TBool IsSetAttribute(TMDBAttributeFlags aAttributes) const;
862 Queries the state of the field value
864 Returns ETrue if the value of the element is not set
865 Returns EFalse if the element contains a value
869 IMPORT_C TBool IsNull() const;
876 Queries the type of the field value
878 Returns the enumeration TCDFieldValueTypes that represents the value that can be stored in this element
883 virtual TCDFieldValueTypes Type()=0;
888 TMDBElementId* Data(){return &iElementId;}
893 const TMDBElementId* CData(){return &iElementId;}
899 TMDBElementId iElementId;
908 ///////////////////////////////////////////////////////////////////////////////////////
909 // COMMSDAT CONTAINERS
913 Commsdat Container classes qualifying numeric values
916 class CMDBNumFieldBase : public CMDBElement
922 IMPORT_C CMDBNumFieldBase();
926 Constructor setting Field's ElementId
928 IMPORT_C CMDBNumFieldBase(TMDBElementId aFieldId);
932 Assignment operator for field value
934 IMPORT_C CMDBNumFieldBase& operator=(const TInt aValue);
936 IMPORT_C void SetMaxLengthL(TInt aLength);
937 TMDBElementId GetL();
941 virtual TCDFieldValueTypes Type()
949 class CMDBField : public CMDBNumFieldBase
951 A thin template that guards typed data access in a single CMDBElement
952 This class describes a single numeric field in the database
969 Constructor setting Field's ElementId
973 inline CMDBField(TMDBElementId aFieldId)
974 : CMDBNumFieldBase(aFieldId)
980 Assignment operator for field value
984 inline CMDBField<TYPE>& operator=(const TYPE& aValue)
986 return (CMDBField<TYPE>&)CMDBNumFieldBase::operator=((TInt&)aValue);
990 inline CMDBField<TYPE>& operator=(const CMDBField<TYPE>& aValue)
992 return (CMDBField<TYPE>&)CMDBNumFieldBase::operator=(aValue);
996 Conversion operator for field value
1000 inline operator TYPE&()
1002 return (TYPE&)iValue;
1006 Conversion operator for field value
1010 inline CMDBField<TYPE>& GetL()
1012 if(IsNull() && !(ElementId() & KCDChangedFlag))
1014 User::Leave(KErrNotFound); //todo commsdat specific error code
1017 return (TYPE&)iValue;
1021 Function for setting a value
1025 inline void SetL(const TYPE& aValue)
1027 CMDBNumFieldBase::operator=(aValue);
1036 Base Container class qualifying a text field
1039 class CMDBTextFieldBase : public CMDBElement
1045 IMPORT_C CMDBTextFieldBase();
1048 Constructor setting Field's ElementId
1050 IMPORT_C CMDBTextFieldBase(TMDBElementId aFieldId);
1054 Destructor that deletes the field value
1056 IMPORT_C ~CMDBTextFieldBase();
1060 Assignment Operator setting Field's value
1062 IMPORT_C CMDBTextFieldBase& operator=(const TDesC& aValue);
1065 IMPORT_C void SetMaxLengthL(TInt aLength);
1069 virtual TCDFieldValueTypes Type()
1083 class CMDBField<TDesC> : public CMDBTextFieldBase
1085 A thin template that guards typed data access in a single CMDBElement
1086 This class describes a single field in the database
1103 Constructor setting Field's ElementId
1107 inline CMDBField(TMDBElementId aFieldId)
1108 : CMDBTextFieldBase(aFieldId)
1113 inline void SetMaxLengthL(TInt aLength)
1114 // create a new buffer if necessary.
1116 CMDBTextFieldBase::SetMaxLengthL(aLength);
1119 inline CMDBField<TDesC>& operator=(const TDesC& aValue)
1121 CMDBTextFieldBase::operator=(aValue);
1125 inline CMDBField<TDesC>& operator=(CMDBField<TDesC>& aValue)
1127 CMDBTextFieldBase::operator=((const TDesC&)aValue);
1132 Conversion operator for field value
1136 inline operator const TDesC&()
1141 return *(HBufC*)iValue;
1145 Conversion operator for field value
1149 inline TDesC& GetL()
1151 if(IsNull() && !(ElementId() & KCDChangedFlag))
1153 User::Leave(KErrNotFound); //todo commsdat specific error code
1156 return *(HBufC*)iValue;
1160 Function for setting a value
1164 inline void SetL(const TDesC& aValue)
1166 SetMaxLengthL(aValue.Length());
1167 CMDBTextFieldBase::operator=(aValue);
1176 Container class for qualifying binary values
1179 class CMDBBinFieldBase : public CMDBElement
1185 IMPORT_C CMDBBinFieldBase();
1189 Constructor setting Field's ElementId
1191 IMPORT_C CMDBBinFieldBase(TMDBElementId aFieldId);
1195 Destructor that deletes the field value
1197 IMPORT_C ~CMDBBinFieldBase();
1201 Assignment Operator setting Field's value
1203 IMPORT_C CMDBBinFieldBase& operator=(const TDesC8& aValue);
1206 To allocate space for field data.
1208 IMPORT_C void SetMaxLengthL(TInt aLength);
1212 virtual TCDFieldValueTypes Type()
1220 class CMDBField<TDesC8> : public CMDBBinFieldBase
1222 A thin template that guards typed data access in a single CMDBElement
1223 This class describes a single field in the database
1240 Constructor setting Field's ElementId
1244 inline CMDBField(TMDBElementId aFieldId)
1245 : CMDBBinFieldBase(aFieldId)
1249 inline void SetMaxLengthL(TInt aLength)
1250 // create a new buffer if necessary.
1252 CMDBBinFieldBase::SetMaxLengthL(aLength);
1256 inline CMDBField<TDesC8>& operator=(const TDesC8& aValue)
1258 return (CMDBField<TDesC8>&)CMDBBinFieldBase::operator=(aValue);
1262 inline CMDBField<TDesC8>& operator=(CMDBField<TDesC8>& aValue)
1265 return (CMDBField<TDesC8>&)CMDBBinFieldBase::operator=((const TDesC8&)aValue);
1270 Conversion operator for field value
1274 inline operator const TDesC8&()
1279 return *(HBufC8*)iValue;
1283 Conversion operator for field value
1287 inline TDesC8& GetL()
1289 if(IsNull() && !(ElementId() & KCDChangedFlag))
1291 User::Leave(KErrNotFound); //todo commsdat specific error code
1294 return *(HBufC8*)iValue;
1298 Function for setting a value
1302 inline void SetL(const TDesC8& aValue)
1304 SetMaxLengthL(aValue.Length());
1305 CMDBBinFieldBase::operator=(aValue);
1312 ///////////////////////////////////////////////////////////////////////////////////////////////
1315 Base class for CMDBRecordLink
1318 class CMDBRecordLinkBase : public CMDBNumFieldBase
1322 IMPORT_C CMDBRecordLinkBase();
1324 IMPORT_C CMDBRecordLinkBase(TMDBElementId aLinkingFieldId);
1326 IMPORT_C CMDBRecordLinkBase(TMDBElementId aLinkingFieldId, CMDBElement* aLinkedRecord);
1329 IMPORT_C ~CMDBRecordLinkBase();
1332 Assignment operator for field value
1333 which sets the id of the element list
1335 IMPORT_C CMDBRecordLinkBase& operator=(const TMDBElementId aValue);
1339 Conversion operator for field value
1340 which gets the id of the element list
1342 IMPORT_C operator TMDBElementId();
1344 TCDFieldValueTypes Type()
1355 // the record referenced by the link id stored in the value of this field.
1356 CMDBElement* iLinkedRecord;
1361 template<class RECORD_TYPE>
1362 class CMDBRecordLink : public CMDBRecordLinkBase
1364 This container expresses a 'soft-link' to a record in another table.
1366 The value of a CMDBRecordLink field as stored in the database is the
1367 ElementId (<Table><Record>) of the linked record.
1369 The linked record itself can be viewed via the iLinkedRecord member and its accessors
1371 iLinkedRecord must be created explicitly by the client - either on construction,
1372 or by use of the CreateLinkL or SetLinkL functions. Often the linked record is not
1373 required by a caller. So creating it automatically would just waste memory
1375 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
1377 SetLinkL functions to ensure type safety
1379 Calling MMetaDatabase functions on a CMDRecordLink field directly will perform the operation
1380 on the field and also the linked record if it is present
1387 Constructor/Destructor
1392 inline CMDBRecordLink()
1393 : CMDBRecordLinkBase() {}
1400 inline CMDBRecordLink(TMDBElementId aLinkingFieldId)
1401 : CMDBRecordLinkBase(aLinkingFieldId) {}
1408 inline CMDBRecordLink(TMDBElementId aLinkingFieldId, RECORD_TYPE* aLinkedRecord)
1409 : CMDBRecordLinkBase(aLinkingFieldId, (CMDBElement*)aLinkedRecord) {}
1414 inline CMDBRecordLink& operator=(const TMDBElementId aValue)
1416 return (CMDBRecordLink&)CMDBRecordLinkBase::operator=(aValue);
1423 Set the field value (this will be validated on StoreL)
1427 inline void SetL(const TMDBElementId aValue)
1429 CMDBRecordLinkBase::operator=(aValue);
1436 conversion operator for linked record of this type
1440 inline operator RECORD_TYPE*()
1442 return static_cast<RECORD_TYPE*>(iLinkedRecord);
1447 enum TFieldTypeAttributes
1449 To express type information for all MetaDatabase fields
1454 ENoAttrs, ///< No attributes associated with this field.
1455 ENotNull, ///< Ensures the field contains a value and must not be null.
1460 To express type information for all MetaDatabase fields
1465 const TMDBElementId iTypeId; ///< Identifier for the field.
1466 const TInt iValType; ///< The field type value e.g.EText, EMedText.
1467 const TFieldTypeAttributes iTypeAttr; ///< The field attribute, either ENoAttrs or ENotNull.
1468 const TText * const iTypeName; ///< Name of the field type.
1473 #define MDB_GENERIC_TYPE_INFO(a, b, c, d) SGenericRecordTypeInfo(a, b, c, d)
1475 typedef TBuf<64> TGenericTypeName;
1477 typedef struct SGenericRecordTypeInfoTag
1479 To express type information for all MetaDatabase fields
1484 SGenericRecordTypeInfoTag()
1485 : iTypeId(0), iValType(0), iTypeAttr(ENoAttrs) {}
1487 SGenericRecordTypeInfoTag(TMDBElementId aId,
1489 TFieldTypeAttributes aAttrType)
1490 : iTypeId(aId), iValType(aVal), iTypeAttr(aAttrType)
1494 SGenericRecordTypeInfoTag(TMDBElementId aId,
1496 TFieldTypeAttributes aAttrType,
1497 TText * const aTypeName)
1498 : iTypeId(aId), iValType(aVal), iTypeAttr(aAttrType), iTypeName(aTypeName)
1504 SGenericRecordTypeInfoTag( TMDBElementId aId,
1506 TFieldTypeAttributes aAttrType,
1507 const TGenericTypeName& aTypeName)
1508 : iTypeId(aId), iValType(aVal), iTypeAttr(aAttrType), iTypeName(aTypeName) {}
1511 TMDBElementId iTypeId; ///< Identifier for the field type.
1512 TInt iValType; ///< The field type value e.g.EText, EMedText.
1513 TFieldTypeAttributes iTypeAttr; ///< The type's attribute, either ENoAttrs or ENotNull
1514 TGenericTypeName iTypeName; ///< Name of the field type.
1515 } SGenericRecordTypeInfo;
1519 class CMDBRecordBase : public CMDBNumFieldBase
1521 Base class for all MetaDatabase records
1528 inline CMDBRecordBase(){}
1529 inline CMDBRecordBase(TMDBElementId aElementId)
1530 : CMDBNumFieldBase(aElementId | KCDMaskShowFieldType){}
1532 IMPORT_C virtual CMDBElement* GetFieldByNameL(const TPtrC& aFieldName, TInt& aValType );
1534 IMPORT_C virtual CMDBElement* GetFieldByIdL(TMDBElementId aId);
1536 IMPORT_C virtual const SRecordTypeInfo* GetRecordInfo();
1542 class CMDBGenericRecord : public CMDBRecordBase
1544 Container for data and type information in a MetaDatabase record
1545 For use to contain user-defined records as an alternative to declaring a
1546 specific record class of type CCDRecordBase
1552 friend class TMDBGenericRecordVisitor;
1553 friend class CMDBSessionImpl;
1559 explicit inline CMDBGenericRecord(TMDBElementId aElementId)
1560 : CMDBRecordBase(aElementId) {}
1562 IMPORT_C ~CMDBGenericRecord();
1564 IMPORT_C virtual CMDBElement* GetFieldByNameL(const TPtrC& aFieldName, TInt& aValType );
1566 IMPORT_C CMDBElement* GetFieldByIdL(TMDBElementId aId);
1569 IMPORT_C void InitializeL(const TDesC& aTableName, const SGenericRecordTypeInfo* aNewTableInfo);
1575 The name of this record type
1577 TBuf<KCDMaxFieldNameLength> iRecordType;
1580 array of type information about fields in this record
1581 order of field info should match order of fields
1583 RArray<SGenericRecordTypeInfo> iRecordInfo;
1585 array of fields in this record
1586 order of fields should match order of field info
1588 RPointerArray<CMDBElement> iFields;
1593 class CMDBRecordSetBase : public CMDBTextFieldBase
1595 Use this class to express a list of records MetaDatabase Element type
1596 Records can be ordered using the standard RPointerArray functions
1606 IMPORT_C CMDBRecordSetBase();
1611 IMPORT_C CMDBRecordSetBase(TMDBElementId aElementId);
1616 IMPORT_C ~CMDBRecordSetBase();
1618 inline CMDBRecordSetBase& operator=(const TPtrC& aValue)
1620 return (CMDBRecordSetBase&)CMDBTextFieldBase::operator=(aValue);
1629 RPointerArray<CMDBRecordBase> iRecords;
1635 template <class TYPE>
1636 class CMDBRecordSet : public CMDBRecordSetBase
1638 Use this class to express a list of records of a particular MetaDatabase Element type
1639 Records can be ordered using the standard RPointerArray functions
1646 inline CMDBRecordSet(){}
1648 inline CMDBRecordSet(TMDBElementId aElementId)
1649 : CMDBRecordSetBase(aElementId) {}
1651 inline CMDBRecordSet<TYPE>& operator=(const TPtrC& aValue)
1653 return (CMDBRecordSet<TYPE>&)CMDBRecordSetBase::operator=(aValue);
1656 inline TYPE* operator [](const TInt i)
1658 return (TYPE*)iRecords[i];
1668 } //end namespace CommsDat
1670 #endif // METADATABASE_H