Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TFPBlock.h
Go to the documentation of this file.
1 // @(#)root/io:$Id$
2 // Author: Elvin Sindrilaru 19/05/2011
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2011, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TFPBlock
13 #define ROOT_TFPBlock
14 
15 #include "TObject.h"
16 
17 /**
18 \class TFPBlock
19 \ingroup IO
20 */
21 
22 class TFPBlock : public TObject{
23 
24 private:
25  char *fBuffer; ///< Content of the block
26  Int_t fNblock; ///< Number of segment in the block
27  Long64_t fDataSize; ///< Total size of useful data in the block
28  Long64_t fCapacity; ///< Capacity of the buffer
29  Int_t *fLen; ///< Array of lengths of each segment
30  Long64_t *fPos; ///< Array of positions of each segment
31  Long64_t *fRelOffset; ///< Relative offset of piece in the buffer
32 
33  TFPBlock(const TFPBlock&) = delete; // Not implemented.
34  TFPBlock &operator=(const TFPBlock&) = delete; // Not implemented.
35 
36 public:
37 
38  TFPBlock(Long64_t*, Int_t*, Int_t);
39  virtual ~TFPBlock();
40 
41  Long64_t GetPos(Int_t) const;
42  Int_t GetLen(Int_t) const;
43 
44  Long64_t *GetPos() const;
45  Int_t *GetLen() const;
46  Long64_t GetDataSize() const;
47  Long64_t GetCapacity() const;
48  Int_t GetNoElem() const;
49  char *GetBuffer() const;
50  char *GetPtrToPiece(Int_t index) const;
51 
52  void SetBuffer(char*);
53  void SetPos(Int_t, Long64_t);
54  void ReallocBlock(Long64_t*, Int_t*, Int_t);
55 
56  ClassDef(TFPBlock, 0); // File prefetch block
57 };
58 
59 /// Get pointer to the array of postions.
60 inline Long64_t* TFPBlock::GetPos() const
61 {
62  return fPos;
63 }
64 
65 /// Get pointer to the array of lengths.
66 inline Int_t* TFPBlock::GetLen() const
67 {
68 
69  return fLen;
70 }
71 
72 /// Return size of the data in the block.
73 inline Long64_t TFPBlock::GetDataSize() const
74 {
75  return fDataSize;
76 }
77 
78 /// Return capacity of the block.
79 inline Long64_t TFPBlock::GetCapacity() const
80 {
81  return fCapacity;
82 }
83 
84 /// Return number of elements in the block.
85 inline Int_t TFPBlock::GetNoElem() const
86 {
87  return fNblock;
88 }
89 
90 /// Get position of the element at index i.
91 inline Long64_t TFPBlock::GetPos(Int_t i) const
92 {
93  return fPos[i];
94 }
95 
96 /// Get length of the element at index i.
97 inline Int_t TFPBlock::GetLen(Int_t i) const
98 {
99  return fLen[i];
100 }
101 
102 /// Get block buffer.
103 inline char* TFPBlock::GetBuffer() const
104 {
105  return fBuffer;
106 }
107 
108 /// Get block buffer.
109 inline char* TFPBlock::GetPtrToPiece(Int_t index) const
110 {
111  return (fBuffer + fRelOffset[index]);
112 }
113 
114 #endif