os/kernelhwsrv/userlibandfileserver/fileserver/shostmassstorage/server/protocol/include/tblocktransfer.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.
     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 the License "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 /**
    17  @file
    18  @internalTechnology
    19 */
    20 
    21 #ifndef TBLOCKTRANSFER_H
    22 #define TBLOCKTRANSFER_H
    23 
    24 class MBlockTransferProtocol;
    25 
    26 /**
    27 Split the byte stream on block boundaries and transfer using
    28 MBlockTransferProtocol interface in blocks
    29 */
    30 class TBlockTransfer
    31     {
    32 public:
    33     TBlockTransfer();
    34 
    35     void InitBuffers(RBuf8* aHeadbuf, RBuf8* aTailbuf);
    36 
    37     void ReadL(MBlockTransferProtocol& aProtocol,
    38                TPos aPosition,
    39                TInt aLength,
    40                TDes8& aBuf);
    41 
    42     void WriteL(MBlockTransferProtocol& aProtocol,
    43                 TPos aPosition,
    44                 TInt aLength,
    45                 TDesC8& aBuf);
    46 
    47     TUint32 BlockLength() const;
    48     void SetCapacityL(TUint32 aBlockLength, TLba aLastLba);
    49 
    50 private:
    51     TPos GetHeadBlockOffset(TPos aPos);
    52     TLba GetHeadBlockLbaL(TPos aPos);
    53 
    54     TPos GetTailBlockOffset(TPos aPos, TInt aLen);
    55     TLba GetTailBlockLbaL(TPos aPos, TInt aLen);
    56 
    57 private:
    58     /** Block Length */
    59     TInt64 iBlockLength;
    60     /** Last Logical Block Address */
    61     TLba iLastLba;
    62 
    63     // buffers for block manipulation (not owend by this class)
    64     RBuf8* iHeadbuf;
    65 	RBuf8* iTailbuf;
    66     };
    67 
    68 
    69 /** Constructor */
    70 inline TBlockTransfer::TBlockTransfer()
    71 :   iBlockLength(0),
    72     iHeadbuf(NULL),
    73     iTailbuf(NULL)
    74     {
    75     }
    76 
    77 
    78 /** return the Block Length */
    79 inline TUint32 TBlockTransfer::BlockLength() const
    80     {
    81     return iBlockLength;
    82     }
    83 
    84 
    85 inline void TBlockTransfer::InitBuffers(RBuf8* aHeadbuf, RBuf8* aTailbuf)
    86     {
    87     iHeadbuf = aHeadbuf;
    88     iTailbuf = aTailbuf;
    89     }
    90 
    91 #endif // TBLOCKTRANSFER_H
    92