os/persistentdata/persistentstorage/dbms/pcdbms/inc/D32TABLE.H
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
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
#if !defined(__D32TABLE_H__)
sl@0
    17
#define __D32TABLE_H__
sl@0
    18
#if !defined(__D32DBAS_H__)
sl@0
    19
#include "D32DBAS.H"
sl@0
    20
#endif
sl@0
    21
#if !defined(__D32REC_H__)
sl@0
    22
#include "D32REC.H"
sl@0
    23
#endif
sl@0
    24
#if !defined(__D32CACHE_H__)
sl@0
    25
#include "D32CACHE.H"
sl@0
    26
#endif
sl@0
    27
sl@0
    28
// classes defined in this file
sl@0
    29
class TDbGenerationMark;
sl@0
    30
class TDbColumnDef;
sl@0
    31
class HDbColumnSet;
sl@0
    32
class CDbTableIndexDef;
sl@0
    33
class RDbIndexes;
sl@0
    34
class RDbTableSchema;
sl@0
    35
class CDbTableDef;
sl@0
    36
class RDbTableRow;
sl@0
    37
class CDbTable;
sl@0
    38
class RDbTables;
sl@0
    39
class RDbTransaction;
sl@0
    40
class CDbTableDatabase;
sl@0
    41
sl@0
    42
// classes also referenced
sl@0
    43
class CDbTableSource;
sl@0
    44
class CDbBlobCleanup;
sl@0
    45
sl@0
    46
/**
sl@0
    47
@internalComponent
sl@0
    48
*/
sl@0
    49
const TInt KDbTableMaxIndexes = 32;
sl@0
    50
sl@0
    51
/**
sl@0
    52
@internalComponent
sl@0
    53
*/
sl@0
    54
class CDbTableIndexDef : public CBase
sl@0
    55
	{
sl@0
    56
	friend class RDbIndexes;
sl@0
    57
public:
sl@0
    58
	IMPORT_C CDbTableIndexDef();
sl@0
    59
	IMPORT_C ~CDbTableIndexDef();
sl@0
    60
	IMPORT_C void ConstructL( const TDesC& aName );
sl@0
    61
	inline const TDesC& Name() const;
sl@0
    62
	inline const CDbKey& Key() const;
sl@0
    63
	inline CDbKey& Key();
sl@0
    64
private:
sl@0
    65
	TSglQueLink iLink;
sl@0
    66
	HBufC* iName;
sl@0
    67
	CDbKey iKey;
sl@0
    68
	};
sl@0
    69
sl@0
    70
/**
sl@0
    71
@internalComponent
sl@0
    72
*/
sl@0
    73
class RDbIndexes
sl@0
    74
	{
sl@0
    75
	friend class CDbTableDef;
sl@0
    76
public:
sl@0
    77
	inline void Add( CDbTableIndexDef* aDef );
sl@0
    78
	inline void Remove( CDbTableIndexDef* aDef );
sl@0
    79
	inline const TSglQueBase& AsQue() const;
sl@0
    80
	CDbTableIndexDef* Find( const TDesC& aName ) const;
sl@0
    81
	CDbTableIndexDef& FindL( const TDesC& aName ) const;
sl@0
    82
	IMPORT_C TInt Count() const;
sl@0
    83
private:
sl@0
    84
	inline RDbIndexes();
sl@0
    85
	void Close();
sl@0
    86
private:
sl@0
    87
	TSglQue<CDbTableIndexDef> iRep;
sl@0
    88
	};
sl@0
    89
sl@0
    90
/**
sl@0
    91
@internalComponent
sl@0
    92
*/
sl@0
    93
