// @(#)root/io:$Id$
// Author: Elvin Sindrilaru   19/05/2011

/*************************************************************************
 * Copyright (C) 1995-2011, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOT_TFPBlock
#define ROOT_TFPBlock

#ifndef ROOT_TObject
#include "TObject.h"
#endif

/**
\class TFPBlock
\ingroup IO
*/

class TFPBlock : public TObject{

private:
   char     *fBuffer;       ///< Content of the block
   Int_t     fNblock;       ///< Number of segment in the block
   Long64_t  fDataSize;     ///< Total size of useful data in the block
   Long64_t  fCapacity;     ///< Capacity of the buffer
   Int_t    *fLen;          ///< Array of lengths of each segment
   Long64_t *fPos;          ///< Array of positions of each segment
   Long64_t *fRelOffset;    ///< Relative offset of piece in the buffer

   TFPBlock(const TFPBlock&);            // Not implemented.
   TFPBlock &operator=(const TFPBlock&); // Not implemented.

public:

   TFPBlock(Long64_t*, Int_t*, Int_t);
   virtual ~TFPBlock();

   Long64_t  GetPos(Int_t) const;
   Int_t     GetLen(Int_t) const;

   Long64_t *GetPos() const;
   Int_t    *GetLen() const;
   Long64_t  GetDataSize() const;
   Long64_t  GetCapacity() const;
   Int_t     GetNoElem() const;
   char     *GetBuffer() const;
   char     *GetPtrToPiece(Int_t index) const;

   void SetBuffer(char*);
   void SetPos(Int_t, Long64_t);
   void ReallocBlock(Long64_t*, Int_t*, Int_t);

   ClassDef(TFPBlock, 0);  // File prefetch block
};

/// Get pointer to the array of postions.
inline Long64_t* TFPBlock::GetPos() const
{
   return fPos;
}

/// Get pointer to the array of lengths.
inline Int_t* TFPBlock::GetLen() const
{

   return fLen;
}

/// Return size of the data in the block.
inline Long64_t TFPBlock::GetDataSize() const
{
   return fDataSize;
}

/// Return capacity of the block.
inline Long64_t TFPBlock::GetCapacity() const
{
   return fCapacity;
}

/// Return number of elements in the block.
inline Int_t TFPBlock::GetNoElem() const
{
   return fNblock;
}

/// Get position of the element at index i.
inline Long64_t TFPBlock::GetPos(Int_t i) const
{
   return fPos[i];
}

/// Get length of the element at index i.
inline Int_t TFPBlock::GetLen(Int_t i) const
{
   return fLen[i];
}

/// Get block buffer.
inline char* TFPBlock::GetBuffer() const
{
   return fBuffer;
}

/// Get block buffer.
inline char* TFPBlock::GetPtrToPiece(Int_t index) const
{
  return (fBuffer + fRelOffset[index]);
}

#endif
 TFPBlock.h:1
 TFPBlock.h:2
 TFPBlock.h:3
 TFPBlock.h:4
 TFPBlock.h:5
 TFPBlock.h:6
 TFPBlock.h:7
 TFPBlock.h:8
 TFPBlock.h:9
 TFPBlock.h:10
 TFPBlock.h:11
 TFPBlock.h:12
 TFPBlock.h:13
 TFPBlock.h:14
 TFPBlock.h:15
 TFPBlock.h:16
 TFPBlock.h:17
 TFPBlock.h:18
 TFPBlock.h:19
 TFPBlock.h:20
 TFPBlock.h:21
 TFPBlock.h:22
 TFPBlock.h:23
 TFPBlock.h:24
 TFPBlock.h:25
 TFPBlock.h:26
 TFPBlock.h:27
 TFPBlock.h:28
 TFPBlock.h:29
 TFPBlock.h:30
 TFPBlock.h:31
 TFPBlock.h:32
 TFPBlock.h:33
 TFPBlock.h:34
 TFPBlock.h:35
 TFPBlock.h:36
 TFPBlock.h:37
 TFPBlock.h:38
 TFPBlock.h:39
 TFPBlock.h:40
 TFPBlock.h:41
 TFPBlock.h:42
 TFPBlock.h:43
 TFPBlock.h:44
 TFPBlock.h:45
 TFPBlock.h:46
 TFPBlock.h:47
 TFPBlock.h:48
 TFPBlock.h:49
 TFPBlock.h:50
 TFPBlock.h:51
 TFPBlock.h:52
 TFPBlock.h:53
 TFPBlock.h:54
 TFPBlock.h:55
 TFPBlock.h:56
 TFPBlock.h:57
 TFPBlock.h:58
 TFPBlock.h:59
 TFPBlock.h:60
 TFPBlock.h:61
 TFPBlock.h:62
 TFPBlock.h:63
 TFPBlock.h:64
 TFPBlock.h:65
 TFPBlock.h:66
 TFPBlock.h:67
 TFPBlock.h:68
 TFPBlock.h:69
 TFPBlock.h:70
 TFPBlock.h:71
 TFPBlock.h:72
 TFPBlock.h:73
 TFPBlock.h:74
 TFPBlock.h:75
 TFPBlock.h:76
 TFPBlock.h:77
 TFPBlock.h:78
 TFPBlock.h:79
 TFPBlock.h:80
 TFPBlock.h:81
 TFPBlock.h:82
 TFPBlock.h:83
 TFPBlock.h:84
 TFPBlock.h:85
 TFPBlock.h:86
 TFPBlock.h:87
 TFPBlock.h:88
 TFPBlock.h:89
 TFPBlock.h:90
 TFPBlock.h:91
 TFPBlock.h:92
 TFPBlock.h:93
 TFPBlock.h:94
 TFPBlock.h:95
 TFPBlock.h:96
 TFPBlock.h:97
 TFPBlock.h:98
 TFPBlock.h:99
 TFPBlock.h:100
 TFPBlock.h:101
 TFPBlock.h:102
 TFPBlock.h:103
 TFPBlock.h:104
 TFPBlock.h:105
 TFPBlock.h:106
 TFPBlock.h:107
 TFPBlock.h:108
 TFPBlock.h:109
 TFPBlock.h:110
 TFPBlock.h:111
 TFPBlock.h:112
 TFPBlock.h:113
 TFPBlock.h:114
 TFPBlock.h:115
 TFPBlock.h:116