1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/persistentstorage/sql/SRC/Server/SqlSrvDriveSpace.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,107 @@
1.4 +// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// Reserving/Accessing/Releasing drive space - CSqlDriveSpace and RSqlDriveSpaceCol classes declarations
1.18 +//
1.19 +//
1.20 +
1.21 +#ifndef __SQLSRVDRIVESPACE_H__
1.22 +#define __SQLSRVDRIVESPACE_H__
1.23 +
1.24 +#include <f32file.h>
1.25 +
1.26 +//Forward declarations
1.27 +class RSqlDriveSpaceCol;
1.28 +class CSqlServer;
1.29 +
1.30 +#ifdef _DEBUG
1.31 +#define SQLDRIVESPACE_INVARIANT() Invariant()
1.32 +#define SQLDRIVESPACECOL_INVARIANT() Invariant()
1.33 +#else
1.34 +#define SQLDRIVESPACE_INVARIANT() void(0)
1.35 +#define SQLDRIVESPACECOL_INVARIANT() void(0)
1.36 +#endif
1.37 +
1.38 +/**
1.39 +This class describes an object, which is responsible for handling
1.40 +"reserve/get access/release" requests for a particular drive.
1.41 +
1.42 +Since the drive may be shared between more than one server side session and there is only one RFs instance,
1.43 +the current solution is that CSqlDriveSpace objects reserve some predefined amount of disk space
1.44 +at the time of their creation and then the access to the reserved disk space is reference counted.
1.45 + There is one obvious disadvantage of this solution: if a bad application "forgets" to release
1.46 +the access to the reserved disk space, then the reserved (but not released) disk space may be used by the server.
1.47 +At the moment, when some client will really need the reserved disk space to complete its "delete" transaction,
1.48 +it may happen that there is no reserved disk space at all.
1.49 +
1.50 +@see RSqlDriveSpaceCol
1.51 +@internalComponent
1.52 +*/
1.53 +NONSHARABLE_CLASS(CSqlDriveSpace) : public CBase
1.54 + {
1.55 +public:
1.56 + static CSqlDriveSpace* NewLC(RFs& aFs, TDriveNumber aDrive);
1.57 + virtual ~CSqlDriveSpace();
1.58 + inline TDriveNumber Drive() const;
1.59 + void GetAccessL();
1.60 + void ReleaseAccess();
1.61 + void Invariant() const;
1.62 +
1.63 +private:
1.64 + CSqlDriveSpace(RFs& aFs, TDriveNumber aDrive);
1.65 + void ConstructL();
1.66 +
1.67 +private:
1.68 + RFs& iFs; //File session reference
1.69 + TDriveNumber iDrive; //Drive number
1.70 + TInt iGetAccessRefCnt; //"Get access" requests count
1.71 +
1.72 + };
1.73 +
1.74 +/**
1.75 +@return The drive number, where the CSqlDriveSpace object handles the reservation requests
1.76 +*/
1.77 +inline TDriveNumber CSqlDriveSpace::Drive() const
1.78 + {
1.79 + return iDrive;
1.80 + }
1.81 +
1.82 +/**
1.83 +This class describes a collection of CSqlDriveSpace objects. Each CSqlDriveSpace object in the
1.84 +collection is responsible for handling "reserve/get access/release" requests for a particular
1.85 +drive.
1.86 +
1.87 +Only one RSqlDriveSpaceCol instance should be created (resp. destroyed) by the CSqlServer object.
1.88 +
1.89 +@see CSqlServer
1.90 +@see CSqlDriveSpace
1.91 +
1.92 +@internalComponent
1.93 +*/
1.94 +NONSHARABLE_CLASS(RSqlDriveSpaceCol)
1.95 + {
1.96 +public:
1.97 + RSqlDriveSpaceCol();
1.98 + void Create(RFs& aFs);
1.99 + void ResetAndDestroy();
1.100 + CSqlDriveSpace* Find(TDriveNumber aDrive);
1.101 + CSqlDriveSpace* AddL(TDriveNumber aDrive);
1.102 + void Invariant() const;
1.103 +
1.104 +private:
1.105 + RFs* iFs; //File session reference
1.106 + RPointerArray<CSqlDriveSpace> iDriveSpaceCol; //Collection of CSqlDriveSpace objects: one per drive
1.107 +
1.108 + };
1.109 +
1.110 +#endif//__SQLSRVDRIVESPACE_H__