class TDbColumnDef
sl@0
    94
	{
sl@0
    95
public:
sl@0
    96
	IMPORT_C void SetL( const TDbCol& aCol );
sl@0
    97
	IMPORT_C void SetL( const TDbColumnDef& aCol );
sl@0
    98
	void AsTDbCol( TDbCol& aColumn ) const;
sl@0
    99
	inline TDbColType Type() const;
sl@0
   100
private:
sl@0
   101
// don't allow copies
sl@0
   102
	void operator=( const TDbColumnDef& );
sl@0
   103
public:
sl@0
   104
	// flags used by AlterTable
sl@0
   105
	enum { EDropped = 0x1, EChangedType = 0x2, EChangedLen = 0x4, EAdded = 0x8 };
sl@0
   106
public:
sl@0
   107
	HBufC* iName;
sl@0
   108
	TInt iMaxLength;
sl@0
   109
	TUint8 iType;
sl@0
   110
	TUint8 iAttributes;
sl@0
   111
	TUint8 iFlags;
sl@0
   112
	TUint8 iReserved;
sl@0
   113
	};
sl@0
   114
sl@0
   115
/**
sl@0
   116
@internalComponent
sl@0
   117
*/
sl@0
   118
class HDbColumnSet
sl@0
   119
	{
sl@0
   120
private:
sl@0
   121
	enum { ELongColumns = 0x1, EAutoIncrement = 0x2 };
sl@0
   122
public:
sl@0
   123
	typedef TDbColumnDef* TIterator;
sl@0
   124
	typedef const TDbColumnDef* TIteratorC;
sl@0
   125
public:
sl@0
   126
	static HDbColumnSet* NewL( TInt aCount );
sl@0
   127
	~HDbColumnSet();
sl@0
   128
//
sl@0
   129
	inline TIterator Begin();
sl@0
   130
	void Complete();
sl@0
   131
	IMPORT_C TInt Count() const;
sl@0
   132
	inline TIteratorC Begin() const;
sl@0
   133
	inline TIteratorC End() const;
sl@0
   134
	inline const TDbColumnDef& operator[]( TDbColNo anIndex ) const;
sl@0
   135
	IMPORT_C TIteratorC ColumnL( const TDesC& aColumn ) const;
sl@0
   136
	inline TIterator ColumnL( const TDesC& aColumn );
sl@0
   137
	IMPORT_C TDbColNo ColNoL( const TDesC& aColumn ) const;
sl@0
   138
	inline TBool HasLongColumns() const;
sl@0
   139
	inline TBool HasAutoIncrement() const;
sl@0
   140
private:
sl@0
   141
	HDbColumnSet( TInt aCount );
sl@0
   142
	const TIteratorC* IndexL() const;
sl@0
   143
private:
sl@0
   144
	TUint iAttributes;
sl@0
   145
	TIteratorC* iIndex;
sl@0
   146
	const TDbColumnDef* const iEnd;
sl@0
   147
	TDbColumnDef iColumns[1];		// at least one
sl@0
   148
	};
sl@0
   149
sl@0
   150
/**
sl@0
   151
@internalComponent
sl@0
   152
*/
sl@0
   153
class CDbTableDef : public CBase
sl@0
   154
	{
sl@0
   155
	friend class RDbTableSchema;
sl@0
   156
public:
sl@0
   157
	IMPORT_C ~CDbTableDef();
sl@0
   158
	inline const TDesC& Name() const;
sl@0
   159
	inline HDbColumnSet& Columns();
sl@0
   160
	inline const HDbColumnSet& Columns() const;
sl@0
   161
	inline RDbIndexes& Indexes();
sl@0
   162
	inline const RDbIndexes& Indexes() const;
sl@0
   163
	IMPORT_C virtual void Changed();
sl@0
   164
//
sl@0
   165
	inline const CDbTableIndexDef* Key( const TDesC& aColumn ) const;
sl@0
   166
	inline TBool IsIndexed( const TDesC& aColumn ) const;
sl@0
   167
//
sl@0
   168
	virtual void AlteredColumnSetL( HDbColumnSet& aSet, const CDbColSet& aChange, const CDbColSet& aAdd ) = 0;
sl@0
   169
	void ExchangeColumnSet( HDbColumnSet* aSet );
sl@0
   170
protected:
sl@0
   171
	IMPORT_C CDbTableDef();
sl@0
   172
	IMPORT_C void ConstructL( const TDesC& aName, TInt aColumnCount );
sl@0
   173
private:
sl@0
   174
	const CDbTableIndexDef* FindKey( const TDesC& aColumn, TBool aFirstColumn ) const;
sl@0
   175
private:
sl@0
   176
	TSglQueLink iLink;
sl@0
   177
	HBufC* iName;
sl@0
   178
	HDbColumnSet* iColumns;
sl@0
   179
	RDbIndexes iIndexes;
sl@0
   180
	};
