williamr@2: // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). williamr@2: // All rights reserved. williamr@2: // This component and the accompanying materials are made available williamr@4: // under the terms of "Eclipse Public License v1.0" williamr@2: // which accompanies this distribution, and is available williamr@4: // at the URL "http://www.eclipse.org/legal/epl-v10.html". williamr@2: // williamr@2: // Initial Contributors: williamr@2: // Nokia Corporation - initial contribution. williamr@2: // williamr@2: // Contributors: williamr@2: // williamr@2: // Description: williamr@2: // Meta-database declarations for use in storing comms data williamr@2: // williamr@2: // williamr@2: williamr@2: /** williamr@2: @file williamr@4: @publishedAll williamr@2: @released williamr@2: */ williamr@2: williamr@2: #if (!defined METADATABASE_H) williamr@2: #define METADATABASE_H williamr@2: williamr@2: williamr@2: williamr@2: // NetMeta headers williamr@2: #include williamr@2: #include williamr@2: williamr@4: #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS williamr@4: #include williamr@4: #endif williamr@4: williamr@2: // CommsDat headers williamr@2: #include williamr@2: williamr@2: williamr@2: williamr@2: /**@plaintext williamr@2: williamr@2: This file contains : williamr@2: williamr@2: 1/ Class for expressing a session with the storage server williamr@2: williamr@2: CMDBSession williamr@2: williamr@2: This class contains functions to create and close a session, to set the dataset version williamr@2: and to request database actions such as locking for a transaction. williamr@2: williamr@2: 2/ Generic database functionality interface williamr@2: williamr@2: MMetaDatabase williamr@2: williamr@2: This class uses a CMDBSession object williamr@2: williamr@2: williamr@2: 3/ General base class that inherits from MMetaDatabase to express any database element williamr@2: williamr@2: CMDBElement williamr@2: williamr@2: This class contains the ElementId for each MetaDatabase object williamr@2: An element id locates stored data in the comms database. williamr@2: williamr@2: williamr@2: 4/ Data classes that each inherit from CMDBElement williamr@2: williamr@2: a) Fields williamr@2: williamr@2: CMDBField williamr@2: williamr@2: where T is a basic type value of the field (TInt, TDes, TBool etc) williamr@2: williamr@2: This class derives from williamr@2: williamr@2: CMDBElement williamr@2: williamr@2: to implement the thin template idiom williamr@2: williamr@2: williamr@2: CMDBRecordLink williamr@2: williamr@2: where T is a record of a particular type. This class expresses a soft-link williamr@2: from a field in one record to a record of a different type (i.e. in another table). williamr@2: The TMDBElementId value stored in this field in the repository is the id of an instance williamr@2: of the record of type T williamr@2: williamr@2: This class derives from williamr@2: williamr@2: CMDBRecordLinkBase williamr@2: williamr@2: to implement the thin template idiom williamr@2: williamr@2: williamr@2: b) Field Containers williamr@2: williamr@2: williamr@2: CCDRecord williamr@2: williamr@2: base class for record containing specific list of fields - see CommsDatTypesv1_1.h williamr@2: williamr@2: williamr@2: CMDBRecordSet williamr@2: williamr@2: an array of records where T is the record type. This can represent a Table in a database. williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: 5/ Other support classes and type definitions williamr@2: williamr@2: TMDBElementId williamr@2: williamr@2: The TMDBElementId locates a data object or set of data objects in the database. williamr@2: williamr@2: A TMDBElementId expresses williamr@2: williamr@2: williamr@2: williamr@2: A TMDBElementId has a different format depending on the data type it expresses williamr@2: williamr@2: Table <0><0> williamr@2: Column <0> williamr@2: williamr@2: Record <0> williamr@2: Field williamr@2: williamr@2: williamr@2: TMDBAttributeFlags williamr@2: williamr@2: Attribute settings for any storable element. williamr@2: Attributes express access control for data in the database williamr@2: williamr@2: */ williamr@2: williamr@2: williamr@2: williamr@2: namespace CommsDat williamr@2: { williamr@2: williamr@2: using namespace Meta; williamr@2: williamr@2: williamr@2: // Private to implementation williamr@2: //@internalTechnology williamr@2: //@released williamr@2: class CMDBSessionImpl; williamr@2: williamr@2: // Forward declarations williamr@2: class MMetaDatabase; williamr@2: class CMDBElement; williamr@2: williamr@2: /** williamr@2: Attribute flags for an element in the Meta Database williamr@2: Attributes describe access rights to the data in the database williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@4: typedef TUint32 TMDBAttributeFlags; williamr@2: williamr@2: /** williamr@2: The identifier for any entry in the MetaDatabase. williamr@2: It can specify williamr@2: williamr@2: This identifies williamr@2: The data location in the database williamr@2: The meaning of the data within in the data schema williamr@2: The type of the data williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: typedef TUint32 TMDBElementId; williamr@2: williamr@4: williamr@4: // williamr@4: // COMMSDAT RECORD BASE CLASS williamr@4: // Contains fields common to all records williamr@4: // williamr@4: williamr@4: // Element Type Ids williamr@4: williamr@4: /** williamr@4: Field will contain a user-defined numeric tag for a record. williamr@4: Useful for user searches and cheaper to search on a numeric tag than a string name. williamr@4: Can be null. williamr@4: This tag is not automatically connected with the record id itself, williamr@4: which is contained within the ElementId for the record and not in any field. williamr@4: williamr@4: @publishedAll williamr@4: @released williamr@4: */ williamr@4: const TMDBElementId KCDTIdRecordTag = 0x00010000; williamr@4: williamr@4: /** williamr@4: Field will contain a user-defined string tag for a record. williamr@4: This is used to uniquely identify business level information within a record. williamr@4: williamr@4: This field is useful for user searches, however it should be noted that it would be more efficient to use the KCDTIdRecordTag field instead williamr@4: as it is quicker and cheaper to search for a number than for a string. williamr@4: williamr@4: @publishedAll williamr@4: @released williamr@4: */ williamr@4: const TMDBElementId KCDTIdRecordName = 0x00020000; williamr@4: williamr@4: williamr@4: // Element Type Names williamr@4: #define KCDTypeNameRecordTag _S("Id") williamr@4: #define KCDTypeNameRecordName _S("Name") williamr@4: williamr@4: williamr@2: class CMDBSession : public CBase williamr@4: /** williamr@2: A session with the underlying storage server williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: { williamr@2: public: williamr@2: williamr@2: /** williamr@2: Open a session with the storage server and establish data format version in use williamr@2: CommsDat always attempts to support the required version of the client-facing data set. williamr@2: The client must carefully choose the dataset version as it affects binary compatibility williamr@2: williamr@2: @params aRequiredVersion williamr@2: If the requested version is deprecated but still supported, mapping will be performed williamr@2: within CommsDat to maintain Data and Binary compatibility for the client williamr@2: If the requested version is the latest version, no mapping will be performed williamr@2: and deprecated fields will be ignored williamr@2: A client that needs to maintain BC must use a specific version williamr@2: A client that always wants to use the latest dataset can start the session with KCDLatestVersion williamr@2: williamr@2: @leave KErrUnsupported If an old unsupported version is requested williamr@2: @leave System-wide error codes if there is an unexpected error williamr@2: williamr@2: @pre None williamr@2: @post on success a session has been created and initialised williamr@2: williamr@2: */ williamr@2: IMPORT_C static CMDBSession* NewL(TVersion aRequiredVersion); williamr@2: williamr@2: /** williamr@2: As NewL and adds Session to the CleanupStack williamr@2: williamr@2: */ williamr@2: IMPORT_C static CMDBSession* NewLC(TVersion aRequiredVersion); williamr@2: williamr@2: /** williamr@2: Virtual Destructor williamr@2: williamr@2: */ williamr@2: IMPORT_C ~CMDBSession(); williamr@2: williamr@2: williamr@2: /** williamr@2: Close session with storage server. williamr@2: @publishedAll williamr@2: @deprecated v9.1 Destructor is all that is required williamr@2: */ williamr@2: IMPORT_C void Close(); williamr@2: williamr@2: williamr@2: /** williamr@4: Returns the KCDCurrentVersion constant which maps to the KCDVersion1_1 williamr@4: constant for backward compatibility reason. Please avoid using this method williamr@4: when creating a CommsDat session object and use explicit schema version williamr@4: instead. williamr@4: williamr@2: @pre None williamr@2: @post None williamr@4: williamr@2: @publishedAll williamr@4: @deprecated williamr@4: williamr@2: */ williamr@2: IMPORT_C static TVersion LatestVersion(); williamr@2: williamr@2: williamr@2: /** williamr@2: Lookup data format version currently in use by client williamr@2: williamr@4: williamr@2: */ williamr@2: IMPORT_C TVersion VersionInUse(); williamr@2: williamr@2: williamr@2: /** williamr@2: Open Transaction with storage server and obtain write lock - if not already set williamr@2: williamr@2: @capability WriteDeviceData williamr@2: williamr@2: @leave Will leave with KErrNotAvailable if Database write locked by another process williamr@2: @leave Will report KErrAlreadyInTransaction if transaction this session is already in a transaction williamr@2: @leave Will leave with a system-wide error code if an error occurs during commit williamr@2: williamr@2: @pre None williamr@2: @post on success the session has exclusive write access to the database williamr@2: williamr@4: williamr@2: */ williamr@2: IMPORT_C void OpenTransactionL(); williamr@2: williamr@2: williamr@2: /** williamr@2: Commit Transaction in database. williamr@2: williamr@2: @leave Will leave with KErrNotFound if not in transaction williamr@2: @leave Will leave with a system-wide error code if an error occurs during commit williamr@2: williamr@2: @pre None williamr@2: williamr@2: @post On success the database is updated with data added, modified or deleted during the transaction williamr@2: @post On failure, any open data containers may not be in sync with the database and should be discarded or reloaded williamr@2: */ williamr@2: IMPORT_C void CommitTransactionL(); williamr@2: williamr@2: williamr@2: /** williamr@2: Cancel Transaction with database and rollback all associated changes williamr@2: williamr@2: @leave Will fail with KErrNotFound if not in transaction williamr@2: williamr@2: @pre None - though for correct usage, ensure a transaction is already open williamr@2: @post Any open data containers may not be in sync with the database and should be discarded or reloaded williamr@2: */ williamr@2: IMPORT_C void RollbackTransactionL(); williamr@2: williamr@2: /** williamr@2: Query if this session is in a transaction with the database williamr@2: Return code will indicate williamr@2: Not in transaction, williamr@2: Already in transaction for this session, williamr@2: Write-lock not available. Another session has it. williamr@2: @pre None williamr@2: */ williamr@2: IMPORT_C TInt IsInTransaction(); williamr@2: williamr@2: williamr@2: /** williamr@2: Set attributes to ignore for all database operations during this session williamr@2: williamr@2: @params aAttributeFlags indicates the requested access level to stored data. williamr@2: Attributes set by this call will be ignored as restrictions in all database interactions, williamr@2: providing the client has enough platform security capabilities to back up the request williamr@2: williamr@2: @pre None williamr@2: */ williamr@2: IMPORT_C void SetAttributeMask(TMDBAttributeFlags aAttributeFlags); williamr@2: williamr@2: williamr@2: /** williamr@2: Check flags in attribute mask williamr@2: @params aAttributeFlags indicates the requested access level to stored data williamr@2: Attribute flags that have been set will be ignored as restrictions in all database interactions, williamr@2: providing the client has enough platform security capabilities to back up the request williamr@2: williamr@2: @return ETrue if the flag is set in the session mask williamr@2: This means that the attribute is ignored in database interactions for this session williamr@2: williamr@2: @return EFalse if the flag is not set in the session mask williamr@2: This means that the attribute is obeyed in all database interactions for this session williamr@2: williamr@2: @pre None williamr@4: williamr@2: */ williamr@2: IMPORT_C TBool IsSetAttributeMask(TMDBAttributeFlags aAttributeFlags); williamr@2: williamr@2: williamr@2: /** williamr@2: Clear attribute mask settings, indicating required access level to stored data williamr@2: Clear flags in the attribute mask for this session williamr@2: williamr@2: Flags indicate the requested access level to stored data williamr@2: williamr@2: Attribute flags that have been set in this function will be cleared from the session's williamr@2: attribute mask and will be obeyed as restrictions in all database interactions, williamr@2: providing the client has enough platform security capabilities to back up the request williamr@2: williamr@2: @pre None williamr@2: williamr@4: williamr@2: */ williamr@2: IMPORT_C void ClearAttributeMask(TMDBAttributeFlags aAttributeFlags); williamr@2: williamr@2: williamr@2: williamr@2: /** williamr@2: Cancel all notification requests that are outstanding from calls to williamr@2: MMetaDatabase::RequestNotification williamr@2: Individual requests can be cancelled via MMetaDatabase::CancelNotify. williamr@2: williamr@2: @return KErrNone on success or a system-wide error code williamr@2: williamr@2: @pre None williamr@2: williamr@2: */ williamr@2: IMPORT_C TInt CancelAllNotifications(); williamr@2: williamr@2: williamr@2: /** williamr@2: Attempt to create publish/subscribe properties if not already defined. williamr@2: williamr@2: This function is normally called as a setup activity by System components williamr@2: williamr@2: @capability WriteDeviceData - since these properties are created in KUidSystemCategory category. williamr@2: williamr@2: @return KErrNone on success. Otherwise a system-wide error code williamr@2: williamr@2: @pre None williamr@2: williamr@2: */ williamr@2: IMPORT_C TInt PublishProperties(); williamr@2: williamr@2: private: williamr@2: williamr@2: TInt ConstructL( TVersion aRequiredVersion ); williamr@2: williamr@2: CMDBSession(); williamr@2: williamr@2: private: williamr@2: williamr@2: CMDBSessionImpl* iMDBSessionImpl; williamr@2: williamr@2: friend class MMetaDatabase; williamr@4: friend class CommsDatSchema; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: class MMetaDatabase : public Meta::MMetaData williamr@4: /** williamr@2: Interface for interaction with a database server williamr@2: Inherited by each data set type that can be stored williamr@2: @publishedAll williamr@4: @released williamr@2: */ williamr@2: { williamr@2: public: williamr@2: williamr@2: IMPORT_C virtual ~MMetaDatabase(); williamr@2: williamr@2: williamr@2: /** williamr@2: LoadL - Load this container with data from the database williamr@2: williamr@2: Any data in the container will be discarded williamr@2: williamr@2: Individual fields may legitimately be NULL in the database, but if no data at all williamr@2: is found for an entire table or record, LoadL will leave with williamr@2: KErrNotFound williamr@2: williamr@2: The client can request to ignore access control flags by setting the attribute mask williamr@2: CMDBSession::SetAttributeMask() williamr@2: However, only fields that the client has capabilities to write will be stored in the database williamr@2: A request to read data from an unauthorised area of the database will cause the function to leave.with williamr@2: KErrPermissionDenied williamr@2: williamr@2: In a record, fields in an unauthorised column may be silently ignored and returned as NULL williamr@2: williamr@2: May also leave with KErrNoMemory or other general error codes williamr@2: williamr@2: On failure, the container should be discarded or reloaded before it is used again williamr@2: williamr@2: @pre williamr@2: williamr@2: Ensure the ElementId for this container fully identifies the target data in the database williamr@2: williamr@2: Ensure that the session object has been initialised with the correct dataset version williamr@2: Ensure that the session object has appropriate access control attributes to manage the target data in the database williamr@2: williamr@2: */ williamr@2: IMPORT_C void LoadL(CMDBSession& aSession); williamr@2: williamr@2: williamr@2: /** williamr@2: FindL - Find and Load the data set(s) that match all the data values entered by the williamr@2: client in this container williamr@2: williamr@2: Client can request to ignore access control flags by setting the attribute mask, williamr@2: CMDBSession::SetAttributeMask() williamr@2: However will not load data that the client is not authorised to see (by platsec) williamr@2: even if the client has sets the appropriate attribute mask williamr@2: williamr@2: Will return williamr@2: ETrue on success williamr@2: EFalse if no data found that the client is authorised to view williamr@2: williamr@2: May also leave with KErrGeneral or other general error codes. williamr@2: williamr@2: On failure, the container should be discarded or repopulated before it is used again williamr@4: williamr@4: Please note - a case insensitive search is done in the case of text based fields williamr@4: williamr@2: @pre williamr@2: williamr@2: Populate this container where necessary with valid data to match during the find operation williamr@2: Ensure the ElementId for this container correcty identifies the target table in the database williamr@2:
williamr@2: Ensure that the session object has been initialised with the correct dataset version williamr@2: Ensure that the session object has appropriate access control attributes to manage the target data in the database williamr@2: */ williamr@2: IMPORT_C TBool FindL(CMDBSession& aSession); williamr@2: williamr@2: williamr@2: /** williamr@2: Refresh all fields in the container that have not been changed by the client williamr@2: williamr@2: The client can request to ignore access control flags by setting the attribute mask, williamr@2: CMDBSession::SetAttributeMask() williamr@2: However, only data that the client has capabilities to view will be loaded williamr@2: Unauthorised data elements will be silently ignored and will remain NULL williamr@2: williamr@2: If no data at all is found the functon will leave with williamr@2: KErrNotFound williamr@2: williamr@2: If fields are not accessible for reading the function may leave with williamr@2: KErrPermissionDenied williamr@2: williamr@2: May also leave with other general error codes if there are unexpected williamr@2: problems (e.g. KErrNoMemory when out of memory) williamr@2: williamr@2: On failure, the container should be discarded or reloaded before it is used again williamr@2: williamr@2: @pre williamr@2: williamr@2: Ensure the ElementId for this container fully identifies the target data in the database williamr@2:
williamr@2: Ensure that the session object has been initialised with the correct dataset version williamr@2: Ensure that the session object has appropriate access control attributes to manage the target data in the database williamr@2: */ williamr@2: IMPORT_C void RefreshL(CMDBSession& aSession); williamr@2: williamr@2: williamr@2: /** williamr@2: StoreL - Store all fields in the database that have been changed in this container and williamr@2: create new records where necessary. williamr@2: williamr@2: StoreL is atomic for this container. An internal transaction is used even if williamr@2: no overall transaction is set by client. williamr@2: All changed fields in the element are stored in the database on success. williamr@2: No fields or records are stored in the database if the function leaves williamr@2: williamr@2: If a client has an open transaction in the session, the stored data will be available to this session as williamr@2: soon as StoreL completes but will not be visible to other sessions until the transaction completes successfully williamr@2: williamr@2: The client can request to ignore access control flags by setting the attribute mask williamr@2: CMDBSession::SetAttributeMask() williamr@2: However, only fields that the client has capabilities to write will be stored in the database williamr@2: A request to modify data in an unauthorised area of the database will cause the function to leave.with williamr@2: KErrPermissionDenied williamr@2: williamr@2: If a field already exists, StoreL will leave with williamr@2: KErrAlreadyExists williamr@2: williamr@2: May also leave with other general error codes if there are unexpected williamr@2: problems (e.g. KErrNoMemory when out of memory) williamr@2: williamr@4: Store will be atomic - all fields stored after success. No fields stored if the function leaves williamr@4: williamr@2: If StoreL fails or the later commit is not successful, The data in the container will not williamr@2: match the data in the database. williamr@2: williamr@2: On failure, the container should be discarded or repopulated before it is used again williamr@2: williamr@2: @pre williamr@2: williamr@2: Populate this container with valid data for storage williamr@2: Ensure the ElementId for this container fully identifies the target location in the database williamr@2:
williamr@2: Ensure that the session object has been initialised with the correct dataset version williamr@2: Ensure that the session object has appropriate access control attributes to manage the target data in the database williamr@2: williamr@2: */ williamr@2: IMPORT_C void StoreL(CMDBSession& aSession); williamr@2: williamr@2: williamr@2: /** williamr@2: Modify all fields in the database that have been changed in this container by the caller williamr@2: williamr@2: Modification is atomic for this container. It uses an internal transaction even if williamr@2: no overall transaction set by client. williamr@2: All changed fields in the element are modified in database on success. williamr@2: No fields are altered in the database if the function leaves williamr@2: williamr@2: Client can request to ignore access control flags by setting the attribute mask williamr@2: CMDBSession::SetAttributeMask() williamr@2: However, only fields that the client has capabilities to alter will be modified.in the database williamr@2: A request to modify data in an unauthorised area will cause the function to leave.with williamr@2: KErrPermissionDenied williamr@4: williamr@2: williamr@2: May also leave with other general error codes if there are unexpected williamr@2: problems (e.g. KErrNoMemory when out of memory) williamr@2: williamr@2: On failure, the container should be discarded or repopulated before it is used again williamr@2: williamr@2: @pre williamr@2: williamr@2: Populate this container with valid data for storage williamr@2: Ensure the ElementId for this container fully identifies the target data in the database williamr@2:
williamr@2: Ensure that the session object has been initialised with the correct dataset version williamr@2: Ensure that the session object has appropriate access control attributes to manage the target data in the database williamr@2: */ williamr@2: IMPORT_C void ModifyL(CMDBSession& aSession); williamr@2: williamr@2: williamr@2: /** williamr@2: Delete fields from the database. williamr@2: williamr@2: Client can request to ignore access control flags by setting the attribute mask, williamr@2: but only fields that the client has capabilities to delete will be removed. williamr@2: williamr@2: A request to delete data in unauthorised area will cause the function to leave williamr@2: williamr@2: @leave If client not authorised to read or write the data, will leave with williamr@2: KErrPermissionDenied williamr@2: May also leave with other general error codes if there are unexpected williamr@2: problems (e.g. KErrNoMemory when out of memory) williamr@2: williamr@2: @pre Ensure the ElementId for this container fully identifies the target data in the database williamr@2:
williamr@2: Ensure that the session object has appropriate access control attributes to manage the target data in the database williamr@2: Ensure the ElementId for this container correcty identifies the target data in the database williamr@2: williamr@2: */ williamr@2: IMPORT_C void DeleteL(CMDBSession& aSession); williamr@2: williamr@2: williamr@2: /** williamr@2: RequestNotification - Register for notification of events from all clients of the database williamr@2: williamr@2: aRequestStatus will be completed when the following events occur williamr@2: TransactionComplete williamr@2: TransactionRollback williamr@2: SessionClose williamr@2: williamr@2: this aRequestStatus can be cancelled by a call to williamr@2: williamr@2: MMetaDatabase::CancelNotification williamr@2: williamr@2: all outstanding aRequestStatus can be cancelled by a call to williamr@2: williamr@2: CMDBSession::CancelAllNotifications williamr@2: williamr@2: @capability WriteDeviceData williamr@2: williamr@2: @return KErrNone on success. A system wide error on failure williamr@2: williamr@2: @params aSession a valid session object williamr@2: @params aRequestStatus the requestStatus object that will be completed on notification williamr@2: williamr@2: @pre None williamr@2: @post A notification request will be outstanding williamr@2: */ williamr@2: IMPORT_C TInt RequestNotification(CMDBSession& aSession, williamr@2: TRequestStatus& aRequestStatus); williamr@2: williamr@2: /** williamr@2: CancelNotification - cancel an outstanding notification request williamr@2: williamr@2: note that all outstanding notification requests can be cancelled by a call to williamr@2: williamr@2: CMDBSession::CancelAllNotifications williamr@2: williamr@2: @pres williamr@2: williamr@2: There is an outstanding notification request williamr@2: williamr@2: */ williamr@2: IMPORT_C TInt CancelNotification(CMDBSession& aSession, williamr@2: TRequestStatus& aRequestStatus); williamr@2: williamr@2: williamr@2: protected: williamr@2: williamr@2: williamr@4: IMPORT_C explicit MMetaDatabase(); williamr@2: williamr@2: private: williamr@2: williamr@2: /* williamr@2: @internalComponent williamr@2: */ williamr@4: void DoLoadL(CMDBSessionImpl* aSession, CMDBElement* aElement, CMDBElement* aMapper, TInt& aErr, TMDBElementId aRecordId, TMDBElementId aAttributes, TBool isTheLoadForMapper = EFalse); williamr@2: williamr@2: /* williamr@2: @internalComponent williamr@2: */ williamr@4: void DoLoadL(CMDBSessionImpl* aSession, CMDBElement* aElement, CMDBElement* aMapper, TInt& aErr, TMDBElementId aRecordId, TMDBElementId aAttributes, RArray& aMatches, TBool isTheLoadForMapper = EFalse); williamr@2: williamr@2: /* williamr@2: @internalComponent williamr@2: */ williamr@2: void DoFindL(CMDBSessionImpl* aSession, CMDBElement* aElement, CMDBElement* aMapper, TInt& aErr, RArray& candidates, RArray& matches); williamr@2: williamr@2: /* williamr@2: @internalComponent williamr@2: */ williamr@2: void DoRefreshL(CMDBSessionImpl* aSession, CMDBElement* aElement, CMDBElement* aMapper, TInt &aErr); williamr@2: williamr@2: /* williamr@2: @internalComponent williamr@2: */ williamr@2: void DoStoreL(CMDBSessionImpl* aSession, CMDBElement* aElement, CMDBElement* aMapper, TInt &aErr); williamr@2: williamr@2: /* williamr@2: @internalComponent williamr@2: */ williamr@2: void DoModifyL(CMDBSessionImpl* aSession, CMDBElement* aElement, CMDBElement* aMapper, TInt &aErr); williamr@2: williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: class CMDBElement : public CBase, public MMetaDatabase williamr@4: /** williamr@2: Every item stored in the database is represented as a CMDBElement williamr@2: This class contains the id and attributes of every item in the database williamr@2: and for individual fields it also contains the value. williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: { williamr@2: public: williamr@2: williamr@2: williamr@2: /** williamr@2: Default Constructor williamr@2: */ williamr@2: IMPORT_C CMDBElement(); williamr@2: williamr@2: williamr@2: /** williamr@2: Constructor williamr@2: */ williamr@2: IMPORT_C CMDBElement(TMDBElementId aElementId); williamr@2: williamr@2: williamr@2: /** williamr@2: Destructor williamr@2: */ williamr@2: IMPORT_C ~CMDBElement(); williamr@2: williamr@2: williamr@2: // Accessors williamr@2: williamr@2: /** williamr@2: Returns the ElementId of an object of this type. williamr@2: williamr@2: The TypeId is williamr@2: williamr@2: williamr@2: williamr@2: This identifies the meaning of the field in the database schema williamr@2: It also identifies the type of the data stored in this element williamr@2: and the instance of the type williamr@2: williamr@2: */ williamr@2: IMPORT_C TMDBElementId ElementId() const; williamr@2: williamr@2: williamr@2: /** williamr@2: Returns the TypeId of an object of this type. williamr@2: williamr@2: The TypeId is williamr@2: williamr@2: williamr@2: williamr@2: This identifies the meaning of the data in this element in the database schema williamr@2: It also identifies the type of the data contained in this element williamr@2: williamr@2: For an element that is a Table or a Record, the ColumnId field will be set to williamr@2: williamr@2: KCDMaxColumnId williamr@2: */ williamr@2: IMPORT_C TMDBElementId TypeId() const; williamr@2: williamr@2: williamr@2: /** williamr@2: Returns the TableId of an object of this type. williamr@2: williamr@2: The TableId is part of the ElementId williamr@2: williamr@2: williamr@2: williamr@2: It identifies the table in the database that holds the data contained in this element williamr@2: williamr@2: */ williamr@2: IMPORT_C TMDBElementId TableId() const; williamr@2: williamr@2: williamr@2: /** williamr@2: Returns the RecordId of an object of this type. williamr@2: williamr@2: The RecordId is part of the ElementId williamr@2: williamr@2: It identifies a particular instance of this type of Element in the database williamr@2: williamr@2: */ williamr@2: IMPORT_C TInt RecordId() const; williamr@2: williamr@2: williamr@2: /** williamr@2: Returns the Attributes of an object of this type. williamr@2: williamr@2: Attributes express database access rights for the data of this element williamr@2: williamr@2: */ williamr@2: IMPORT_C TMDBAttributeFlags Attributes() const; williamr@2: williamr@2: // SETTER FUNCTIONS williamr@2: williamr@2: /** williamr@2: Sets the ElementId williamr@2: williamr@2: */ williamr@2: IMPORT_C void SetElementId(TMDBElementId aElementId); williamr@2: williamr@2: williamr@2: /** williamr@2: Sets the TypeId williamr@2: williamr@2: */ williamr@2: IMPORT_C void SetTypeId(TMDBElementId aElementId); williamr@2: williamr@2: williamr@2: /** williamr@2: Sets the RecordId williamr@2: williamr@2: */ williamr@2: IMPORT_C void SetRecordId(TInt aRecordId); williamr@2: williamr@2: williamr@2: /** williamr@2: Sets one or more attributes williamr@2: williamr@2: */ williamr@2: IMPORT_C void SetAttributes(TMDBAttributeFlags aAttributes); williamr@2: williamr@2: williamr@2: /** williamr@2: Clears one or more attributes williamr@2: williamr@2: */ williamr@2: IMPORT_C void ClearAttributes(TMDBAttributeFlags aAttributes); williamr@2: williamr@2: williamr@2: /** williamr@2: Queries the attributes williamr@2: williamr@2: Returns ETrue if all queried attributes are set williamr@2: Returns EFalse if any queried attribute is not set. williamr@2: */ williamr@2: IMPORT_C TBool IsSetAttribute(TMDBAttributeFlags aAttributes) const; williamr@2: williamr@2: williamr@2: /** williamr@2: Queries the state of the field value williamr@2: williamr@2: Returns ETrue if the value of the element is not set williamr@2: Returns EFalse if the element contains a value williamr@2: williamr@2: */ williamr@2: IMPORT_C TBool IsNull() const; williamr@2: williamr@2: williamr@2: williamr@2: EXP_DATA_VTABLE williamr@2: williamr@2: /** williamr@2: Queries the type of the field value williamr@2: williamr@2: Returns the enumeration TCDFieldValueTypes that represents the value that can be stored in this element williamr@2: williamr@2: */ williamr@2: williamr@2: virtual TCDFieldValueTypes Type()=0; williamr@2: williamr@2: /** williamr@2: @internalComponent williamr@2: */ williamr@2: TMDBElementId* Data(){return &iElementId;} williamr@2: williamr@2: protected: williamr@2: williamr@2: TMDBElementId iElementId; williamr@2: williamr@2: TAny* iValue; williamr@2: williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@4: // williamr@2: // COMMSDAT CONTAINERS williamr@2: // williamr@2: williamr@2: /** williamr@2: Commsdat Container classes qualifying numeric values williamr@4: @publishedAll williamr@2: */ williamr@2: class CMDBNumFieldBase : public CMDBElement williamr@2: { williamr@2: public: williamr@2: /** williamr@2: Default Constructor williamr@2: */ williamr@2: IMPORT_C CMDBNumFieldBase(); williamr@2: williamr@2: williamr@2: /** williamr@2: Constructor setting Field's ElementId williamr@2: */ williamr@2: IMPORT_C CMDBNumFieldBase(TMDBElementId aFieldId); williamr@4: williamr@2: williamr@2: /** williamr@2: Assignment operator for field value williamr@2: */ williamr@2: IMPORT_C CMDBNumFieldBase& operator=(const TInt aValue); williamr@2: williamr@2: IMPORT_C void SetMaxLengthL(TInt aLength); williamr@2: TMDBElementId GetL(); williamr@2: williamr@2: EXP_DATA_VTABLE williamr@4: williamr@2: williamr@4: private: williamr@2: virtual TCDFieldValueTypes Type() williamr@2: { williamr@2: return EInt; williamr@2: } williamr@2: williamr@2: }; williamr@2: williamr@2: template williamr@2: class CMDBField : public CMDBNumFieldBase williamr@2: /** williamr@2: A thin template that guards typed data access in a single CMDBElement williamr@2: This class describes a single numeric field in the database williamr@2: williamr@2: @publishedAll williamr@4: @released williamr@2: */ williamr@2: { williamr@2: public: williamr@2: williamr@2: /** williamr@2: Default Constructor williamr@2: */ williamr@2: inline CMDBField() williamr@2: { williamr@2: } williamr@2: williamr@2: /** williamr@2: Constructor setting Field's ElementId williamr@2: */ williamr@2: inline CMDBField(TMDBElementId aFieldId) williamr@2: : CMDBNumFieldBase(aFieldId) williamr@2: { williamr@2: } williamr@2: williamr@2: williamr@2: /** williamr@2: Assignment operator for field value williamr@2: */ williamr@2: inline CMDBField& operator=(const TYPE& aValue) williamr@2: { williamr@2: return (CMDBField&)CMDBNumFieldBase::operator=((TInt&)aValue); williamr@2: } williamr@2: williamr@2: williamr@2: inline CMDBField& operator=(const CMDBField& aValue) williamr@2: { williamr@2: return (CMDBField&)CMDBNumFieldBase::operator=(aValue); williamr@2: } williamr@2: williamr@2: /** williamr@2: Conversion operator for field value williamr@2: */ williamr@2: inline operator TYPE&() williamr@2: { williamr@2: return (TYPE&)iValue; williamr@2: } williamr@2: williamr@2: /** williamr@2: Conversion operator for field value williamr@2: */ williamr@2: inline CMDBField& GetL() williamr@2: { williamr@2: if(IsNull() && !(ElementId() & KCDChangedFlag)) williamr@2: { williamr@2: User::Leave(KErrNotFound); //todo commsdat specific error code williamr@2: } williamr@2: williamr@2: return (TYPE&)iValue; williamr@2: } williamr@2: williamr@2: /** williamr@2: Function for setting a value williamr@2: */ williamr@2: inline void SetL(const TYPE& aValue) williamr@2: { williamr@2: CMDBNumFieldBase::operator=(aValue); williamr@2: } williamr@2: williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@4: // williamr@2: /** williamr@2: Base Container class qualifying a text field williamr@4: @publishedAll williamr@2: */ williamr@2: class CMDBTextFieldBase : public CMDBElement williamr@2: { williamr@2: public: williamr@2: /** williamr@2: Default Constructor williamr@2: */ williamr@2: IMPORT_C CMDBTextFieldBase(); williamr@2: williamr@2: /** williamr@2: Constructor setting Field's ElementId williamr@2: */ williamr@2: IMPORT_C CMDBTextFieldBase(TMDBElementId aFieldId); williamr@2: williamr@2: williamr@2: /** williamr@2: Destructor that deletes the field value williamr@2: */ williamr@2: IMPORT_C ~CMDBTextFieldBase(); williamr@2: williamr@2: williamr@2: /** williamr@2: Assignment Operator setting Field's value williamr@2: */ williamr@2: IMPORT_C CMDBTextFieldBase& operator=(const TDesC& aValue); williamr@2: williamr@2: williamr@2: IMPORT_C void SetMaxLengthL(TInt aLength); williamr@2: williamr@2: EXP_DATA_VTABLE williamr@4: williamr@4: private: williamr@2: virtual TCDFieldValueTypes Type() williamr@2: { williamr@2: return EText; williamr@2: } williamr@2: williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: template<> williamr@2: class CMDBField : public CMDBTextFieldBase williamr@2: /** williamr@2: A thin template that guards typed data access in a single CMDBElement williamr@2: This class describes a single field in the database williamr@2: williamr@2: @publishedAll williamr@4: @released williamr@2: */ williamr@2: { williamr@2: public: williamr@2: williamr@2: /** williamr@2: Default Constructor williamr@2: */ williamr@2: inline CMDBField() williamr@2: { williamr@2: } williamr@2: williamr@2: /** williamr@2: Constructor setting Field's ElementId williamr@2: */ williamr@2: inline CMDBField(TMDBElementId aFieldId) williamr@2: : CMDBTextFieldBase(aFieldId) williamr@2: { williamr@2: } williamr@2: williamr@2: williamr@2: inline void SetMaxLengthL(TInt aLength) williamr@2: // create a new buffer if necessary. williamr@2: { williamr@2: CMDBTextFieldBase::SetMaxLengthL(aLength); williamr@2: } williamr@2: williamr@2: inline CMDBField& operator=(const TDesC& aValue) williamr@2: { williamr@2: CMDBTextFieldBase::operator=(aValue); williamr@2: return *this; williamr@2: } williamr@2: williamr@2: inline CMDBField& operator=(CMDBField& aValue) williamr@2: { williamr@2: CMDBTextFieldBase::operator=((const TDesC&)aValue); williamr@2: return *this; williamr@2: } williamr@2: williamr@2: /** williamr@2: Conversion operator for field value williamr@2: */ williamr@2: inline operator const TDesC&() williamr@2: { williamr@2: if (! iValue) williamr@2: return KNullDesC; williamr@2: williamr@2: return *(HBufC*)iValue; williamr@2: } williamr@2: williamr@2: /** williamr@2: Conversion operator for field value williamr@2: */ williamr@2: inline TDesC& GetL() williamr@2: { williamr@2: if(IsNull() && !(ElementId() & KCDChangedFlag)) williamr@2: { williamr@2: User::Leave(KErrNotFound); //todo commsdat specific error code williamr@2: } williamr@2: williamr@2: return *(HBufC*)iValue; williamr@2: } williamr@2: williamr@2: /** williamr@2: Function for setting a value williamr@2: */ williamr@2: inline void SetL(const TDesC& aValue) williamr@2: { williamr@2: SetMaxLengthL(aValue.Length()); williamr@2: CMDBTextFieldBase::operator=(aValue); williamr@2: } williamr@2: williamr@2: williamr@2: }; williamr@2: williamr@2: williamr@4: // williamr@2: /** williamr@2: Container class for qualifying binary values williamr@4: @publishedAll williamr@2: */ williamr@2: class CMDBBinFieldBase : public CMDBElement williamr@2: { williamr@2: public: williamr@2: /** williamr@2: Default Constructor williamr@2: */ williamr@2: IMPORT_C CMDBBinFieldBase(); williamr@2: williamr@2: williamr@2: /** williamr@2: Constructor setting Field's ElementId williamr@2: */ williamr@2: IMPORT_C CMDBBinFieldBase(TMDBElementId aFieldId); williamr@2: williamr@2: williamr@2: /** williamr@2: Destructor that deletes the field value williamr@2: */ williamr@2: IMPORT_C ~CMDBBinFieldBase(); williamr@2: williamr@2: williamr@2: /** williamr@2: Assignment Operator setting Field's value williamr@2: */ williamr@2: IMPORT_C CMDBBinFieldBase& operator=(const TDesC8& aValue); williamr@2: williamr@2: /** williamr@2: To allocate space for field data. williamr@2: */ williamr@2: IMPORT_C void SetMaxLengthL(TInt aLength); williamr@2: williamr@2: EXP_DATA_VTABLE williamr@4: williamr@4: private: williamr@2: virtual TCDFieldValueTypes Type() williamr@2: { williamr@2: return EDesC8; williamr@2: } williamr@2: }; williamr@2: williamr@2: williamr@2: template<> williamr@2: class CMDBField : public CMDBBinFieldBase williamr@2: /** williamr@2: A thin template that guards typed data access in a single CMDBElement williamr@2: This class describes a single field in the database williamr@2: williamr@2: @publishedAll williamr@4: @released williamr@2: */ williamr@2: { williamr@2: public: williamr@2: williamr@2: /** williamr@2: Default Constructor williamr@2: */ williamr@2: inline CMDBField() williamr@2: { williamr@2: } williamr@2: williamr@2: /** williamr@2: Constructor setting Field's ElementId williamr@2: */ williamr@2: inline CMDBField(TMDBElementId aFieldId) williamr@2: : CMDBBinFieldBase(aFieldId) williamr@2: { williamr@2: } williamr@2: williamr@2: inline void SetMaxLengthL(TInt aLength) williamr@2: // create a new buffer if necessary. williamr@2: { williamr@2: CMDBBinFieldBase::SetMaxLengthL(aLength); williamr@2: } williamr@2: williamr@2: williamr@2: inline CMDBField& operator=(const TDesC8& aValue) williamr@2: { williamr@2: return (CMDBField&)CMDBBinFieldBase::operator=(aValue); williamr@2: } williamr@2: williamr@2: williamr@2: inline CMDBField& operator=(CMDBField& aValue) williamr@2: // Copy assignment williamr@2: { williamr@2: return (CMDBField&)CMDBBinFieldBase::operator=((const TDesC8&)aValue); williamr@2: } williamr@2: williamr@2: williamr@2: /** williamr@2: Conversion operator for field value williamr@2: */ williamr@2: inline operator const TDesC8&() williamr@2: { williamr@2: if (! iValue) williamr@2: return KNullDesC8; williamr@2: williamr@2: return *(HBufC8*)iValue; williamr@2: } williamr@2: williamr@2: /** williamr@2: Conversion operator for field value williamr@2: */ williamr@2: inline TDesC8& GetL() williamr@2: { williamr@2: if(IsNull() && !(ElementId() & KCDChangedFlag)) williamr@2: { williamr@2: User::Leave(KErrNotFound); //todo commsdat specific error code williamr@2: } williamr@2: williamr@2: return *(HBufC8*)iValue; williamr@2: } williamr@2: williamr@2: /** williamr@2: Function for setting a value williamr@2: */ williamr@2: inline void SetL(const TDesC8& aValue) williamr@2: { williamr@2: SetMaxLengthL(aValue.Length()); williamr@2: CMDBBinFieldBase::operator=(aValue); williamr@2: } williamr@2: williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@4: // williamr@2: williamr@2: /** williamr@2: Base class for CMDBRecordLink williamr@4: @publishedAll williamr@2: */ williamr@2: class CMDBRecordLinkBase : public CMDBNumFieldBase williamr@2: { williamr@2: public : williamr@2: williamr@2: IMPORT_C CMDBRecordLinkBase(); williamr@2: williamr@2: IMPORT_C CMDBRecordLinkBase(TMDBElementId aLinkingFieldId); williamr@2: williamr@2: IMPORT_C CMDBRecordLinkBase(TMDBElementId aLinkingFieldId, CMDBElement* aLinkedRecord); williamr@2: williamr@2: williamr@2: IMPORT_C ~CMDBRecordLinkBase(); williamr@2: williamr@2: /** williamr@2: Assignment operator for field value williamr@2: which sets the id of the element list williamr@2: */ williamr@2: IMPORT_C CMDBRecordLinkBase& operator=(const TMDBElementId aValue); williamr@2: williamr@2: williamr@2: /** williamr@2: Conversion operator for field value williamr@2: which gets the id of the element list williamr@2: */ williamr@2: IMPORT_C operator TMDBElementId(); williamr@2: williamr@2: williamr@2: protected: williamr@2: williamr@2: EXP_DATA_VTABLE williamr@2: williamr@4: private: williamr@4: TCDFieldValueTypes Type() williamr@4: { williamr@4: return ELink; williamr@4: } williamr@2: public: williamr@2: williamr@2: // the record referenced by the link id stored in the value of this field. williamr@2: CMDBElement* iLinkedRecord; williamr@2: williamr@2: }; williamr@2: williamr@2: williamr@2: template williamr@2: class CMDBRecordLink : public CMDBRecordLinkBase williamr@2: /** williamr@2: This container expresses a 'soft-link' to a record in another table. williamr@2: williamr@2: The value of a CMDBRecordLink field as stored in the database is the williamr@2: ElementId (
) of the linked record. williamr@2: williamr@2: The linked record itself can be viewed via the iLinkedRecord member and its accessors williamr@2: williamr@4: If a record is loaded then the iLinkedRecord must be created explicitly williamr@4: by the client - either on construction, or by use of the CreateLinkL or williamr@4: SetLinkL functions. Often the linked record is not required by a caller. williamr@4: So creating it automatically would just waste memory williamr@4: williamr@4: However in the case of an explicit load of a LinkedRecord field the ILinkedRecord williamr@4: is created. williamr@2: williamr@2: When instantiating iLinkedRecord directly take care to match the object's type to the Type williamr@2: ID that will be found at the linking element. It is better to use the CreateLinkL or williamr@2: SetLinkL functions to ensure type safety williamr@2: williamr@2: Calling MMetaDatabase functions on a CMDRecordLink field directly will perform the operation williamr@2: on the field and also the linked record if it is present williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: { williamr@2: public : williamr@2: /** williamr@2: Constructor/Destructor williamr@2: */ williamr@2: williamr@2: inline CMDBRecordLink() williamr@2: : CMDBRecordLinkBase() {} williamr@2: williamr@2: /** williamr@2: Constructor williamr@2: */ williamr@2: inline CMDBRecordLink(TMDBElementId aLinkingFieldId) williamr@2: : CMDBRecordLinkBase(aLinkingFieldId) {} williamr@2: williamr@2: /** williamr@2: Constructor williamr@2: */ williamr@2: inline CMDBRecordLink(TMDBElementId aLinkingFieldId, RECORD_TYPE* aLinkedRecord) williamr@2: : CMDBRecordLinkBase(aLinkingFieldId, (CMDBElement*)aLinkedRecord) {} williamr@2: williamr@2: inline CMDBRecordLink& operator=(const TMDBElementId aValue) williamr@2: { williamr@2: return (CMDBRecordLink&)CMDBRecordLinkBase::operator=(aValue); williamr@2: } williamr@2: williamr@2: williamr@2: // SETTERS williamr@2: williamr@2: /** williamr@2: Set the field value (this will be validated on StoreL) williamr@2: */ williamr@2: inline void SetL(const TMDBElementId aValue) williamr@2: { williamr@2: CMDBRecordLinkBase::operator=(aValue); williamr@2: } williamr@2: williamr@2: williamr@2: // OPERATORS williamr@2: williamr@2: /** williamr@2: conversion operator for linked record of this type williamr@2: */ williamr@2: inline operator RECORD_TYPE*() williamr@2: { williamr@2: return static_cast(iLinkedRecord); williamr@2: } williamr@2: williamr@2: }; williamr@2: williamr@2: enum TFieldTypeAttributes williamr@2: /** williamr@2: To express type information for all MetaDatabase fields williamr@2: */ williamr@2: { williamr@4: ENoAttrs, //< No attributes associated with this field. williamr@4: ENotNull, //< Ensures the field contains a value and must not be null. williamr@2: }; williamr@2: williamr@2: typedef struct williamr@2: /** williamr@2: To express type information for all MetaDatabase fields williamr@2: */ williamr@2: { williamr@4: const TMDBElementId iTypeId; //< Identifier for the field. williamr@4: const TInt iValType; //< The field type value e.g.EText, EMedText. williamr@4: const TFieldTypeAttributes iTypeAttr; //< The field attribute, either ENoAttrs or ENotNull. williamr@4: const TText * const iTypeName; //< Name of the field type. williamr@2: williamr@2: } SRecordTypeInfo; williamr@2: williamr@2: williamr@2: #define MDB_GENERIC_TYPE_INFO(a, b, c, d) SGenericRecordTypeInfo(a, b, c, d) williamr@2: williamr@2: typedef TBuf<64> TGenericTypeName; williamr@2: williamr@2: typedef struct SGenericRecordTypeInfoTag williamr@2: /** williamr@2: To express type information for all MetaDatabase fields williamr@2: */ williamr@2: { williamr@2: SGenericRecordTypeInfoTag() williamr@2: : iTypeId(0), iValType(0), iTypeAttr(ENoAttrs) {} williamr@2: williamr@2: SGenericRecordTypeInfoTag(TMDBElementId aId, williamr@2: TInt aVal, williamr@2: TFieldTypeAttributes aAttrType) williamr@2: : iTypeId(aId), iValType(aVal), iTypeAttr(aAttrType) williamr@2: { williamr@2: } williamr@2: williamr@2: SGenericRecordTypeInfoTag(TMDBElementId aId, williamr@2: TInt aVal, williamr@2: TFieldTypeAttributes aAttrType, williamr@2: TText * const aTypeName) williamr@2: : iTypeId(aId), iValType(aVal), iTypeAttr(aAttrType), iTypeName(aTypeName) williamr@2: { williamr@2: williamr@2: } williamr@2: williamr@2: williamr@2: SGenericRecordTypeInfoTag( TMDBElementId aId, williamr@2: TInt aVal, williamr@2: TFieldTypeAttributes aAttrType, williamr@2: const TGenericTypeName& aTypeName) williamr@2: : iTypeId(aId), iValType(aVal), iTypeAttr(aAttrType), iTypeName(aTypeName) {} williamr@2: williamr@2: williamr@4: TMDBElementId iTypeId; //< Identifier for the field type. williamr@4: TInt iValType; //< The field type value e.g.EText, EMedText. williamr@4: TFieldTypeAttributes iTypeAttr; //< The type's attribute, either ENoAttrs or ENotNull williamr@4: TGenericTypeName iTypeName; //< Name of the field type. williamr@2: } SGenericRecordTypeInfo; williamr@2: williamr@2: williamr@2: williamr@2: class CMDBRecordBase : public CMDBNumFieldBase williamr@2: /** williamr@2: Base class for all MetaDatabase records williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: { williamr@2: public: williamr@2: williamr@2: inline CMDBRecordBase(){} williamr@2: inline CMDBRecordBase(TMDBElementId aElementId) williamr@2: : CMDBNumFieldBase(aElementId | KCDMaskShowFieldType){} williamr@2: williamr@2: IMPORT_C virtual CMDBElement* GetFieldByNameL(const TPtrC& aFieldName, TInt& aValType ); williamr@2: williamr@2: IMPORT_C virtual CMDBElement* GetFieldByIdL(TMDBElementId aId); williamr@2: williamr@2: IMPORT_C virtual const SRecordTypeInfo* GetRecordInfo(); williamr@2: williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: class CMDBGenericRecord : public CMDBRecordBase williamr@2: /** williamr@2: Container for data and type information in a MetaDatabase record williamr@2: For use to contain user-defined records as an alternative to declaring a williamr@2: specific record class of type CCDRecordBase williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: { williamr@2: friend class TMDBGenericRecordVisitor; williamr@2: friend class CMDBSessionImpl; williamr@2: public: williamr@2: williamr@2: williamr@2: EXP_DATA_VTABLE williamr@2: williamr@2: explicit inline CMDBGenericRecord(TMDBElementId aElementId) williamr@2: : CMDBRecordBase(aElementId) {} williamr@2: williamr@2: IMPORT_C ~CMDBGenericRecord(); williamr@2: williamr@2: IMPORT_C virtual CMDBElement* GetFieldByNameL(const TPtrC& aFieldName, TInt& aValType ); williamr@2: williamr@2: IMPORT_C CMDBElement* GetFieldByIdL(TMDBElementId aId); williamr@2: williamr@2: williamr@2: IMPORT_C void InitializeL(const TDesC& aTableName, const SGenericRecordTypeInfo* aNewTableInfo); williamr@2: williamr@2: williamr@2: private: williamr@2: williamr@2: /* williamr@2: The name of this record type williamr@2: */ williamr@2: TBuf iRecordType; williamr@2: williamr@2: /* williamr@2: array of type information about fields in this record williamr@2: order of field info should match order of fields williamr@2: */ williamr@2: RArray iRecordInfo; williamr@2: /* williamr@2: array of fields in this record williamr@2: order of fields should match order of field info williamr@2: */ williamr@2: RPointerArray iFields; williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: class CMDBRecordSetBase : public CMDBTextFieldBase williamr@2: /** williamr@2: Use this class to express a list of records MetaDatabase Element type williamr@2: Records can be ordered using the standard RPointerArray functions williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: { williamr@2: public: williamr@2: IMPORT_C CMDBRecordSetBase(); williamr@2: williamr@2: IMPORT_C CMDBRecordSetBase(TMDBElementId aElementId); williamr@2: williamr@2: IMPORT_C ~CMDBRecordSetBase(); williamr@2: williamr@2: inline CMDBRecordSetBase& operator=(const TPtrC& aValue) williamr@2: { williamr@2: return (CMDBRecordSetBase&)CMDBTextFieldBase::operator=(aValue); williamr@2: } williamr@2: williamr@2: protected: williamr@2: williamr@2: EXP_DATA_VTABLE williamr@2: williamr@2: public: williamr@2: williamr@2: RPointerArray iRecords; williamr@2: williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: template williamr@2: class CMDBRecordSet : public CMDBRecordSetBase williamr@2: /** williamr@2: Use this class to express a list of records of a particular MetaDatabase Element type williamr@2: Records can be ordered using the standard RPointerArray functions williamr@2: williamr@2: @publishedAll williamr@4: @released williamr@2: */ williamr@2: { williamr@2: public: williamr@2: williamr@2: inline CMDBRecordSet(){} williamr@2: williamr@2: inline CMDBRecordSet(TMDBElementId aElementId) williamr@2: : CMDBRecordSetBase(aElementId) {} williamr@2: williamr@2: inline CMDBRecordSet& operator=(const TPtrC& aValue) williamr@2: { williamr@2: return (CMDBRecordSet&)CMDBRecordSetBase::operator=(aValue); williamr@2: } williamr@2: williamr@2: inline TYPE* operator [](const TInt i) williamr@2: { williamr@2: return (TYPE*)iRecords[i]; williamr@2: } williamr@2: williamr@2: private: williamr@2: williamr@2: }; williamr@2: williamr@2: } //end namespace CommsDat williamr@2: williamr@2: #endif // METADATABASE_H