persistentstorage/sql/SRC/Server/Compact/SqlCompactEntry.h
changeset 0 08ec8eefde2f
equal deleted inserted replaced
-1:000000000000 0:08ec8eefde2f
       
     1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #ifndef SQLCOMPACTENTRY_H
       
    17 #define SQLCOMPACTENTRY_H
       
    18 
       
    19 #include "SqlCompact.h"
       
    20 
       
    21 //Forward declarations
       
    22 class CSqlCompactTestActive;
       
    23 class CSqlCompactTimer;
       
    24 
       
    25 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
       
    26 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
       
    27 
       
    28 #ifdef _DEBUG
       
    29 #define SQLCOMPACTENTRY_INVARIANT() Invariant()
       
    30 #else
       
    31 #define SQLCOMPACTENTRY_INVARIANT() void(0)
       
    32 #endif
       
    33 
       
    34 /**
       
    35 Every CSqlCompactEntry maintains a connection to the database that has to be compacted in background mode.
       
    36 When the number of the free pages reaches or is above the threshold, the background compaction will be activated
       
    37 and performed in steps.
       
    38 
       
    39 @see MSqlCompactConn
       
    40 @see CSqlCompactTimer
       
    41 
       
    42 @internalComponent
       
    43 */
       
    44 NONSHARABLE_CLASS(CSqlCompactEntry) : public CBase
       
    45 	{
       
    46 	friend class CSqlCompactTestActive;
       
    47 	
       
    48 public:
       
    49 	static CSqlCompactEntry* NewLC(const TDesC& aFullName, TSqlCompactConnFactoryL aConnFactoryL, 
       
    50 								   const TSqlCompactSettings& aSettings, CSqlCompactTimer& aTimer);
       
    51 	TInt AddRef();
       
    52 	TInt Release();
       
    53 	TInt Compact();
       
    54 	const TDesC& FullName() const;
       
    55 	void Invariant() const;
       
    56 	
       
    57 private:
       
    58 	CSqlCompactEntry(const TSqlCompactSettings& aSettings, CSqlCompactTimer& aTimer);
       
    59 	virtual ~CSqlCompactEntry();
       
    60 	void ConstructL(const TDesC& aFullName, TSqlCompactConnFactoryL aConnFactoryL);
       
    61 	void ResetState();
       
    62 	MSqlCompactConn& Connection();
       
    63 	static void FreePageCallback(void* aThis, TInt aFreePageCount);
       
    64 
       
    65 public:
       
    66     TSglQueLink			iLink;       
       
    67     
       
    68 private:
       
    69 	RBuf				iFullName;
       
    70 	TSqlCompactSettings	iSettings;
       
    71 	CSqlCompactTimer& 	iTimer;
       
    72 	MSqlCompactConn*	iConnection;
       
    73 	TInt				iRefCounter;
       
    74 	enum TState 
       
    75 		{
       
    76 		EInactive,
       
    77 		EInProgress
       
    78 		};
       
    79 	TState				iState;
       
    80 	TInt				iPageCount;
       
    81 	TBool				iFreePageCallbackDisabled;
       
    82 
       
    83 	};
       
    84 
       
    85 #endif//SQLCOMPACTENTRY_H