sl@0
   181
sl@0
   182
/**
sl@0
   183
@internalComponent
sl@0
   184
*/
sl@0
   185
class RDbTableSchema
sl@0
   186
	{
sl@0
   187
	friend class CDbTableDatabase;
sl@0
   188
public:
sl@0
   189
	inline void Loaded();
sl@0
   190
	inline operator TSglQueBase&();
sl@0
   191
	inline void Add( CDbTableDef* aDef );
sl@0
   192
//
sl@0
   193
	inline TBool IsEmpty() const;
sl@0
   194
	CDbTableDef* Find( const TDesC& aTable );
sl@0
   195
	CDbTableDef& FindL( const TDesC& aTable );
sl@0
   196
private:
sl@0
   197
	inline RDbTableSchema();
sl@0
   198
	void Close();
sl@0
   199
//
sl@0
   200
	inline TBool IsLoaded() const;
sl@0
   201
	void Discard();
sl@0
   202
	inline void Remove( CDbTableDef* aDef );
sl@0
   203
private:
sl@0
   204
	TSglQue<CDbTableDef> iRep;
sl@0
   205
	TBool iLoaded;
sl@0
   206
	};
sl@0
   207
sl@0
   208
/**
sl@0
   209
@internalComponent
sl@0
   210
*/
sl@0
   211
typedef TUint TDbGeneration;
sl@0
   212
sl@0
   213
/**
sl@0
   214
@internalComponent
sl@0
   215
*/
sl@0
   216
class TDbGenerationMark
sl@0
   217
	{
sl@0
   218
public:
sl@0
   219
	inline void Construct( const TDbGeneration& aGeneration );
sl@0
   220
	inline void Mark();
sl@0
   221
	inline TBool Changed() const;
sl@0
   222
private:
sl@0
   223
	const TDbGeneration* iGeneration;
sl@0
   224
	TDbGeneration iMark;
sl@0
   225
	};
sl@0
   226
sl@0
   227
/**
sl@0
   228
@internalComponent
sl@0
   229
*/
sl@0
   230
