os/persistentdata/persistentstorage/dbms/inc/D32REC.H
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
#ifndef __D32REC_H__
sl@0
    17
#define __D32REC_H__
sl@0
    18
#ifndef __E32BASE_H__
sl@0
    19
#include <e32base.h>
sl@0
    20
#endif
sl@0
    21
#ifndef __D32DBMS_H__
sl@0
    22
#include <d32dbms.h>
sl@0
    23
#endif
sl@0
    24
#ifndef __D32DBAS__
sl@0
    25
#include "D32DBAS.H"
sl@0
    26
#endif
sl@0
    27
sl@0
    28
// classes used in this header
sl@0
    29
class RDbTableRow;
sl@0
    30
class MStreamBuf;
sl@0
    31
sl@0
    32
// classes defined in this header
sl@0
    33
class TDbRecordId;
sl@0
    34
class CDbRecordBase;
sl@0
    35
class CDbRecordIter;
sl@0
    36
class CDbRecordSpace;
sl@0
    37
class CDbBlobSpace;
sl@0
    38
class CDbRecordIndex;
sl@0
    39
sl@0
    40
/**
sl@0
    41
@internalComponent
sl@0
    42
*/
sl@0
    43
enum TDbPosition { EDbFirst=RDbRowSet::EFirst,EDbNext=RDbRowSet::ENext,EDbPrevious=RDbRowSet::EPrevious,EDbLast=RDbRowSet::ELast };
sl@0
    44
sl@0
    45
/**
sl@0
    46
@internalComponent
sl@0
    47
*/
sl@0
    48
const TUint32 KDbNullRecordIdValue=0;
sl@0
    49
class TDbRecordId
sl@0
    50
/**
sl@0
    51
@internalComponent
sl@0
    52
*/
sl@0
    53
	{
sl@0
    54
public:
sl@0
    55
	TDbRecordId() {}
sl@0
    56
	inline TDbRecordId(TUint32 aValue);
sl@0
    57
	inline TDbRecordId& operator=(TUint32 aValue);
sl@0
    58
//
sl@0
    59
	inline TBool operator==(TDbRecordId anId) const;
sl@0
    60
	inline TBool operator!=(TDbRecordId anId) const;
sl@0
    61
//
sl@0
    62
	inline TUint32 Value() const;
sl@0
    63
private:
sl@0
    64
	TUint32 iValue;
sl@0
    65
	};
sl@0
    66
#if defined(__NO_CLASS_CONSTS__)
sl@0
    67
/**
sl@0
    68
@internalComponent
sl@0
    69
*/
sl@0
    70
#define KDbNullRecordId TDbRecordId(KDbNullRecordIdValue)
sl@0
    71
#else
sl@0
    72
/**
sl@0
    73
@internalComponent
sl@0
    74
*/
sl@0
    75
const TDbRecordId KDbNullRecordId=TDbRecordId(KDbNullRecordIdValue);
sl@0
    76
#endif
sl@0
    77
sl@0
    78
class CDbRecordBase : public CBase
sl@0
    79
/**
sl@0
    80
@internalComponent
sl@0
    81
*/
sl@0
    82
	{
sl@0
    83
private:
sl@0
    84
	enum {EOpen=0x1,EModified=0x2,EBroken=0x4};
sl@0
    85
protected:
sl@0
    86
	CDbRecordBase() {}
sl@0
    87
public:
sl@0
    88
	inline TBool OpenL();
sl@0
    89
	IMPORT_C void FlushL();
sl@0
    90
	inline void Abandon();
sl@0
    91
	inline TBool IsBroken() const;
sl@0
    92
//
sl@0
    93
	static void DoFlushL(CDbRecordBase* aRec);
sl@0
    94
	static void DoDelete(CDbRecordBase* aRec);
sl@0
    95
	static void DoAbandon(CDbRecordBase* aRec);
sl@0
    96
protected:
sl@0
    97
	IMPORT_C void TouchL();
sl@0
    98
	inline void MarkIntact();
sl@0
    99
private:
sl@0
   100
	IMPORT_C TBool DoRestoreL();
sl@0
   101
	IMPORT_C virtual TBool RestoreL();
sl@0
   102
	IMPORT_C virtual void AboutToModifyL();
sl@0
   103
	IMPORT_C virtual void SynchL();
sl@0
   104
private:
sl@0
   105
	TUint iFlags;
sl@0
   106
	};
sl@0
   107
sl@0
   108
class CDbRecordIter : public CBase
sl@0
   109
/**
sl@0
   110
@internalComponent
sl@0
   111
*/
sl@0
   112
	{
sl@0
   113
public:
sl@0
   114
	enum TDeleted {EAtRow,ENoRow,ENotSupported};
sl@0
   115
protected:
sl@0
   116
	IMPORT_C CDbRecordIter(CDbRecordBase& aHost);
sl@0
   117
public:
sl@0
   118
	IMPORT_C ~CDbRecordIter();
sl@0
   119
	inline CDbRecordBase& Host() const;
sl@0
   120
// pure virtual
sl@0
   121
	virtual TInt Count() const =0;
sl@0
   122
	virtual TDbRecordId CurrentL() =0;
sl@0
   123
	virtual TBool GotoL(TDbPosition aPosition) =0;
sl@0
   124
	virtual TBool GotoL(TDbRecordId aRecordId,RDbTableRow& aBuffer) =0;	// re-synchronise
sl@0
   125
	virtual TBool SeekL(const TDbLookupKey& aKey,RDbTable::TComparison aComparison) =0;
sl@0
   126
	inline TDeleted DeletedL(TDbPosition aPosition,TDbRecordId aRecordId);					// goto next id
sl@0
   127
	inline TDeleted DeletedL(TDbPosition aPosition,TDbRecordId aRecordId,const RDbTableRow& aRow);	// goto next id
sl@0
   128
//
sl@0
   129
	virtual TDeleted DoDeletedL(TDbPosition aPosition,TDbRecordId aRecordId,const RDbTableRow* aRow) =0;
sl@0
   130
private:
sl@0
   131
	CDbRecordBase& iHost;
sl@0
   132
	};
