os/persistentdata/persistentstorage/sql/SRC/Server/Compact/SqlCompactEntry.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) 2008-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 SQLCOMPACTENTRY_H
sl@0
    17
#define SQLCOMPACTENTRY_H
sl@0
    18
sl@0
    19
#include "SqlCompact.h"
sl@0
    20
sl@0
    21
//Forward declarations
sl@0
    22
class CSqlCompactTestActive;
sl@0
    23
class CSqlCompactTimer;
sl@0
    24
sl@0
    25
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sl@0
    26
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sl@0
    27
sl@0
    28
#ifdef _DEBUG
sl@0
    29
#define SQLCOMPACTENTRY_INVARIANT() Invariant()
sl@0
    30
#else
sl@0
    31
#define SQLCOMPACTENTRY_INVARIANT() void(0)
sl@0
    32
#endif
sl@0
    33
sl@0
    34
/**
sl@0
    35
Every CSqlCompactEntry maintains a connection to the database that has to be compacted in background mode.
sl@0
    36
When the number of the free pages reaches or is above the threshold, the background compaction will be activated
sl@0
    37
and performed in steps.
sl@0
    38
sl@0
    39
@see MSqlCompactConn
sl@0
    40
@see CSqlCompactTimer
sl@0
    41
sl@0
    42
@internalComponent
sl@0
    43
*/
sl@0
    44
NONSHARABLE_CLASS(CSqlCompactEntry) : public CBase
sl@0
    45
	{
sl@0
    46
	friend class CSqlCompactTestActive;
sl@0
    47
	
sl@0
    48
public:
sl@0
    49
	static CSqlCompactEntry* NewLC(const TDesC& aFullName, TSqlCompactConnFactoryL aConnFactoryL, 
sl@0
    50
								   const TSqlCompactSettings& aSettings, CSqlCompactTimer& aTimer);
sl@0
    51
	TInt AddRef();
sl@0
    52
	TInt Release();
sl@0
    53
	TInt Compact();
sl@0
    54
	const TDesC& FullName() const;
sl@0
    55
	void Invariant() const;
sl@0
    56
	
sl@0
    57
private:
sl@0
    58
	CSqlCompactEntry(const TSqlCompactSettings& aSettings, CSqlCompactTimer& aTimer);
sl@0
    59
	virtual ~CSqlCompactEntry();
sl@0
    60
	void ConstructL(const TDesC& aFullName, TSqlCompactConnFactoryL aConnFactoryL);
sl@0
    61
	void ResetState();
sl@0
    62
	MSqlCompactConn& Connection();
sl@0
    63
	static void FreePageCallback(void* aThis, TInt aFreePageCount);
sl@0
    64
sl@0
    65
public:
sl@0
    66
    TSglQueLink			iLink;       
sl@0
    67
    
sl@0
    68
private:
sl@0
    69
	RBuf				iFullName;
sl@0
    70
	TSqlCompactSettings	iSettings;
sl@0
    71
	CSqlCompactTimer& 	iTimer;
sl@0
    72
	MSqlCompactConn*	iConnection;
sl@0
    73
	TInt				iRefCounter;
sl@0
    74
	enum TState 
sl@0
    75
		{
sl@0
    76
		EInactive,
sl@0
    77
		EInProgress
sl@0
    78
		};
sl@0
    79
	TState				iState;
sl@0
    80
	TInt				iPageCount;
sl@0
    81
	TBool				iFreePageCallbackDisabled;
sl@0
    82
sl@0
    83
	};
sl@0
    84
sl@0
    85
#endif//SQLCOMPACTENTRY_H