sl@0: // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #ifndef __D32REC_H__ sl@0: #define __D32REC_H__ sl@0: #ifndef __E32BASE_H__ sl@0: #include sl@0: #endif sl@0: #ifndef __D32DBMS_H__ sl@0: #include sl@0: #endif sl@0: #ifndef __D32DBAS__ sl@0: #include "D32DBAS.H" sl@0: #endif sl@0: sl@0: // classes used in this header sl@0: class RDbTableRow; sl@0: class MStreamBuf; sl@0: sl@0: // classes defined in this header sl@0: class TDbRecordId; sl@0: class CDbRecordBase; sl@0: class CDbRecordIter; sl@0: class CDbRecordSpace; sl@0: class CDbBlobSpace; sl@0: class CDbRecordIndex; sl@0: sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: enum TDbPosition { EDbFirst=RDbRowSet::EFirst,EDbNext=RDbRowSet::ENext,EDbPrevious=RDbRowSet::EPrevious,EDbLast=RDbRowSet::ELast }; sl@0: sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: const TUint32 KDbNullRecordIdValue=0; sl@0: class TDbRecordId sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: { sl@0: public: sl@0: TDbRecordId() {} sl@0: inline TDbRecordId(TUint32 aValue); sl@0: inline TDbRecordId& operator=(TUint32 aValue); sl@0: // sl@0: inline TBool operator==(TDbRecordId anId) const; sl@0: inline TBool operator!=(TDbRecordId anId) const; sl@0: // sl@0: inline TUint32 Value() const; sl@0: private: sl@0: TUint32 iValue; sl@0: }; sl@0: #if defined(__NO_CLASS_CONSTS__) sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: #define KDbNullRecordId TDbRecordId(KDbNullRecordIdValue) sl@0: #else sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: const TDbRecordId KDbNullRecordId=TDbRecordId(KDbNullRecordIdValue); sl@0: #endif sl@0: sl@0: class CDbRecordBase : public CBase sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: { sl@0: private: sl@0: enum {EOpen=0x1,EModified=0x2,EBroken=0x4}; sl@0: protected: sl@0: CDbRecordBase() {} sl@0: public: sl@0: inline TBool OpenL(); sl@0: IMPORT_C void FlushL(); sl@0: inline void Abandon(); sl@0: inline TBool IsBroken() const; sl@0: // sl@0: static void DoFlushL(CDbRecordBase* aRec); sl@0: static void DoDelete(CDbRecordBase* aRec); sl@0: static void DoAbandon(CDbRecordBase* aRec); sl@0: protected: sl@0: IMPORT_C void TouchL(); sl@0: inline void MarkIntact(); sl@0: private: sl@0: IMPORT_C TBool DoRestoreL(); sl@0: IMPORT_C virtual TBool RestoreL(); sl@0: IMPORT_C virtual void AboutToModifyL(); sl@0: IMPORT_C virtual void SynchL(); sl@0: private: sl@0: TUint iFlags; sl@0: }; sl@0: sl@0: class CDbRecordIter : public CBase sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: { sl@0: public: sl@0: enum TDeleted {EAtRow,ENoRow,ENotSupported}; sl@0: protected: sl@0: IMPORT_C CDbRecordIter(CDbRecordBase& aHost); sl@0: public: sl@0: IMPORT_C ~CDbRecordIter(); sl@0: inline CDbRecordBase& Host() const; sl@0: // pure virtual sl@0: virtual TInt Count() const =0; sl@0: virtual TDbRecordId CurrentL() =0; sl@0: virtual TBool GotoL(TDbPosition aPosition) =0; sl@0: virtual TBool GotoL(TDbRecordId aRecordId,RDbTableRow& aBuffer) =0; // re-synchronise sl@0: virtual TBool SeekL(const TDbLookupKey& aKey,RDbTable::TComparison aComparison) =0; sl@0: inline TDeleted DeletedL(TDbPosition aPosition,TDbRecordId aRecordId); // goto next id sl@0: inline TDeleted DeletedL(TDbPosition aPosition,TDbRecordId aRecordId,const RDbTableRow& aRow); // goto next id sl@0: // sl@0: virtual TDeleted DoDeletedL(TDbPosition aPosition,TDbRecordId aRecordId,const RDbTableRow* aRow) =0; sl@0: private: sl@0: CDbRecordBase& iHost; sl@0: }; sl@0: sl@0: class CDbRecordSpace : public CDbRecordBase sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: { sl@0: protected: sl@0: CDbRecordSpace() {} sl@0: public: sl@0: virtual TBool ExistsL(TDbRecordId aRecordId) =0; sl@0: virtual TPtrC8 ReadL(TDbRecordId aRecordId) const =0; sl@0: TUint8* ReplaceL(TDbRecordId aRecordId,TInt aRecordSize); sl@0: virtual TUint AutoIncrementL() =0; sl@0: TUint8* NewL(TInt aRecordSize); sl@0: virtual TDbRecordId AppendL() =0; sl@0: void EraseL(TDbRecordId aRecordId); sl@0: virtual CDbRecordIter* IteratorL() =0; sl@0: private: sl@0: virtual TUint8* DoReplaceL(TDbRecordId aRecordId,TInt aRecordSize) =0; sl@0: virtual TUint8* DoNewL(TInt aRecordSize) =0; sl@0: virtual void DoEraseL(TDbRecordId aRecordId) =0; sl@0: }; sl@0: sl@0: class CDbBlobSpace : public CDbRecordBase sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: { sl@0: protected: sl@0: CDbBlobSpace() {} sl@0: public: sl@0: virtual MStreamBuf* ReadL(TDbBlobId aBlobId,TDbColType aType) const =0; sl@0: IMPORT_C MStreamBuf* ReadLC(TDbBlobId aBlobId,TDbColType aType) const; sl@0: IMPORT_C MStreamBuf* CreateL(TDbBlobId &aBlobId,TDbColType aType); sl@0: IMPORT_C TDbBlobId CreateL(TDbColType aType,const TAny* aBuf,TInt aLength); sl@0: IMPORT_C void DeleteL(TDbBlobId aBlobId); sl@0: IMPORT_C TInt Delete(TDbBlobId aBlobId); sl@0: inline TInt InlineLimit() const; sl@0: protected: sl@0: inline void SetInlineLimit(TInt anInlineLimit); sl@0: private: sl@0: virtual MStreamBuf* DoCreateL(TDbBlobId &aBlobId,TDbColType aType) =0; sl@0: virtual void DoDeleteL(TDbBlobId aBlobId) =0; sl@0: private: sl@0: TInt iInlineLimit; sl@0: }; sl@0: sl@0: class CDbRecordIndex : public CDbRecordBase sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: { sl@0: public: sl@0: enum TFind {ENoMatch,EKeyMatch,EEntryMatch}; sl@0: enum TInclusion {EIncludeLower=0x1,EIncludeUpper=0x2,EIncludeBoth=0x3}; sl@0: protected: sl@0: CDbRecordIndex() {} sl@0: public: sl@0: virtual TFind FindL(TDbRecordId aRecordId,const RDbTableRow& aRow) =0; sl@0: TBool InsertL(TDbRecordId aRecordId,const RDbTableRow& aRow); sl@0: void DeleteL(TDbRecordId aRecordId,const RDbTableRow& aRow); sl@0: virtual CDbRecordIter* IteratorL(TUint aInclusion=0,const TDbLookupKey* aLowerBound=0,const TDbLookupKey* aUpperBound=0) =0; sl@0: private: sl@0: virtual TBool DoInsertL(TDbRecordId aRecordId,const RDbTableRow& aRow) =0; sl@0: virtual void DoDeleteL(TDbRecordId aRecordId,const RDbTableRow& aRow) =0; sl@0: }; sl@0: sl@0: #include "D32REC.INL" sl@0: #endif