class CDbTable : public CBase
sl@0
   231
	{
sl@0
   232
	friend class RDbTables;
sl@0
   233
public:
sl@0
   234
	class TValid;
sl@0
   235
	friend class TValid;
sl@0
   236
	enum { EUnavailableSpan = -1, EFullIndexSpan = 100 };
sl@0
   237
protected:
sl@0
   238
	IMPORT_C CDbTable( CDbTableDatabase& aDatabase, const CDbTableDef& aDef );
sl@0
   239
	IMPORT_C ~CDbTable();
sl@0
   240
public:
sl@0
   241
	void Open();
sl@0
   242
	void Close();
sl@0
   243
	void FlushL();
sl@0
   244
	void Abandon();
sl@0
   245
	void Release();
sl@0
   246
	void Idle();
sl@0
   247
//
sl@0
   248
	inline TBool IsActive() const;
sl@0
   249
	inline TBool IsIdle() const;
sl@0
   250
	inline const CDbTableDef& Def() const;
sl@0
   251
	inline CDbTableDatabase& Database();
sl@0
   252
//
sl@0
   253
	inline const TDbGeneration& Generation() const;
sl@0
   254
	TBool ExistsL( TDbRecordId aRecordId );
sl@0
   255
	void NewRowL( RDbRow& aRow );
sl@0
   256
	void ReadRowL( RDbRow& aRow, TDbRecordId aRecordId );
sl@0
   257
	void PrepareReplaceL( const RDbTableRow& aRow, TDbRecordId aRecordId );
sl@0
   258
	void ReplaceRowL( RDbTableRow& aRow, TDbRecordId aRecordId );
sl@0
   259
	void PrepareAppendL( const RDbTableRow& aRow );
sl@0
   260
	TDbRecordId AppendRowL( const RDbTableRow& aRow );
sl@0
   261
	void DeleteRowL( RDbTableRow& aRow, TDbRecordId aRecordId );
sl@0
   262
	void DuplicateBlobsL( RDbRow& aRow );
sl@0
   263
	IMPORT_C void DiscardBlobsL( RDbRow& aRow );
sl@0
   264
//
sl@0
   265
	IMPORT_C CDbRecordSpace& RecordsL();
sl@0
   266
	IMPORT_C CDbRecordIndex& IndexL( const CDbTableIndexDef& anIndex );
sl@0
   267
	IMPORT_C CDbBlobSpace* BlobsL();
sl@0
   268
	virtual CDbRecordIndex* RecordIndexL( const CDbTableIndexDef& anIndex ) = 0;
sl@0
   269
//
sl@0
   270
	CDbRecordIter* IteratorL();
sl@0
   271
	IMPORT_C virtual TInt IndexSpanL( const CDbTableIndexDef& aIndex, TUint aInclusion, const TDbLookupKey* aLowerBound, const TDbLookupKey* aUpperBound );
sl@0
   272
	CDbRecordIter* IteratorL( const CDbTableIndexDef& aIndex, TUint aInclusion = 0, const TDbLookupKey* aLowerBound = 0, const TDbLookupKey* aUpperBound = 0 );
sl@0
   273
	CDbRecordIter* IteratorL( const TDesC& aIndex );
sl@0
   274
private:
sl@0
   275
	typedef void ( *TBlobFuncL )( CDbBlobSpace& aBlobStore, TDbBlob& aBlob, TDbColType aType, CDbBlobCleanup* aCleanup );
sl@0
   276
private:
sl@0
   277
	inline void Discard();
sl@0
   278
	void Disconnect();
sl@0
   279
	inline TBool InUse() const;
sl@0
   280
	inline RDbCache& Cache();
sl@0
   281
//
sl@0
   282
	void ApplyToBlobsL( RDbRow& aRow, TBlobFuncL aFuncL, CDbBlobCleanup* aCleanup = 0 );
sl@0
   283
	void ApplyToComponentsL( void ( *anOperationL )( CDbRecordBase* ) );
sl@0
   284
	void EnsureIndexesL();
sl@0
   285
	void ValidateL( const RDbRow& aRow );
sl@0
   286
	void CheckInliningL( RDbRow& aRow );
sl@0
   287
	void DoReplaceRowL( const RDbRow& aRow, TDbRecordId aRecordId );
sl@0
   288
//
sl@0
   289
	virtual CDbRecordSpace* RecordSpaceL() = 0;
sl@0
   290
	virtual CDbBlobSpace* BlobSpaceL() = 0;
sl@0
   291
//
sl@0
   292
	virtual void CopyToRowL( RDbRow& aRow, const TDesC8& aRecord ) = 0;
sl@0
   293
	virtual TInt RecordLength( const RDbRow& aRow ) = 0;
sl@0
   294
	virtual void CopyFromRow( TUint8* aRecord, const RDbRow& aRow ) = 0;
sl@0
   295
private:
sl@0
   296
	enum { EIdle = -1, ECached = -2 };
sl@0
   297
private:
sl@0
   298
	TSglQueLink iLink;
sl@0
   299
	TInt iRef;
sl@0
   300
	CDbTableDatabase* iDatabase;
sl@0
   301
	const CDbTableDef* iDef;
sl@0
   302
	TDbGeneration iGeneration;
sl@0
   303
	CDbRecordSpace* iRecords;
sl@0
   304
	CDbBlobSpace* iBlobs;
sl@0
   305
	CDbRecordIndex* iIndexes[KDbTableMaxIndexes];
sl@0
   306
	CDbRecordIndex** iIndexesEnd;
sl@0
   307
	TUint32 iUpdateMap;
sl@0
   308
	};
