os/persistentdata/persistentstorage/dbms/inc/D32STOR.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
// The Store-Database
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
#ifndef __D32STOR_H__
sl@0
    19
#define __D32STOR_H__
sl@0
    20
#ifndef __D32TABLE_H__
sl@0
    21
#include "D32TABLE.H"
sl@0
    22
#endif
sl@0
    23
#ifndef __S32STOR_H__
sl@0
    24
#include <s32stor.h>
sl@0
    25
#endif
sl@0
    26
sl@0
    27
// other classes referenced
sl@0
    28
class MDbStreamFilter;
sl@0
    29
class CDbStoreCompression;
sl@0
    30
class CClusterCache;
sl@0
    31
sl@0
    32
// classes defined
sl@0
    33
class CDbStoreDatabase;
sl@0
    34
class CDbFileStoreDatabase;
sl@0
    35
sl@0
    36
/**
sl@0
    37
@internalComponent
sl@0
    38
*/
sl@0
    39
enum TDbStoreVersion { EDbStoreVersion2=3,EDbStoreSecure,EDbStoreCompressed };
sl@0
    40
sl@0
    41
/**
sl@0
    42
@internalComponent
sl@0
    43
*/
sl@0
    44
class CDbStoreDatabase : public CDbTableDatabase
sl@0
    45
	{
sl@0
    46
public:
sl@0
    47
	enum TZipType {EDeflate,EInflate};
sl@0
    48
	
sl@0
    49
private:
sl@0
    50
	#ifndef PAGE_CACHE_SIZE
sl@0
    51
		#define PAGE_CACHE_SIZE 16
sl@0
    52
	#else
sl@0
    53
		#if PAGE_CACHE_SIZE < 8
sl@0
    54
			#error "PAGE_CACHE_SIZE macro value can't be less than 8"
sl@0
    55
		#endif
sl@0
    56
	#endif
sl@0
    57
	enum {EPageCachePages=PAGE_CACHE_SIZE};
sl@0
    58
	enum {EModified=0x1,EDamaged=0x2,ESharedStore=0x80000000};
sl@0
    59
	class CCompactor;
sl@0
    60
	
sl@0
    61
public:
sl@0
    62
// factory functions for pure StoreDatabase
sl@0
    63
	static CDbDatabase* CreateL(CStreamStore* aStore,TStreamId& aStreamId);
sl@0
    64
	static CDbSource* OpenL(CStreamStore* aStore,TStreamId aStreamId);
sl@0
    65
	static void CompressL(CStreamStore* aStore,TStreamId aStreamId,TZipType aZip);
sl@0
    66
// accessors
sl@0
    67
	inline CStreamStore& Store();
sl@0
    68
	inline MDbStreamFilter* Filter();
sl@0
    69
	CClusterCache& ClusterCacheL();
sl@0
    70
	MPagePool& PagePoolL();
sl@0
    71
// user-class's transaction protocol
sl@0
    72
	void MarkL();
sl@0
    73
	void IndexRecoveredL();
sl@0
    74
	
sl@0
    75
protected:
sl@0
    76
	IMPORT_C CDbStoreDatabase();
sl@0
    77
	IMPORT_C ~CDbStoreDatabase();
sl@0
    78
// phase 2 c'tors
sl@0
    79
	IMPORT_C TStreamId ConstructL();
sl@0
    80
// framework: authentication
sl@0
    81
	IMPORT_C void AuthenticateL();
sl@0
    82
	IMPORT_C void RestoreL(TStreamId aStreamId);
sl@0
    83
// framework: pure delegated functions
sl@0
    84
	IMPORT_C TInt Property(CDbDatabase::TProperty aProperty);
sl@0
    85
	IMPORT_C void DestroyL();
sl@0
    86
// framework: transaction protocol
sl@0
    87
	IMPORT_C void LoadSchemaL();
sl@0
    88
	IMPORT_C void SynchL(TDbLockType aLock);
sl@0
    89
	IMPORT_C void Revert(TDbLockType aLock);
sl@0
    90
	IMPORT_C void Idle();
sl@0
    91
// framework: object factory
sl@0
    92
	IMPORT_C CDbTableDef* CreateTableL(const TDesC& aName,const CDbColSet& aColSet,const CDbKey* aPrimaryKey);
sl@0
    93
	IMPORT_C CDbTableIndexDef* CreateIndexL(const CDbTableDef& aTable,const TDesC& aName,const CDbKey& aKey);
sl@0
    94
	IMPORT_C CDbTable* TableL(const CDbTableDef& aDef);
sl@0
    95
// framework: incremental factory
sl@0
    96
	IMPORT_C CStepper* TableAlterL(CDbTableDef& aTable,const HDbColumnSet& aNewSet,TInt& aStep);
sl@0
    97
	IMPORT_C CStepper* RecordDiscarderL(const CDbTableDef& aTable,TInt& aStep);
sl@0
    98
	IMPORT_C CStepper* IndexDiscarderL(const CDbTableDef& aTable,const CDbTableIndexDef& anIndex,TInt& aStep);
sl@0
    99
	IMPORT_C CStepper* UtilityL(CDbDatabase::TUtility aType,TInt& aStep);
sl@0
   100
	
sl@0
   101
private:
sl@0
   102
// framework: reserved
sl@0
   103
	IMPORT_C void Reserved_1();
sl@0
   104
	IMPORT_C void Reserved_2();
sl@0
   105
// implementationp functions
sl@0
   106
	static CDbStoreDatabase* NewLC(CStreamStore* aStore);
sl@0
   107
//
sl@0
   108
	void CompressTablesL();
sl@0
   109
	void CompressL(TStreamId aStreamId,TZipType aZip);
sl@0
   110
//
sl@0
   111
	void ReadHeaderL(RReadStream& aStream);
sl@0
   112
	void InitPagePoolL();
sl@0
   113
	void ReplaceSchemaL();
sl@0
   114
	void ReplaceTokenL(TUint aFlags);
sl@0
   115
	void SynchStoreL(TDbLockType aLock);
sl@0
   116
	CDbStoreCompression& CompressionL();
sl@0
   117
	CStepper* RecoverL(TInt& aStep);
sl@0
   118
	
sl@0
   119
protected:
sl@0
   120
	CStreamStore* iStore;
sl@0
   121
	TInt iReclaim;
sl@0
   122
	
sl@0
   123
private:
sl@0
   124
	TUint8 iVersion;
sl@0
   125
	TUint8 iFlags;
sl@0
   126
	TUint8 iSharedStore;
sl@0
   127
	TStreamId iSchemaId;
sl@0
   128
	TStreamId iTokenId;
sl@0
   129
	TStorePagePoolToken iPoolToken;
sl@0
   130
	RStorePagePool* iPagePool;
sl@0
   131
	CPageCache* iPageCache;
sl@0
   132
	CClusterCache* iClusterCache;
sl@0
   133
	MDbStreamFilter* iFilter;
sl@0
   134
	CDbStoreCompression* iCompression;
sl@0
   135
	
sl@0
   136
	};