sl@0
   133
sl@0
   134
class CDbRecordSpace : public CDbRecordBase
sl@0
   135
/**
sl@0
   136
@internalComponent
sl@0
   137
*/
sl@0
   138
	{
sl@0
   139
protected:
sl@0
   140
	CDbRecordSpace() {}
sl@0
   141
public:
sl@0
   142
	virtual TBool ExistsL(TDbRecordId aRecordId) =0;
sl@0
   143
	virtual TPtrC8 ReadL(TDbRecordId aRecordId) const =0;
sl@0
   144
	TUint8* ReplaceL(TDbRecordId aRecordId,TInt aRecordSize);
sl@0
   145
	virtual TUint AutoIncrementL() =0;
sl@0
   146
	TUint8* NewL(TInt aRecordSize);
sl@0
   147
	virtual TDbRecordId AppendL() =0;
sl@0
   148
	void EraseL(TDbRecordId aRecordId);
sl@0
   149
	virtual CDbRecordIter* IteratorL() =0;
sl@0
   150
private:
sl@0
   151
	virtual TUint8* DoReplaceL(TDbRecordId aRecordId,TInt aRecordSize) =0;
sl@0
   152
	virtual TUint8* DoNewL(TInt aRecordSize) =0;
sl@0
   153
	virtual void DoEraseL(TDbRecordId aRecordId) =0;
sl@0
   154
	};
sl@0
   155
sl@0
   156
class CDbBlobSpace : public CDbRecordBase
sl@0
   157
/**
sl@0
   158
@internalComponent
sl@0
   159
*/
sl@0
   160
	{
sl@0
   161
protected:
sl@0
   162
	CDbBlobSpace() {}
sl@0
   163
public:
sl@0
   164
	virtual MStreamBuf* ReadL(TDbBlobId aBlobId,TDbColType aType) const =0;
sl@0
   165
	IMPORT_C MStreamBuf* ReadLC(TDbBlobId aBlobId,TDbColType aType) const;
sl@0
   166
	IMPORT_C MStreamBuf* CreateL(TDbBlobId &aBlobId,TDbColType aType);
sl@0
   167
	IMPORT_C TDbBlobId CreateL(TDbColType aType,const TAny* aBuf,TInt aLength);
sl@0
   168
	IMPORT_C void DeleteL(TDbBlobId aBlobId);
sl@0
   169
	IMPORT_C TInt Delete(TDbBlobId aBlobId);
sl@0
   170
	inline TInt InlineLimit() const;
sl@0
   171
protected:
sl@0
   172
	inline void SetInlineLimit(TInt anInlineLimit);
sl@0
   173
private:
sl@0
   174
	virtual MStreamBuf* DoCreateL(TDbBlobId &aBlobId,TDbColType aType) =0;
sl@0
   175
	virtual void DoDeleteL(TDbBlobId aBlobId) =0;
sl@0
   176
private:
sl@0
   177
	TInt iInlineLimit;
sl@0
   178
	};
sl@0
   179
sl@0
   180
class CDbRecordIndex : public CDbRecordBase
sl@0
   181
/**
sl@0
   182
@internalComponent
sl@0
   183
*/
sl@0
   184
	{
sl@0
   185
public:
sl@0
   186
	enum TFind {ENoMatch,EKeyMatch,EEntryMatch};
sl@0
   187
	enum TInclusion {EIncludeLower=0x1,EIncludeUpper=0x2,EIncludeBoth=0x3};
sl@0
   188
protected:
sl@0
   189
	CDbRecordIndex() {}
sl@0
   190
public:
sl@0
   191
	virtual TFind FindL(TDbRecordId aRecordId,const RDbTableRow& aRow) =0;
sl@0
   192
	TBool InsertL(TDbRecordId aRecordId,const RDbTableRow& aRow);
sl@0
   193
	void DeleteL(TDbRecordId aRecordId,const RDbTableRow& aRow);
sl@0
   194
	virtual CDbRecordIter* IteratorL(TUint aInclusion=0,const TDbLookupKey* aLowerBound=0,const TDbLookupKey* aUpperBound=0) =0;
sl@0
   195
private:
sl@0
   196
	virtual TBool DoInsertL(TDbRecordId aRecordId,const RDbTableRow& aRow) =0;
sl@0
   197
	virtual void DoDeleteL(TDbRecordId aRecordId,const RDbTableRow& aRow) =0;
sl@0
   198
	};
sl@0
   199
sl@0
   200
#include "D32REC.INL"
sl@0
   201
#endif