sl@0
   309
sl@0
   310
/**
sl@0
   311
@internalComponent
sl@0
   312
*/
sl@0
   313
class RDbTableRow : public RDbRow
sl@0
   314
	{
sl@0
   315
public:
sl@0
   316
	inline RDbTableRow();
sl@0
   317
	void Open( CDbTable* aTable );
sl@0
   318
	void Close();
sl@0
   319
//
sl@0
   320
	inline CDbTable& Table() const;
sl@0
   321
	IMPORT_C void ReadL( TDbRecordId aRecordId );
sl@0
   322
	void NewL( TDbRecordId aCopyRecord );
sl@0
   323
	void PrepareAppendL();
sl@0
   324
	TDbRecordId AppendL();
sl@0
   325
	void PrepareReplaceL();
sl@0
   326
	TDbRecordId ReplaceL();
sl@0
   327
	void DeleteL( TDbRecordId aRecordId );
sl@0
   328
private:
sl@0
   329
	TDbGenerationMark iMark;
sl@0
   330
	TDbRecordId iRecord;
sl@0
   331
	CDbTable* iTable;
sl@0
   332
	};
sl@0
   333
sl@0
   334
/**
sl@0
   335
implementation class
sl@0
   336
@internalComponent
sl@0
   337
*/
sl@0
   338
class RDbTables		
sl@0
   339
	{
sl@0
   340
public:
sl@0
   341
	inline RDbTables();
sl@0
   342
	void Close();
sl@0
   343
//
sl@0
   344
	inline TBool IsEmpty() const;
sl@0
   345
	inline void Add( CDbTable& aTable );
sl@0
   346
	inline void Remove( CDbTable& aTable );
sl@0
   347
	CDbTable* Find( const TDesC& aTable );
sl@0
   348
	inline operator TSglQueBase&();
sl@0
   349
private:
sl@0
   350
	TSglQue<CDbTable> iRep;
sl@0
   351
	};
sl@0
   352
sl@0
   353
/**
sl@0
   354
@internalComponent
sl@0
   355
*/
sl@0
   356
enum TDbLockType { EDbReadLock = 0, EDbXReadLock, EDbWriteLock, EDbCompactLock, EDbRecoveryLock, EDbSchemaLock };
sl@0
   357
sl@0
   358
/**
sl@0
   359
implementation class
sl@0
   360
@internalComponent
sl@0
   361
*/
sl@0
   362