sl@0
   137
sl@0
   138
/**
sl@0
   139
The general file-store database class
sl@0
   140
@internalComponent
sl@0
   141
*/
sl@0
   142
const TInt32 KDbmsFileDatabaseUidValue=0x10000EBE;
sl@0
   143
const TUid KDbmsFileDatabaseUid={KDbmsFileDatabaseUidValue};
sl@0
   144
sl@0
   145
/**
sl@0
   146
@internalComponent
sl@0
   147
*/
sl@0
   148
class CDbFileStoreDatabase : public CDbStoreDatabase
sl@0
   149
	{
sl@0
   150
public:
sl@0
   151
	IMPORT_C static CDbDatabase* CreateL(RFs& aFs, const TDesC& aName, TDbFormat::TCreate aMode,
sl@0
   152
                                         const TUidType& aType);
sl@0
   153
	IMPORT_C static CDbSource* OpenL(RFs& aFs,const TDesC& aName,TDbFormat::TOpen aMode);
sl@0
   154
	
sl@0
   155
protected:
sl@0
   156
	IMPORT_C CDbFileStoreDatabase(RFs& aFs);
sl@0
   157
	IMPORT_C ~CDbFileStoreDatabase();
sl@0
   158
//
sl@0
   159
	IMPORT_C void CreateL(const TDesC& aName, TDbFormat::TCreate aMode, const TUidType& aType);
sl@0
   160
	IMPORT_C virtual TStreamId CreateRootL(TStreamId aDatabaseId);
sl@0
   161
//
sl@0
   162
	IMPORT_C void OpenL(const TDesC& aName,TDbFormat::TOpen aMode);
sl@0
   163
	IMPORT_C virtual TStreamId DatabaseIdL(TStreamId aRootId);
sl@0
   164
// from CDbStoreDatabase
sl@0
   165
	IMPORT_C TInt Property(CDbDatabase::TProperty aProperty);
sl@0
   166
	IMPORT_C void DestroyL();
sl@0
   167
	
sl@0
   168
private:
sl@0
   169
	static CDbFileStoreDatabase* NewLC(RFs& aFs);
sl@0
   170
	
sl@0
   171
private:
sl@0
   172
	RFs& iFs;
sl@0
   173
	HBufC* iName;
sl@0
   174
	TBool iDelete;
sl@0
   175
	
sl@0
   176
	};
sl@0
   177
sl@0
   178
#endif