os/kernelhwsrv/userlibandfileserver/fileserver/shostmassstorage/server/protocol/include/tblocktransfer.h
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/userlibandfileserver/fileserver/shostmassstorage/server/protocol/include/tblocktransfer.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,92 @@
1.4 +// Copyright (c) 2008-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 the License "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 +//
1.18 +
1.19 +/**
1.20 + @file
1.21 + @internalTechnology
1.22 +*/
1.23 +
1.24 +#ifndef TBLOCKTRANSFER_H
1.25 +#define TBLOCKTRANSFER_H
1.26 +
1.27 +class MBlockTransferProtocol;
1.28 +
1.29 +/**
1.30 +Split the byte stream on block boundaries and transfer using
1.31 +MBlockTransferProtocol interface in blocks
1.32 +*/
1.33 +class TBlockTransfer
1.34 + {
1.35 +public:
1.36 + TBlockTransfer();
1.37 +
1.38 + void InitBuffers(RBuf8* aHeadbuf, RBuf8* aTailbuf);
1.39 +
1.40 + void ReadL(MBlockTransferProtocol& aProtocol,
1.41 + TPos aPosition,
1.42 + TInt aLength,
1.43 + TDes8& aBuf);
1.44 +
1.45 + void WriteL(MBlockTransferProtocol& aProtocol,
1.46 + TPos aPosition,
1.47 + TInt aLength,
1.48 + TDesC8& aBuf);
1.49 +
1.50 + TUint32 BlockLength() const;
1.51 + void SetCapacityL(TUint32 aBlockLength, TLba aLastLba);
1.52 +
1.53 +private:
1.54 + TPos GetHeadBlockOffset(TPos aPos);
1.55 + TLba GetHeadBlockLbaL(TPos aPos);
1.56 +
1.57 + TPos GetTailBlockOffset(TPos aPos, TInt aLen);
1.58 + TLba GetTailBlockLbaL(TPos aPos, TInt aLen);
1.59 +
1.60 +private:
1.61 + /** Block Length */
1.62 + TInt64 iBlockLength;
1.63 + /** Last Logical Block Address */
1.64 + TLba iLastLba;
1.65 +
1.66 + // buffers for block manipulation (not owend by this class)
1.67 + RBuf8* iHeadbuf;
1.68 + RBuf8* iTailbuf;
1.69 + };
1.70 +
1.71 +
1.72 +/** Constructor */
1.73 +inline TBlockTransfer::TBlockTransfer()
1.74 +: iBlockLength(0),
1.75 + iHeadbuf(NULL),
1.76 + iTailbuf(NULL)
1.77 + {
1.78 + }
1.79 +
1.80 +
1.81 +/** return the Block Length */
1.82 +inline TUint32 TBlockTransfer::BlockLength() const
1.83 + {
1.84 + return iBlockLength;
1.85 + }
1.86 +
1.87 +
1.88 +inline void TBlockTransfer::InitBuffers(RBuf8* aHeadbuf, RBuf8* aTailbuf)
1.89 + {
1.90 + iHeadbuf = aHeadbuf;
1.91 + iTailbuf = aTailbuf;
1.92 + }
1.93 +
1.94 +#endif // TBLOCKTRANSFER_H
1.95 +