class RDbTransaction
sl@0
   363
	{
sl@0
   364
private:
sl@0
   365
	class CNotifier;
sl@0
   366
	friend class CNotifier;
sl@0
   367
public:
sl@0
   368
	inline RDbTransaction();
sl@0
   369
	inline void Open( CDbTableDatabase& aDatabase );
sl@0
   370
	void Close();
sl@0
   371
//
sl@0
   372
	inline const TDbGeneration& RollbackGeneration() const;
sl@0
   373
	inline CDbTableDatabase& Database();
sl@0
   374
//
sl@0
   375
	void BeginL( const CDbObject& aObject );
sl@0
   376
	void CommitL( const CDbObject& aObject );
sl@0
   377
	void Rollback( const CDbObject& aObject );
sl@0
   378
//
sl@0
   379
	void ReadPrepareL( const CDbObject& aObject );
sl@0
   380
	void ReadBegin( const CDbObject& aObject );
sl@0
   381
	void ReadRelease( const CDbObject& aObject );
sl@0
   382
//
sl@0
   383
	void DMLCheckL();
sl@0
   384
	void DMLPrepareL( const CDbObject& aObject );
sl@0
   385
	void DMLBegin();
sl@0
   386
	void DMLTouch();
sl@0
   387
	void DMLBeginLC();
sl@0
   388
	void DMLCommitL();
sl@0
   389
	void DMLRollback();
sl@0
   390
//
sl@0
   391
	void DDLPrepareL( const CDbObject& aObject );
sl@0
   392
	void DDLBegin();
sl@0
   393
	void DDLBeginLC();
sl@0
   394
	void DDLCommitL();
sl@0
   395
	void DDLRollback();
sl@0
   396
//
sl@0
   397
	void UtilityPrepareL( const CDbObject& aObject );
sl@0
   398
	void UtilityBegin( CDbDatabase::TUtility aType );
sl@0
   399
	void UtilityCommitL();
sl@0
   400
	void UtilityRollback();
sl@0
   401
//
sl@0
   402
	inline TBool IsLocked() const;
sl@0
   403
	inline void ReadyL() const;
sl@0
   404
	TBool InTransaction( const CDbObject& aObject );
sl@0
   405
//
sl@0
   406
	CDbNotifier* NotifierL();
sl@0
   407
#ifdef _ASSERTIONS
sl@0
   408
	void _Invariant() const;
sl@0
   409
#endif
sl@0
   410
private:
sl@0
   411
	typedef const CDbContext* THolder;
sl@0
   412
	struct TLock
sl@0
   413
		{
sl@0
   414
		THolder iHolder;
sl@0
   415
		TUint iState;
sl@0
   416
		};
sl@0
   417
	enum { ELockListGranularity = 4 };
sl@0
   418
	enum { ETransactionLock = 0x80000000 };
sl@0
   419
	enum { EState = 0x7f, EFailed = 0x80 };
sl@0
   420
	enum { EMaxLock = 255 };
sl@0
   421
private:
sl@0
   422
	inline TDbLockType LockState() const;
sl@0
   423
	void PrepareSLockL( const CDbObject& aObject, TUint aInitState );
sl@0
   424
	void PrepareXLockL( const CDbObject& aObject );
sl@0
   425
	void Unlock( RDbNotifier::TEvent aEvent );
sl@0
   426
	void Unlock( TLock& aLock );
sl@0
   427
	TLock* GetLock( const CDbObject& aObject );
sl@0
   428
	void Event( RDbNotifier::TEvent aEvent );
sl@0
   429
//
sl@0
   430
	void DoCommitL();
sl@0
   431
	void DoRollback();
sl@0
   432
	static void DMLAbandon( TAny* aPtr );
sl@0
   433
	static void DDLAbandon( TAny* aPtr );
sl@0
   434
private:
sl@0
   435
	CDbTableDatabase* iDatabase;
sl@0
   436
	TUint8 iAction;
sl@0
   437
	TUint8 iLockState;
sl@0
   438
	TUint8 iLockCount;
sl@0
   439
	TUint8 iMaxLock;
sl@0
   440
	TInt iUpdaters;
sl@0
   441
	TLock iPrimary;
sl@0
   442
	TLock* iSharers;
sl@0
   443
	TDbGeneration iRollback;
sl@0
   444
	CNotifier* iNotifier;
sl@0
   445
	};
sl@0
   446
sl@0
   447
/**
sl@0
   448
@internalComponent
sl@0
   449
*/
sl@0
   450
