sl@0: // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: /** sl@0: @file sl@0: @internalTechnology sl@0: */ sl@0: sl@0: #ifndef TBLOCKTRANSFER_H sl@0: #define TBLOCKTRANSFER_H sl@0: sl@0: class MBlockTransferProtocol; sl@0: sl@0: /** sl@0: Split the byte stream on block boundaries and transfer using sl@0: MBlockTransferProtocol interface in blocks sl@0: */ sl@0: class TBlockTransfer sl@0: { sl@0: public: sl@0: TBlockTransfer(); sl@0: sl@0: void InitBuffers(RBuf8* aHeadbuf, RBuf8* aTailbuf); sl@0: sl@0: void ReadL(MBlockTransferProtocol& aProtocol, sl@0: TPos aPosition, sl@0: TInt aLength, sl@0: TDes8& aBuf); sl@0: sl@0: void WriteL(MBlockTransferProtocol& aProtocol, sl@0: TPos aPosition, sl@0: TInt aLength, sl@0: TDesC8& aBuf); sl@0: sl@0: TUint32 BlockLength() const; sl@0: void SetCapacityL(TUint32 aBlockLength, TLba aLastLba); sl@0: sl@0: private: sl@0: TPos GetHeadBlockOffset(TPos aPos); sl@0: TLba GetHeadBlockLbaL(TPos aPos); sl@0: sl@0: TPos GetTailBlockOffset(TPos aPos, TInt aLen); sl@0: TLba GetTailBlockLbaL(TPos aPos, TInt aLen); sl@0: sl@0: private: sl@0: /** Block Length */ sl@0: TInt64 iBlockLength; sl@0: /** Last Logical Block Address */ sl@0: TLba iLastLba; sl@0: sl@0: // buffers for block manipulation (not owend by this class) sl@0: RBuf8* iHeadbuf; sl@0: RBuf8* iTailbuf; sl@0: }; sl@0: sl@0: sl@0: /** Constructor */ sl@0: inline TBlockTransfer::TBlockTransfer() sl@0: : iBlockLength(0), sl@0: iHeadbuf(NULL), sl@0: iTailbuf(NULL) sl@0: { sl@0: } sl@0: sl@0: sl@0: /** return the Block Length */ sl@0: inline TUint32 TBlockTransfer::BlockLength() const sl@0: { sl@0: return iBlockLength; sl@0: } sl@0: sl@0: sl@0: inline void TBlockTransfer::InitBuffers(RBuf8* aHeadbuf, RBuf8* aTailbuf) sl@0: { sl@0: iHeadbuf = aHeadbuf; sl@0: iTailbuf = aTailbuf; sl@0: } sl@0: sl@0: #endif // TBLOCKTRANSFER_H sl@0: