epoc32/include/metadatabase.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 2 2fe1408b6811
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
     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 "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 // Meta-database declarations for use in storing comms data
    15 // 
    16 //
    17 
    18 /**
    19  @file
    20  @publishedAll
    21  @released
    22 */
    23 
    24 #if (!defined METADATABASE_H)
    25 #define       METADATABASE_H
    26 
    27 
    28 
    29 // NetMeta headers
    30 #include <comms-infras/metadata.h>
    31 #include <comms-infras/metatype.h>
    32 
    33 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
    34 #include <metadatabase_partner.h>
    35 #endif
    36 
    37 // CommsDat headers
    38 #include <commsdat.h>
    39 
    40 
    41 
    42 /**@plaintext
    43 
    44 This file contains :
    45 
    46 1/  Class for expressing a session with the storage server
    47 
    48 			CMDBSession
    49 
    50 		This class contains functions to create and close a session, to set the dataset version
    51 		and to request database actions such as locking for a transaction.
    52 
    53 2/  Generic database functionality interface
    54 
    55 			MMetaDatabase
    56 
    57 		This class uses a CMDBSession object
    58 
    59 
    60 3/  General base class that inherits from MMetaDatabase to express any database element
    61 
    62 			CMDBElement
    63 
    64 		This class contains the ElementId for each MetaDatabase object
    65 		An element id locates stored data in the comms database.
    66 
    67 
    68 4/  Data classes that each inherit from CMDBElement
    69 
    70 	a) Fields
    71 
    72 			CMDBField<T>
    73 
    74 		where T is a basic type value of the field (TInt, TDes, TBool etc)
    75 		
    76 		This class derives from
    77 
    78 			CMDBElement
    79 
    80 		to implement the thin template idiom
    81 
    82 
    83 			CMDBRecordLink<T>
    84 
    85 		where T is a record of a particular type.  This class expresses a soft-link
    86 		from a field in one record to a record of a different type (i.e. in another table).
    87 		The TMDBElementId value stored in this field in the repository is the id of an instance 
    88 		of the record of type T
    89 
    90 		This class derives from
    91 
    92 			CMDBRecordLinkBase
    93 
    94 		to implement the thin template idiom
    95 
    96 
    97 	b) Field Containers
    98 
    99 
   100 			CCDRecord
   101 
   102 		base class for record containing specific list of fields - see CommsDatTypesv1_1.h
   103 
   104 
   105 			CMDBRecordSet<T>
   106 
   107 		an array of records where T is the record type.  This can represent a Table in a database.
   108 
   109 
   110 
   111 
   112 5/  Other support classes and type definitions
   113 
   114 			TMDBElementId
   115 
   116 		The TMDBElementId locates a data object or set of data objects in the database.
   117 
   118 		A TMDBElementId expresses
   119 
   120 		<TableId><ColumnId><RecordId><Attributes>
   121 
   122 		A TMDBElementId has a different format depending on the data type it expresses
   123 
   124 			Table       <TableId><0><0>
   125 			Column      <TableId><ColumnId><0>
   126 
   127 			Record      <TableId><0><RecordId>
   128 			Field       <TAbleId><ColumnId><RecordId>
   129 
   130 
   131 			TMDBAttributeFlags
   132 
   133 		Attribute settings for any storable element.
   134 		Attributes express access control for data in the database
   135 
   136 */
   137 
   138 
   139 
   140 namespace CommsDat
   141 {
   142 
   143 using namespace Meta;
   144 
   145 
   146 // Private to implementation
   147 //@internalTechnology
   148 //@released
   149 class CMDBSessionImpl;
   150 
   151 // Forward declarations
   152 class MMetaDatabase;
   153 class CMDBElement;
   154 
   155 /**
   156 Attribute flags for an element in the Meta Database
   157 Attributes describe access rights to the data in the database
   158 @publishedAll
   159 @released
   160 */
   161 typedef TUint32         TMDBAttributeFlags;
   162 
   163 /**
   164 The identifier for any entry in the MetaDatabase.
   165 It can specify
   166 	<TableId><ColumnId><RecordId>
   167 This identifies 
   168     The data location in the database
   169     The meaning of the data within in the data schema
   170     The type of the data
   171 
   172 @publishedAll
   173 @released
   174 */
   175 typedef TUint32         TMDBElementId;
   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     
   215 class CMDBSession : public CBase
   216 /**
   217 A session with the underlying storage server
   218 @publishedAll
   219 @released
   220 */
   221 {
   222 public:
   223 
   224 	/**
   225 	Open a session with the storage server and establish data format version in use
   226 	CommsDat always attempts to support the required version of the client-facing data set.
   227     The client must carefully choose the dataset version as it affects binary compatibility
   228 
   229     @params aRequiredVersion  
   230             If the requested version is deprecated but still supported, mapping will be performed 
   231             within CommsDat to maintain Data and Binary compatibility for the client
   232             If the requested version is the latest version, no mapping will be performed
   233             and deprecated fields will be ignored 
   234             A client that needs to maintain BC must use a specific version
   235             A client that always wants to use the latest dataset can start the session with KCDLatestVersion
   236             
   237     @leave  KErrUnsupported If an old unsupported version is requested
   238     @leave  System-wide error codes if there is an unexpected error
   239     
   240     @pre    None
   241     @post   on success a session has been created and initialised
   242 
   243 	*/
   244 	IMPORT_C static CMDBSession* NewL(TVersion aRequiredVersion);
   245 
   246 	/**
   247 	As NewL and adds Session to the CleanupStack
   248 
   249 	*/
   250 	IMPORT_C static CMDBSession* NewLC(TVersion aRequiredVersion);
   251 
   252 	/**
   253 	Virtual Destructor
   254 
   255 	*/
   256 	IMPORT_C ~CMDBSession();
   257 
   258 
   259 	/**
   260 	Close session with storage server.
   261 	@publishedAll
   262 	@deprecated v9.1 Destructor is all that is required
   263 	*/
   264 	IMPORT_C void Close();
   265 
   266 
   267 	/**
   268 	Returns the KCDCurrentVersion constant which maps to the KCDVersion1_1 
   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 	
   273 	@pre   None
   274     @post  None
   275     
   276 	@publishedAll
   277 	@deprecated
   278 
   279 	*/
   280 	IMPORT_C static TVersion LatestVersion();
   281 
   282 
   283 	/**
   284 	Lookup data format version currently in use by client
   285 
   286 
   287 	*/
   288 	IMPORT_C TVersion VersionInUse();
   289 
   290 
   291 	/**
   292 	Open Transaction with storage server and obtain write lock - if not already set
   293 
   294     @capability WriteDeviceData
   295 
   296     @leave	Will leave with KErrNotAvailable if Database write locked by another process
   297 	@leave  Will report KErrAlreadyInTransaction if transaction this session is already in a transaction
   298     @leave  Will leave with a system-wide error code if an error occurs during commit
   299 
   300 	@pre    None
   301     @post   on success the session has exclusive write access to the database
   302 
   303 
   304 	*/
   305 	IMPORT_C void OpenTransactionL();
   306 
   307 
   308 	/**
   309 	Commit Transaction in database.
   310 
   311     @leave	Will leave with KErrNotFound if not in transaction
   312     @leave  Will leave with a system-wide error code if an error occurs during commit
   313 
   314 	@pre    None
   315 
   316 	@post   On success the database is updated with data added, modified or deleted during the transaction
   317     @post   On failure, any open data containers may not be in sync with the database and should be discarded or reloaded
   318 	*/
   319 	IMPORT_C void CommitTransactionL();
   320 
   321 
   322 	/**
   323 	Cancel Transaction with database and rollback all associated changes
   324 
   325     @leave	Will fail with KErrNotFound if not in transaction
   326 
   327     @pre    None - though for correct usage, ensure a transaction is already open
   328 	@post   Any open data containers may not be in sync with the database and should be discarded or reloaded
   329 	*/
   330 	IMPORT_C void RollbackTransactionL();
   331 
   332    /**
   333 	Query if this session is in a transaction with the database
   334 	Return code will indicate
   335 		Not in transaction,
   336 		Already in transaction for this session,
   337 		Write-lock not available.  Another session has it.
   338     @pre None
   339 	*/
   340 	IMPORT_C TInt IsInTransaction();
   341 
   342 	
   343     /**
   344 	Set attributes to ignore for all database operations during this session 
   345 
   346     @params aAttributeFlags indicates the requested access level to stored data.
   347             Attributes set by this call will be ignored as restrictions in all database interactions,
   348 	        providing the client has enough platform security capabilities to back up the request
   349 	
   350     @pre None
   351 	*/
   352 	IMPORT_C void SetAttributeMask(TMDBAttributeFlags aAttributeFlags);
   353 
   354 	
   355 	/**
   356 	Check flags in attribute mask
   357     @params aAttributeFlags indicates the requested access level to stored data
   358             Attribute flags that have been set will be ignored as restrictions in all database interactions, 
   359             providing the client has enough platform security capabilities to back up the request
   360 
   361     @return ETrue if the flag is set in the session mask 
   362             This means that the attribute is ignored in database interactions for this session
   363 
   364     @return EFalse if the flag is not set in the session mask 
   365             This means that the attribute is obeyed in all database interactions for this session
   366 
   367     @pre None
   368 	
   369 	*/
   370 	IMPORT_C TBool IsSetAttributeMask(TMDBAttributeFlags aAttributeFlags);
   371 
   372     
   373     /**
   374 	Clear attribute mask settings, indicating required access level to stored data
   375 	Clear flags in the attribute mask for this session
   376     
   377         Flags indicate the requested access level to stored data
   378 	    
   379         Attribute flags that have been set in this function will be cleared from the session's 
   380         attribute mask and will be obeyed as restrictions in all database interactions, 
   381         providing the client has enough platform security capabilities to back up the request
   382         
   383     @pre None
   384 	
   385 	
   386 	*/
   387 	IMPORT_C void ClearAttributeMask(TMDBAttributeFlags aAttributeFlags);
   388 
   389 
   390 
   391 	/**
   392 	Cancel all notification requests that are outstanding from calls to 
   393         MMetaDatabase::RequestNotification
   394     Individual requests can be cancelled via MMetaDatabase::CancelNotify.
   395 
   396     @return KErrNone on success or a system-wide error code
   397     
   398     @pre  None
   399 
   400 	*/
   401 	IMPORT_C TInt CancelAllNotifications();
   402 
   403 
   404     /**
   405 	Attempt to create publish/subscribe properties if not already defined.
   406     
   407         This function is normally called as a setup activity by System components
   408 
   409     @capability WriteDeviceData - since these properties are created in KUidSystemCategory category.  
   410 
   411     @return KErrNone on success.  Otherwise a system-wide error code
   412     	
   413     @pre None
   414 
   415 	*/	
   416 	IMPORT_C TInt PublishProperties();
   417 
   418 private:
   419 
   420     TInt ConstructL( TVersion aRequiredVersion );
   421 
   422 	CMDBSession();
   423 
   424 private:
   425 
   426 	CMDBSessionImpl* iMDBSessionImpl;
   427 	
   428 	friend class MMetaDatabase;
   429 	friend class CommsDatSchema;
   430 };
   431 
   432 
   433 
   434 
   435 
   436 class MMetaDatabase : public Meta::MMetaData
   437 /**
   438 Interface for interaction with a database server
   439 Inherited by each data set type that can be stored
   440 @publishedAll
   441 @released
   442 */
   443 {
   444 public:
   445 
   446 	IMPORT_C virtual ~MMetaDatabase();
   447 
   448 
   449 	/**
   450 	LoadL - Load this container with data from the database
   451 		
   452         Any data in the container will be discarded 
   453 
   454         Individual fields may legitimately be NULL in the database, but if no data at all
   455         is found for an entire table or record, LoadL will leave with 
   456             KErrNotFound
   457 
   458         The client can request to ignore access control flags by setting the attribute mask
   459             CMDBSession::SetAttributeMask()
   460 		However, only fields that the client has capabilities to write will be stored in the database
   461 		A request to read data from an unauthorised area of the database will cause the function to leave.with 
   462             KErrPermissionDenied
   463         
   464         In a record, fields in an unauthorised column may be silently ignored and returned as NULL
   465         
   466         May also leave with KErrNoMemory or other general error codes
   467 	
   468         On failure, the container should be discarded or reloaded before it is used again
   469 
   470     @pre
   471 
   472         Ensure the ElementId for this container fully identifies the target data in the database
   473             <Table><Column><Record>
   474         Ensure that the session object has been initialised with the correct dataset version
   475         Ensure that the session object has appropriate access control attributes to manage the target data in the database
   476 
   477 	*/
   478 	IMPORT_C void LoadL(CMDBSession& aSession);
   479 
   480 
   481 	/**
   482 	FindL - Find and Load the data set(s) that match all the data values entered by the 
   483     client in this container
   484 	     
   485         Client can request to ignore access control flags by setting the attribute mask,
   486             CMDBSession::SetAttributeMask()
   487 		However will not load data that the client is not authorised to see (by platsec)
   488         even if the client has sets the appropriate attribute mask
   489 
   490 		Will return
   491 			ETrue on success
   492 			EFalse if no data found that the client is authorised to view
   493             
   494         May also leave with KErrGeneral or other general error codes.
   495 
   496         On failure, the container should be discarded or repopulated before it is used again
   497 		
   498 		Please note - a case insensitive search is done in the case of text based fields
   499 		
   500     @pre
   501 
   502         Populate this container where necessary with valid data to match during the find operation
   503         Ensure the ElementId for this container correcty identifies the target table in the database
   504             <Table><Column>
   505         Ensure that the session object has been initialised with the correct dataset version
   506         Ensure that the session object has appropriate access control attributes to manage the target data in the database
   507 	 */
   508 	IMPORT_C TBool FindL(CMDBSession& aSession);
   509 
   510 
   511 	/**
   512 	Refresh all fields in the container that have not been changed by the client
   513 
   514 		The client can request to ignore access control flags by setting the attribute mask,
   515             CMDBSession::SetAttributeMask()
   516 		However, only data that the client has capabilities to view will be loaded
   517 		Unauthorised data elements will be silently ignored and will remain NULL
   518 
   519 		If no data at all is found the functon will leave with 
   520 			KErrNotFound
   521 
   522 		If fields are not accessible for reading the function may leave with 
   523             KErrPermissionDenied
   524 	    
   525         May also leave with other general error codes if there are unexpected 
   526         problems (e.g. KErrNoMemory when out of memory)
   527 
   528         On failure, the container should be discarded or reloaded before it is used again
   529 
   530 	@pre
   531 
   532         Ensure the ElementId for this container fully identifies the target data in the database
   533             <Table><Column><Record>
   534         Ensure that the session object has been initialised with the correct dataset version
   535         Ensure that the session object has appropriate access control attributes to manage the target data in the database
   536 	*/
   537 	IMPORT_C void RefreshL(CMDBSession& aSession);
   538 
   539 
   540 	/**
   541 	StoreL - Store all fields in the database that have been changed in this container and 
   542     create new records where necessary.
   543 
   544         StoreL is atomic for this container.  An internal transaction is used even if 
   545         no overall transaction is set by client.
   546             All changed fields in the element are stored in the database on success.  
   547             No fields or records are stored in the database if the function leaves
   548 
   549         If a client has an open transaction in the session, the stored data will be available to this session as 
   550         soon as StoreL completes but will not be visible to other sessions until the transaction completes successfully
   551 
   552 		The client can request to ignore access control flags by setting the attribute mask
   553             CMDBSession::SetAttributeMask()
   554 		However, only fields that the client has capabilities to write will be stored in the database
   555 		A request to modify data in an unauthorised area of the database will cause the function to leave.with 
   556             KErrPermissionDenied
   557         
   558     	If a field already exists, StoreL will leave with
   559 	        KErrAlreadyExists
   560 
   561         May also leave with other general error codes if there are unexpected 
   562         problems (e.g. KErrNoMemory when out of memory)
   563 
   564 		Store will be atomic - all fields stored after success.  No fields stored if the function leaves
   565 		
   566         If StoreL fails or the later commit is not successful, The data in the container will not
   567         match the data in the database.  
   568 
   569         On failure, the container should be discarded or repopulated before it is used again
   570 
   571 	@pre
   572 
   573         Populate this container with valid data for storage
   574         Ensure the ElementId for this container fully identifies the target location in the database
   575             <Table><Column><Record>
   576         Ensure that the session object has been initialised with the correct dataset version
   577         Ensure that the session object has appropriate access control attributes to manage the target data in the database
   578         
   579 	*/
   580 	IMPORT_C void StoreL(CMDBSession& aSession);
   581 
   582 
   583 	/**
   584 	Modify all fields in the database that have been changed in this container by the caller
   585 	
   586         Modification is atomic for this container.  It uses an internal transaction even if 
   587         no overall transaction set by client.
   588             All changed fields in the element are modified in database on success.  
   589             No fields are altered in the database if the function leaves
   590 
   591         Client can request to ignore access control flags by setting the attribute mask
   592             CMDBSession::SetAttributeMask()
   593 		However, only fields that the client has capabilities to alter will be modified.in the database
   594 		A request to modify data in an unauthorised area will cause the function to leave.with 
   595             KErrPermissionDenied
   596 		
   597 
   598 		May also leave with other general error codes if there are unexpected 
   599         problems (e.g. KErrNoMemory when out of memory)
   600 
   601         On failure, the container should be discarded or repopulated before it is used again
   602 
   603     @pre
   604 
   605         Populate this container with valid data for storage
   606         Ensure the ElementId for this container fully identifies the target data in the database
   607             <Table><Column><Record>
   608         Ensure that the session object has been initialised with the correct dataset version
   609         Ensure that the session object has appropriate access control attributes to manage the target data in the database
   610 	*/
   611 	IMPORT_C void ModifyL(CMDBSession& aSession);
   612 
   613 
   614 	/**
   615 	Delete fields from the database.
   616 
   617 		Client can request to ignore access control flags by setting the attribute mask,
   618 		but only fields that the client has capabilities to delete will be removed.
   619 
   620 		A request to delete data in unauthorised area will cause the function to leave
   621 
   622 	@leave	If client not authorised to read or write the data, will leave with 
   623 	        	KErrPermissionDenied 
   624             May also leave with other general error codes if there are unexpected 
   625             problems (e.g. KErrNoMemory when out of memory)
   626 
   627     @pre    Ensure the ElementId for this container fully identifies the target data in the database
   628                 <Table><Column><Record>
   629             Ensure that the session object has appropriate access control attributes to manage the target data in the database
   630             Ensure the ElementId for this container correcty identifies the target data in the database
   631 
   632 	*/
   633 	IMPORT_C void DeleteL(CMDBSession& aSession);
   634 
   635 
   636 	/**
   637 	RequestNotification - Register for notification of events from all clients of the database
   638 
   639         aRequestStatus will be completed when the following events occur
   640             TransactionComplete
   641             TransactionRollback
   642             SessionClose
   643         
   644         this aRequestStatus can be cancelled by a call to 
   645             
   646             MMetaDatabase::CancelNotification
   647 
   648         all outstanding aRequestStatus can be cancelled by a call to
   649             
   650             CMDBSession::CancelAllNotifications
   651 
   652     @capability WriteDeviceData
   653     
   654     @return KErrNone on success.  A system wide error on failure
   655 
   656     @params aSession        a valid session object
   657     @params aRequestStatus  the requestStatus object that will be completed on notification
   658     
   659     @pre    None
   660     @post   A notification request will be outstanding
   661 	*/
   662 	IMPORT_C TInt RequestNotification(CMDBSession&          aSession,
   663 									  TRequestStatus&        aRequestStatus);
   664 
   665 	/**
   666 	CancelNotification - cancel an outstanding notification request
   667         
   668         note that all outstanding notification requests can be cancelled by a call to
   669             
   670             CMDBSession::CancelAllNotifications
   671 
   672     @pres
   673          
   674         There is an outstanding notification request
   675 
   676 	*/
   677 	IMPORT_C TInt CancelNotification(CMDBSession&       aSession,
   678 									 TRequestStatus&     aRequestStatus);
   679 
   680 
   681 protected:
   682 
   683 
   684 	IMPORT_C explicit MMetaDatabase();
   685 
   686 private:
   687 
   688     /*
   689     @internalComponent
   690     */
   691     void DoLoadL(CMDBSessionImpl* aSession, CMDBElement* aElement, CMDBElement* aMapper, TInt& aErr, TMDBElementId aRecordId, TMDBElementId aAttributes, TBool isTheLoadForMapper = EFalse);
   692 
   693     /*
   694     @internalComponent
   695     */
   696     void DoLoadL(CMDBSessionImpl* aSession, CMDBElement* aElement, CMDBElement* aMapper, TInt& aErr, TMDBElementId aRecordId, TMDBElementId aAttributes, RArray<TUint32>& aMatches, TBool isTheLoadForMapper = EFalse);
   697 
   698     /*
   699     @internalComponent
   700     */
   701     void DoFindL(CMDBSessionImpl* aSession, CMDBElement* aElement, CMDBElement* aMapper, TInt& aErr, RArray<TUint32>& candidates, RArray<TUint32>& matches);
   702 
   703     /*
   704     @internalComponent
   705     */
   706     void DoRefreshL(CMDBSessionImpl* aSession, CMDBElement* aElement, CMDBElement* aMapper, TInt &aErr);
   707 
   708     /*
   709     @internalComponent
   710     */
   711     void DoStoreL(CMDBSessionImpl* aSession, CMDBElement* aElement, CMDBElement* aMapper, TInt &aErr);
   712 
   713     /*
   714     @internalComponent
   715     */
   716     void DoModifyL(CMDBSessionImpl* aSession, CMDBElement* aElement, CMDBElement* aMapper, TInt &aErr);
   717 
   718 };
   719 
   720 
   721 
   722 
   723 
   724 class CMDBElement : public CBase, public MMetaDatabase
   725 /**
   726 Every item stored in the database is represented as a CMDBElement
   727 This class contains the id and attributes of every item in the database
   728 and for individual fields it also contains the value.
   729 
   730 @publishedAll
   731 @released
   732 */
   733 {
   734 public:
   735 
   736 
   737 	/**
   738 	Default Constructor
   739 	*/
   740 	IMPORT_C CMDBElement();
   741 
   742 
   743 	/**
   744 	Constructor
   745 	*/
   746 	IMPORT_C CMDBElement(TMDBElementId aElementId);
   747 	
   748 	
   749 	/**
   750 	Destructor
   751 	*/
   752 	IMPORT_C ~CMDBElement();
   753 
   754 
   755 	// Accessors
   756 
   757 	/**
   758 	Returns the ElementId of an object of this type.
   759 
   760 	The TypeId is
   761 
   762 	<TableId><ColumnId><RecordId>
   763 
   764 	This identifies the meaning of the field in the database schema
   765 	It also identifies the type of the data stored in this element
   766 	and the instance of the type
   767 
   768 	*/
   769 	IMPORT_C TMDBElementId ElementId() const;
   770 
   771 
   772 	/**
   773 	Returns the TypeId of an object of this type.
   774 
   775 	The TypeId is
   776 
   777 	<TableId><ColumnId><x>
   778 
   779 	This identifies the meaning of the data in this element in the database schema
   780 	It also identifies the type of the data contained in this element
   781 
   782     For an element that is a Table or a Record, the ColumnId field will be set to 
   783 
   784     KCDMaxColumnId
   785 	*/
   786 	IMPORT_C TMDBElementId  TypeId() const;
   787 
   788 
   789 	/**
   790 	Returns the TableId of an object of this type.
   791 
   792 	The TableId is part of the ElementId
   793 
   794 	<TableId><x><x>
   795 
   796 	It identifies the table in the database that holds the data contained in this element
   797 
   798 	*/
   799 	IMPORT_C TMDBElementId  TableId() const;
   800 
   801     
   802     /**
   803 	Returns the RecordId of an object of this type.
   804 
   805 	The RecordId is part of the ElementId <x><x><RecordId>
   806 
   807 	It identifies a particular instance of this type of Element in the database
   808 
   809 	*/
   810 	IMPORT_C TInt RecordId() const;
   811 
   812 
   813 	/**
   814 	Returns the Attributes of an object of this type.
   815 
   816 	Attributes express database access rights for the data of this element
   817 
   818 	*/
   819 	IMPORT_C TMDBAttributeFlags Attributes() const;
   820 
   821     // SETTER FUNCTIONS
   822 
   823 	/**
   824 	Sets the ElementId
   825 
   826 	*/
   827 	IMPORT_C void SetElementId(TMDBElementId aElementId);
   828 
   829 
   830 	/**
   831 	Sets the TypeId
   832 
   833 	*/
   834 	IMPORT_C void SetTypeId(TMDBElementId aElementId);
   835 
   836 
   837 	/**
   838 	Sets the RecordId
   839 
   840 	*/
   841 	IMPORT_C void SetRecordId(TInt aRecordId);
   842 
   843 
   844 	/**
   845 	Sets one or more attributes
   846 
   847 	*/
   848 	IMPORT_C void SetAttributes(TMDBAttributeFlags aAttributes);
   849 
   850 
   851 	/**
   852 	Clears one or more attributes
   853 
   854 	*/
   855 	IMPORT_C void ClearAttributes(TMDBAttributeFlags aAttributes);
   856 
   857 
   858 	/**
   859 	Queries the attributes
   860 
   861 	Returns ETrue if all queried attributes are set
   862 	Returns EFalse if any queried attribute is not set.
   863 	*/
   864 	IMPORT_C TBool IsSetAttribute(TMDBAttributeFlags aAttributes) const;
   865 
   866 
   867 	/**
   868 	Queries the state of the field value
   869 
   870 	Returns ETrue if the value of the element is not set
   871 	Returns EFalse if the element contains a value
   872 
   873 	*/
   874 	IMPORT_C TBool IsNull() const;	
   875 	
   876 	
   877 	
   878     EXP_DATA_VTABLE
   879 	
   880     /**
   881 	Queries the type of the field value
   882 
   883 	Returns the enumeration TCDFieldValueTypes that represents the value that can be stored in this element
   884 
   885 	*/
   886 
   887 	virtual TCDFieldValueTypes Type()=0;
   888 
   889 	/**
   890 	@internalComponent
   891 	*/
   892     TMDBElementId* Data(){return &iElementId;}
   893 	
   894 protected:
   895 
   896 	TMDBElementId     iElementId;
   897 	
   898     TAny*             iValue;
   899     
   900     };
   901 
   902 
   903 
   904 
   905 //
   906 //  COMMSDAT CONTAINERS
   907 //
   908 
   909 /**
   910 Commsdat Container classes qualifying numeric values
   911 @publishedAll 
   912 */
   913 class CMDBNumFieldBase : public CMDBElement
   914 {
   915 public:
   916 	/**
   917 	Default Constructor
   918 	*/
   919     IMPORT_C CMDBNumFieldBase();
   920 
   921 
   922    	/**
   923 	Constructor setting Field's ElementId
   924 	*/
   925 	IMPORT_C CMDBNumFieldBase(TMDBElementId aFieldId);
   926 
   927 
   928     /**
   929 	Assignment operator for field value
   930 	*/
   931 	IMPORT_C CMDBNumFieldBase& operator=(const TInt aValue);
   932 	
   933     IMPORT_C void SetMaxLengthL(TInt aLength);
   934     TMDBElementId GetL();
   935 	     
   936     EXP_DATA_VTABLE
   937         
   938 
   939 private:
   940 	virtual TCDFieldValueTypes Type()
   941 		{
   942 		return EInt;
   943 		}    
   944     
   945 };
   946 
   947 template<class TYPE>
   948 class CMDBField : public CMDBNumFieldBase
   949 /**
   950 A thin template that guards typed data access in a single CMDBElement
   951 This class describes a single numeric field in the database
   952 
   953 @publishedAll
   954 @released
   955 */
   956 {
   957 public:
   958 
   959 	/**
   960 	Default Constructor
   961 	*/
   962 	inline CMDBField()
   963 		{
   964 		}
   965 
   966 	/**
   967 	Constructor setting Field's ElementId
   968 	*/
   969 	inline CMDBField(TMDBElementId aFieldId)
   970 		: CMDBNumFieldBase(aFieldId)
   971 		{
   972 		}
   973 
   974 
   975 	/**
   976 	Assignment operator for field value
   977 	*/
   978 	inline CMDBField<TYPE>& operator=(const TYPE& aValue)
   979 	{
   980     	return (CMDBField<TYPE>&)CMDBNumFieldBase::operator=((TInt&)aValue);
   981 	}
   982 
   983 
   984     inline CMDBField<TYPE>& operator=(const CMDBField<TYPE>& aValue)
   985 	{
   986 	    return (CMDBField<TYPE>&)CMDBNumFieldBase::operator=(aValue);
   987 	}
   988 	
   989 	/**
   990 	Conversion operator for field value
   991 	*/
   992 	inline operator TYPE&()
   993 	{
   994 		return (TYPE&)iValue;
   995 	}
   996 	
   997 	/**
   998 	Conversion operator for field value
   999 	*/
  1000 	inline CMDBField<TYPE>& GetL()
  1001 	{
  1002 		if(IsNull() && !(ElementId() & KCDChangedFlag))
  1003 			{
  1004 			User::Leave(KErrNotFound); //todo commsdat specific error code
  1005 			}
  1006 
  1007 		return (TYPE&)iValue;
  1008 	}
  1009 	
  1010 	/**
  1011 	Function for setting a value
  1012 	*/
  1013 	inline void SetL(const TYPE& aValue)
  1014 	{
  1015 	CMDBNumFieldBase::operator=(aValue);
  1016 	}
  1017 	
  1018 };
  1019 
  1020 
  1021 
  1022 //
  1023 /**
  1024 Base Container class qualifying a text field
  1025 @publishedAll
  1026 */
  1027 class CMDBTextFieldBase : public CMDBElement
  1028 {
  1029 public:
  1030 	/**
  1031 	Default Constructor
  1032 	*/
  1033 	IMPORT_C CMDBTextFieldBase();
  1034 
  1035 	/**
  1036 	Constructor setting Field's ElementId
  1037 	*/
  1038 	IMPORT_C CMDBTextFieldBase(TMDBElementId aFieldId);    
  1039 	
  1040 	
  1041 	/**
  1042 	Destructor that deletes the field value
  1043 	*/
  1044 	IMPORT_C ~CMDBTextFieldBase();    
  1045 	
  1046 	
  1047 	/**
  1048 	Assignment Operator setting Field's value
  1049 	*/
  1050 	IMPORT_C CMDBTextFieldBase& operator=(const TDesC& aValue);
  1051 	
  1052 	    	
  1053     IMPORT_C void SetMaxLengthL(TInt aLength);
  1054 
  1055     EXP_DATA_VTABLE
  1056 
  1057 private:
  1058 	virtual TCDFieldValueTypes Type()
  1059 		{
  1060 		return EText;
  1061 		}    
  1062 
  1063 };
  1064 
  1065 
  1066 
  1067 
  1068 
  1069 
  1070 
  1071 template<>
  1072 class CMDBField<TDesC> : public CMDBTextFieldBase
  1073 /**
  1074 A thin template that guards typed data access in a single CMDBElement
  1075 This class describes a single field in the database
  1076 
  1077 @publishedAll
  1078 @released
  1079 */
  1080 {
  1081 public:
  1082 
  1083 	/**
  1084 	Default Constructor
  1085 	*/
  1086 	inline CMDBField()
  1087 		{
  1088 		}
  1089 
  1090 	/**
  1091 	Constructor setting Field's ElementId
  1092 	*/
  1093 	inline CMDBField(TMDBElementId aFieldId)
  1094 		: CMDBTextFieldBase(aFieldId)
  1095 		{
  1096 		}
  1097 
  1098 
  1099     inline void SetMaxLengthL(TInt aLength)
  1100 	// create a new buffer if necessary.
  1101 	{
  1102 	    CMDBTextFieldBase::SetMaxLengthL(aLength);
  1103 	}
  1104 	
  1105     inline CMDBField<TDesC>& operator=(const TDesC& aValue)
  1106 	{
  1107         CMDBTextFieldBase::operator=(aValue);	   
  1108         return *this; 
  1109 	}
  1110 
  1111     inline CMDBField<TDesC>& operator=(CMDBField<TDesC>& aValue)
  1112 	{
  1113         CMDBTextFieldBase::operator=((const TDesC&)aValue);	
  1114         return *this;   
  1115 	}
  1116 
  1117 	/**
  1118 	Conversion operator for field value
  1119 	*/
  1120 	inline operator const TDesC&()
  1121 	{
  1122         if (! iValue)
  1123             return KNullDesC;
  1124 
  1125 		return *(HBufC*)iValue;
  1126 	}
  1127 	
  1128 	/**
  1129 	Conversion operator for field value
  1130 	*/
  1131 	inline TDesC& GetL()
  1132 	{
  1133 		if(IsNull() && !(ElementId() & KCDChangedFlag))
  1134 			{
  1135 			User::Leave(KErrNotFound); //todo commsdat specific error code
  1136 			}
  1137 
  1138 		return *(HBufC*)iValue;
  1139 	}
  1140 	
  1141 	/**
  1142 	Function for setting a value
  1143 	*/
  1144 	inline void SetL(const TDesC& aValue)
  1145 	{
  1146 	SetMaxLengthL(aValue.Length());
  1147 	CMDBTextFieldBase::operator=(aValue);
  1148 	}
  1149 	
  1150 	
  1151 };
  1152 
  1153 
  1154 //
  1155 /**
  1156 Container class for qualifying binary values
  1157 @publishedAll 
  1158 */
  1159 class CMDBBinFieldBase : public CMDBElement
  1160 {
  1161 public:
  1162 	/**
  1163 	Default Constructor
  1164 	*/
  1165 	IMPORT_C CMDBBinFieldBase();
  1166 
  1167 	
  1168 	/**
  1169 	Constructor setting Field's ElementId
  1170 	*/
  1171 	IMPORT_C CMDBBinFieldBase(TMDBElementId aFieldId);    
  1172 	
  1173 	
  1174 	/**
  1175 	Destructor that deletes the field value
  1176 	*/
  1177 	IMPORT_C ~CMDBBinFieldBase();    
  1178 	
  1179 	
  1180 	/**
  1181 	Assignment Operator setting Field's value
  1182 	*/
  1183 	IMPORT_C CMDBBinFieldBase& operator=(const TDesC8& aValue);
  1184 	    	
  1185     /**
  1186 	To allocate space for field data.
  1187 	*/
  1188 	IMPORT_C void SetMaxLengthL(TInt aLength);
  1189 
  1190     EXP_DATA_VTABLE
  1191 
  1192 private:
  1193 	virtual TCDFieldValueTypes Type()
  1194 		{
  1195 		return EDesC8;
  1196 		}    
  1197 };
  1198 
  1199 
  1200 template<>
  1201 class CMDBField<TDesC8> : public CMDBBinFieldBase
  1202 /**
  1203 A thin template that guards typed data access in a single CMDBElement
  1204 This class describes a single field in the database
  1205 
  1206 @publishedAll
  1207 @released
  1208 */
  1209 {
  1210 public:
  1211 
  1212 	/**
  1213 	Default Constructor
  1214 	*/
  1215 	inline CMDBField()
  1216 		{
  1217 		}
  1218 
  1219 	/**
  1220 	Constructor setting Field's ElementId
  1221 	*/
  1222 	inline CMDBField(TMDBElementId aFieldId)
  1223 		: CMDBBinFieldBase(aFieldId)
  1224 		{
  1225 		}
  1226 
  1227     inline void SetMaxLengthL(TInt aLength)
  1228 	// create a new buffer if necessary.
  1229     	{
  1230     	    CMDBBinFieldBase::SetMaxLengthL(aLength);
  1231     	}
  1232 	
  1233 	
  1234     inline CMDBField<TDesC8>& operator=(const TDesC8& aValue)
  1235     	{
  1236             return (CMDBField<TDesC8>&)CMDBBinFieldBase::operator=(aValue);	    
  1237     	}
  1238 	
  1239 	
  1240     inline CMDBField<TDesC8>& operator=(CMDBField<TDesC8>& aValue)
  1241 	// Copy assignment
  1242         {
  1243             return (CMDBField<TDesC8>&)CMDBBinFieldBase::operator=((const TDesC8&)aValue);	    
  1244     	}
  1245 
  1246 
  1247 	/**
  1248 	Conversion operator for field value
  1249 	*/
  1250 	inline operator const TDesC8&()
  1251     	{
  1252 		    if (! iValue)
  1253                 return KNullDesC8;
  1254 
  1255     		return *(HBufC8*)iValue;
  1256     	}
  1257     	
  1258     /**
  1259 	Conversion operator for field value
  1260 	*/
  1261 	inline TDesC8& GetL()
  1262 	{
  1263 		if(IsNull() && !(ElementId() & KCDChangedFlag))
  1264 			{
  1265 			User::Leave(KErrNotFound); //todo commsdat specific error code
  1266 			}
  1267 
  1268     	return *(HBufC8*)iValue;
  1269 	}
  1270 	
  1271 	/**
  1272 	Function for setting a value
  1273 	*/
  1274 	inline void SetL(const TDesC8& aValue)
  1275 	{
  1276 	SetMaxLengthL(aValue.Length());
  1277 	CMDBBinFieldBase::operator=(aValue);
  1278 	}
  1279 	
  1280 };
  1281 
  1282 
  1283 
  1284 //
  1285 
  1286 /**
  1287 Base class for CMDBRecordLink
  1288 @publishedAll 
  1289 */
  1290 class CMDBRecordLinkBase : public CMDBNumFieldBase
  1291 {
  1292 public :	
  1293 
  1294 	IMPORT_C CMDBRecordLinkBase();
  1295 
  1296 	IMPORT_C CMDBRecordLinkBase(TMDBElementId aLinkingFieldId);
  1297 
  1298 	IMPORT_C CMDBRecordLinkBase(TMDBElementId aLinkingFieldId, CMDBElement* aLinkedRecord);
  1299 
  1300 
  1301 	IMPORT_C ~CMDBRecordLinkBase();
  1302 
  1303 	/**
  1304 	Assignment operator for field value
  1305 	which sets the id of the element list
  1306 	*/
  1307 	IMPORT_C CMDBRecordLinkBase& operator=(const TMDBElementId aValue);
  1308 
  1309 
  1310 	/**
  1311 	Conversion operator for field value
  1312 	which gets the id of the element list
  1313 	*/
  1314 	IMPORT_C operator TMDBElementId();
  1315 
  1316 
  1317 protected:
  1318 
  1319 	EXP_DATA_VTABLE
  1320 
  1321 private:
  1322     TCDFieldValueTypes Type()
  1323 		{
  1324 		return ELink;
  1325 		}    
  1326 public:
  1327     
  1328 	// the record referenced by the link id stored in the value of this field.
  1329 	CMDBElement*     iLinkedRecord;
  1330 
  1331 };
  1332 
  1333 
  1334 template<class RECORD_TYPE>
  1335 class CMDBRecordLink : public CMDBRecordLinkBase
  1336 /**
  1337  This container expresses a 'soft-link' to a record in another table.
  1338 
  1339  The value of a CMDBRecordLink field as stored in the database is the 
  1340  ElementId (<Table><Record>) of the linked record.
  1341 
  1342  The linked record itself can be viewed via the iLinkedRecord member and its accessors
  1343  
  1344  If a record is loaded then the iLinkedRecord must be created explicitly 
  1345  by the client - either on construction, or by use of the CreateLinkL or 
  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.
  1351  
  1352  When instantiating iLinkedRecord directly take care to match the object's type to the Type 
  1353  ID that will be found at the linking element.  It is better to use the CreateLinkL or 
  1354  SetLinkL functions to ensure type safety
  1355  
  1356  Calling MMetaDatabase functions on a CMDRecordLink field directly will perform the operation
  1357  on the field and also the linked record if it is present 
  1358 @publishedAll
  1359 @released
  1360 */
  1361 {
  1362 public :
  1363 	/**
  1364 	Constructor/Destructor
  1365 	*/
  1366 
  1367 	inline CMDBRecordLink()
  1368 		: CMDBRecordLinkBase() {}
  1369 
  1370 	/**
  1371 	Constructor
  1372 	*/
  1373 	inline CMDBRecordLink(TMDBElementId aLinkingFieldId)
  1374 		: CMDBRecordLinkBase(aLinkingFieldId) {}
  1375 
  1376 	/**
  1377 	Constructor
  1378 	*/
  1379 	inline CMDBRecordLink(TMDBElementId aLinkingFieldId, RECORD_TYPE* aLinkedRecord)
  1380 		: CMDBRecordLinkBase(aLinkingFieldId, (CMDBElement*)aLinkedRecord) {}
  1381 
  1382 	inline CMDBRecordLink& operator=(const TMDBElementId aValue)
  1383 	{
  1384 		return (CMDBRecordLink&)CMDBRecordLinkBase::operator=(aValue);
  1385 	}
  1386 	
  1387 
  1388     // SETTERS
  1389 
  1390 	/**
  1391 	Set the field value (this will be validated on StoreL)
  1392 	*/
  1393 	inline void SetL(const TMDBElementId aValue)
  1394 		{
  1395 		CMDBRecordLinkBase::operator=(aValue);
  1396 		}
  1397 		
  1398 
  1399     // OPERATORS
  1400 
  1401 	/**
  1402 	conversion operator for linked record of this type
  1403 	*/
  1404 	inline operator RECORD_TYPE*()
  1405 	{
  1406 		return static_cast<RECORD_TYPE*>(iLinkedRecord);
  1407 	}	
  1408 
  1409 };
  1410 
  1411 enum TFieldTypeAttributes
  1412 /**
  1413 To express type information for all MetaDatabase fields
  1414 */
  1415 	{
  1416 	ENoAttrs,	//< No attributes associated with this field.
  1417 	ENotNull, 	//< Ensures the field contains a value and must not be null.	
  1418 	};
  1419 
  1420 typedef struct
  1421 /**
  1422 To express type information for all MetaDatabase fields
  1423 */
  1424 	{
  1425 		const TMDBElementId	        iTypeId;		//< Identifier for the field.	
  1426 		const TInt                  iValType;		//< The field type value e.g.EText, EMedText.
  1427 	    const TFieldTypeAttributes	iTypeAttr;		//< The field attribute, either ENoAttrs or ENotNull.
  1428         const TText * const         iTypeName;		//< Name of the field type.
  1429 	    
  1430 	} SRecordTypeInfo;
  1431 
  1432 
  1433 #define MDB_GENERIC_TYPE_INFO(a, b, c, d) SGenericRecordTypeInfo(a, b, c, d)
  1434 
  1435 typedef TBuf<64> TGenericTypeName;
  1436 
  1437 typedef struct SGenericRecordTypeInfoTag
  1438 /**
  1439 To express type information for all MetaDatabase fields
  1440 */
  1441 	{
  1442 	     SGenericRecordTypeInfoTag()
  1443     	     : iTypeId(0), iValType(0), iTypeAttr(ENoAttrs) {}
  1444 
  1445 	     SGenericRecordTypeInfoTag(TMDBElementId        aId,
  1446 	                               TInt                 aVal,
  1447 	                               TFieldTypeAttributes aAttrType)
  1448    	     : iTypeId(aId), iValType(aVal), iTypeAttr(aAttrType)
  1449     	        {
  1450     	        }
  1451 
  1452 	     SGenericRecordTypeInfoTag(TMDBElementId        aId,
  1453 	                               TInt                 aVal,
  1454 	                               TFieldTypeAttributes aAttrType,
  1455 	                               TText * const        aTypeName)
  1456     	     : iTypeId(aId), iValType(aVal), iTypeAttr(aAttrType), iTypeName(aTypeName)
  1457     	        {
  1458     	        
  1459     	        }
  1460 
  1461 
  1462 	     SGenericRecordTypeInfoTag(      TMDBElementId        aId,
  1463 	                                     TInt                 aVal,
  1464 	                                     TFieldTypeAttributes aAttrType,
  1465 	                               const TGenericTypeName&    aTypeName)
  1466     	     : iTypeId(aId), iValType(aVal), iTypeAttr(aAttrType), iTypeName(aTypeName) {}
  1467 
  1468 
  1469 		 TMDBElementId	       iTypeId;			//< Identifier for the field type.	
  1470 		 TInt                  iValType;		//< The field type value e.g.EText, EMedText.
  1471 	     TFieldTypeAttributes  iTypeAttr;		//< The type's attribute, either ENoAttrs or ENotNull
  1472          TGenericTypeName	   iTypeName;		//< Name of the field type.
  1473 	} SGenericRecordTypeInfo;
  1474 	
  1475 	
  1476 
  1477 class CMDBRecordBase : public CMDBNumFieldBase
  1478 /**
  1479 Base class for all MetaDatabase records
  1480 @publishedAll
  1481 @released
  1482 */
  1483 	{
  1484 	public:
  1485 
  1486 		inline CMDBRecordBase(){}
  1487 		inline CMDBRecordBase(TMDBElementId aElementId)
  1488 			: CMDBNumFieldBase(aElementId | KCDMaskShowFieldType){}
  1489 			
  1490 		IMPORT_C virtual CMDBElement* GetFieldByNameL(const TPtrC& aFieldName, TInt& aValType );
  1491 
  1492 		IMPORT_C virtual CMDBElement* GetFieldByIdL(TMDBElementId aId);
  1493 		
  1494 		IMPORT_C virtual const SRecordTypeInfo* GetRecordInfo();
  1495 		
  1496 	};
  1497 
  1498 
  1499 
  1500 class CMDBGenericRecord : public CMDBRecordBase
  1501 /**
  1502 Container for data and type information in a MetaDatabase record
  1503 For use to contain user-defined records as an alternative to declaring a 
  1504 specific record class of type CCDRecordBase
  1505 
  1506 @publishedAll
  1507 @released
  1508 */
  1509     {
  1510 friend class TMDBGenericRecordVisitor;  
  1511 friend class CMDBSessionImpl;  
  1512 	public:
  1513 
  1514 
  1515 		EXP_DATA_VTABLE
  1516 		    
  1517 		explicit inline CMDBGenericRecord(TMDBElementId aElementId)
  1518 			: CMDBRecordBase(aElementId) {}
  1519 
  1520         IMPORT_C ~CMDBGenericRecord();
  1521 
  1522 		IMPORT_C virtual CMDBElement* GetFieldByNameL(const TPtrC& aFieldName, TInt& aValType );
  1523 
  1524 		IMPORT_C CMDBElement* GetFieldByIdL(TMDBElementId aId);
  1525 		
  1526 		
  1527 		IMPORT_C void InitializeL(const TDesC& aTableName, const SGenericRecordTypeInfo*  aNewTableInfo);
  1528 		
  1529 
  1530 	private:
  1531 
  1532         /*
  1533         The name of this record type
  1534         */
  1535 	    TBuf<KCDMaxFieldNameLength>   	iRecordType; 
  1536         
  1537         /*
  1538         array of type information about fields in this record
  1539         order of field info should match order of fields
  1540         */
  1541         RArray<SGenericRecordTypeInfo>  iRecordInfo;
  1542         /*
  1543         array of fields in this record
  1544         order of fields should match order of field info
  1545         */
  1546 		RPointerArray<CMDBElement>      iFields;
  1547 	};
  1548 
  1549 
  1550 
  1551 class CMDBRecordSetBase : public CMDBTextFieldBase
  1552 /**
  1553 Use this class to express a list of records MetaDatabase Element type
  1554 Records can be ordered using the standard RPointerArray functions
  1555 
  1556 @publishedAll
  1557 @released
  1558 */
  1559     {
  1560     public:
  1561     	IMPORT_C CMDBRecordSetBase();
  1562 
  1563     	IMPORT_C CMDBRecordSetBase(TMDBElementId aElementId);
  1564 
  1565     	IMPORT_C ~CMDBRecordSetBase();
  1566 
  1567         inline CMDBRecordSetBase& operator=(const TPtrC& aValue)
  1568         {
  1569         return (CMDBRecordSetBase&)CMDBTextFieldBase::operator=(aValue);
  1570         }
  1571 	
  1572 	protected:
  1573 
  1574     	EXP_DATA_VTABLE
  1575 
  1576     public:
  1577        
  1578     	RPointerArray<CMDBRecordBase> iRecords;
  1579 
  1580     };
  1581 
  1582 
  1583 
  1584 template <class TYPE>
  1585 class CMDBRecordSet : public CMDBRecordSetBase
  1586 /**
  1587 Use this class to express a list of records of a particular MetaDatabase Element type
  1588 Records can be ordered using the standard RPointerArray functions
  1589 
  1590 @publishedAll
  1591 @released
  1592 */
  1593 {
  1594 public:
  1595 
  1596 	inline CMDBRecordSet(){}
  1597 
  1598 	inline CMDBRecordSet(TMDBElementId aElementId)
  1599 		: CMDBRecordSetBase(aElementId) {}
  1600 		
  1601 	inline CMDBRecordSet<TYPE>& operator=(const TPtrC& aValue)
  1602 	{
  1603 		return (CMDBRecordSet<TYPE>&)CMDBRecordSetBase::operator=(aValue);
  1604 	}
  1605     		
  1606 	inline TYPE* operator [](const TInt i)
  1607 	{
  1608 		return (TYPE*)iRecords[i];
  1609 	}
  1610 
  1611 private:
  1612 
  1613 };
  1614 
  1615 } //end namespace CommsDat
  1616 
  1617 #endif  // METADATABASE_H