class CDbTableDatabase : public CBase
sl@0
   451
	{
sl@0
   452
private:
sl@0
   453
	class CIncremental;
sl@0
   454
	class CIncrementalDDL;
sl@0
   455
	class CCreateIndex;
sl@0
   456
	class CDropIndex;
sl@0
   457
	class CDropTable;
sl@0
   458
	class CAlterTable;
sl@0
   459
	class CUtility;
sl@0
   460
	class CInterface;
sl@0
   461
	class CSource;
sl@0
   462
//
sl@0
   463
	friend class RDbTransaction;
sl@0
   464
	friend class CInterface;
sl@0
   465
	friend class CSource;
sl@0
   466
	friend class CDbTable;
sl@0
   467
	friend class CIncremental;
sl@0
   468
public:
sl@0
   469
	/**
sl@0
   470
	@internalComponent
sl@0
   471
	*/
sl@0
   472
	class CStepper : public CBase
sl@0
   473
		{
sl@0
   474
	protected:
sl@0
   475
		CStepper() {}
sl@0
   476
	public:
sl@0
   477
		virtual TInt StepL( TInt aStep ) = 0;
sl@0
   478
		};
sl@0
   479
sl@0
   480
	/**
sl@0
   481
	@internalComponent
sl@0
   482
	*/
sl@0
   483
	class CMultiStepper : public CStepper
sl@0
   484
		{
sl@0
   485
	private:
sl@0
   486
		struct SStepper
sl@0
   487
			{
sl@0
   488
			CStepper* iStepper;
sl@0
   489
			TInt iStep;
sl@0
   490
			};
sl@0
   491
	public:
sl@0
   492
		~CMultiStepper();
sl@0
   493
		IMPORT_C static CMultiStepper* NewL( TInt aStepperCount );
sl@0
   494
		IMPORT_C void AddStepper( CStepper* aStepper, TInt aSteps );
sl@0
   495
		IMPORT_C TInt TotalSteps();
sl@0
   496
		TInt StepL( TInt aStep );
sl@0
   497
	private:
sl@0
   498
		inline CMultiStepper( TInt aStepperCount );
sl@0
   499
	private:
sl@0
   500
		SStepper* iStepper;
sl@0
   501
		SStepper* iEnd;
sl@0
   502
		SStepper iSteppers[1];		// one or more
sl@0
   503
		};
sl@0
   504
sl@0
   505
	/**
sl@0
   506
	@internalComponent
sl@0
   507
	*/
sl@0
   508
	class CBuildIndex : public CStepper
sl@0
   509
		{
sl@0
   510
	private:
sl@0
   511
		enum { ERecordsPerStep = 16 };
sl@0
   512
	public:
sl@0
   513
		IMPORT_C static CBuildIndex* NewL( CDbTableDatabase& aDatabase, const CDbTableDef& aTable, const CDbTableIndexDef& anIndex );
sl@0
   514
		~CBuildIndex();
sl@0
   515
		IMPORT_C static TInt Steps( TInt aCardinality );
sl@0
   516
		inline CDbRecordIndex& Index();
sl@0
   517
		IMPORT_C TInt StepsL();
sl@0
   518
		// from CStepper
sl@0
   519
		TInt StepL( TInt aStep );
sl@0
   520
	private:
sl@0
   521
		CBuildIndex();
sl@0
   522
	private:
sl@0
   523
		CDbTableSource* iSource;
sl@0
   524
		TDbPosition iNext;
sl@0
   525
		CDbRecordIndex* iIndex;
sl@0
   526
		};
sl@0
   527
protected:
sl@0
   528
	IMPORT_C CDbTableDatabase();
sl@0
   529
	IMPORT_C ~CDbTableDatabase();
sl@0
   530
public:
sl@0
   531
	inline RDbTransaction& Transaction();
sl@0
   532
//
sl@0
   533
	IMPORT_C CDbDatabase* InterfaceL();
sl@0
   534
	IMPORT_C CDbSource* SourceL();
sl@0
   535
//
sl@0
   536
	inline RDbTableSchema& Schema();
sl@0
   537
	IMPORT_C RDbTableSchema& SchemaL();
sl@0
   538
//
sl@0
   539
	CDbTableSource* TableSourceL( const TDesC& aTableName );
sl@0
   540
	void Release( const CDbTableDef& aDef );
sl@0
   541
// framework functions
sl@0
   542
	virtual CStepper* TableAlterL( CDbTableDef& aTable, const HDbColumnSet& aNewSet, TInt& aStep ) = 0;
sl@0
   543
	virtual CStepper* RecordDiscarderL( const CDbTableDef& aTable, TInt& aStep ) = 0;
sl@0
   544
	virtual CStepper* IndexDiscarderL( const CDbTableDef& aTable, const CDbTableIndexDef& anIndex, TInt& aStep ) = 0;
sl@0
   545
	IMPORT_C virtual CStepper* UtilityL( CDbDatabase::TUtility aType, TInt& aStep );
sl@0
   546
protected:
sl@0
   547
// framework
sl@0
   548
	IMPORT_C virtual TInt Property( CDbDatabase::TProperty aProperty );
sl@0
   549
private:
sl@0
   550
//framework
sl@0
   551
	virtual void AuthenticateL() = 0;
sl@0
   552
	IMPORT_C virtual void Idle();
sl@0
   553
	virtual void LoadSchemaL() = 0;
sl@0
   554
	virtual void SynchL( TDbLockType aLock ) = 0;
sl@0
   555
	virtual void Revert( TDbLockType aLock ) = 0;
sl@0
   556
	virtual CDbTable* TableL( const CDbTableDef& aDef ) = 0;
sl@0
   557
	virtual CDbTableDef* CreateTableL( const TDesC& aName, const CDbColSet& aColSet, const CDbKey* aPrimaryKey ) = 0;
sl@0
   558
	virtual CDbTableIndexDef* CreateIndexL( const CDbTableDef& aTable, const TDesC& aName, const CDbKey& aKey ) = 0;
sl@0
   559
	virtual void DestroyL() = 0;
sl@0
   560
//
sl@0
   561
	inline void Open();
sl@0
   562
	void Close();
sl@0
   563
	inline void AddTable( CDbTable& aTable );
sl@0
   564
	void RemoveTable( CDbTable& aTable );
sl@0
   565
//
sl@0
   566
	void CheckIdle();
sl@0
   567
	void FlushL( TDbLockType aLock );
sl@0
   568
	void Abandon( TDbLockType aLock );
sl@0
   569
	void Release();
sl@0
   570
sl@0
   571
	void DoCreateTableL( const TDesC& aName, const CDbColSet& aColSet, const CDbKey* aPrimaryKey );
sl@0
   572
	CIncremental* OpenCreateIndexL( const TDesC& aName, const TDesC& aTable, const CDbKey& aKey, TInt& aStep );
sl@0
   573
	CIncremental* OpenDropIndexL( const TDesC& aName, const TDesC& aTable, TInt& aStep );
sl@0
   574
	CIncremental* OpenDropTableL( const TDesC& aTable, TInt& aStep );
sl@0
   575
	CIncremental* OpenAlterTableL( const TDesC& aTable, const CDbColSet& aNewDef, TInt& aStep );
sl@0
   576
	CDbCursor* PrepareViewL( const TDbQuery& aQuery, const TDbWindow& aWindow, RDbRowSet::TAccess anAccess );
sl@0
   577
	CDbCursor* PrepareTableL( const TDesC& aTable, RDbRowSet::TAccess anAccess );
sl@0
   578
// reserved virtual function space
sl@0
   579
	IMPORT_C virtual void Reserved_1();
sl@0
   580
	IMPORT_C virtual void Reserved_2();
sl@0
   581
private:
sl@0
   582
	TInt iRef;
sl@0
   583
	RDbCache iCache;
sl@0
   584
	RDbTransaction iTransaction;
sl@0
   585
	RDbTableSchema iSchema;
sl@0
   586
	RDbTables iTables;
sl@0
   587
	};
sl@0
   588
sl@0
   589
#include "D32TABLE.INL"
sl@0
   590
#endif