ROOT  6.06/09
Reference Guide
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 #ifndef ROOT_TObject
16 #include "TObject.h"
17 #endif
18 
19 /**
20 \class TFPBlock
21 \ingroup IO
22 */
23 
24 class TFPBlock : public TObject{
25 
26 private:
27  char *fBuffer; ///< Content of the block
28  Int_t fNblock; ///< Number of segment in the block
29  Long64_t fDataSize; ///< Total size of useful data in the block
30  Long64_t fCapacity; ///< Capacity of the buffer
31  Int_t *fLen; ///< Array of lengths of each segment
32  Long64_t *fPos; ///< Array of positions of each segment
33  Long64_t *fRelOffset; ///< Relative offset of piece in the buffer
34 
35  TFPBlock(const TFPBlock&); // Not implemented.
36  TFPBlock &operator=(const TFPBlock&); // Not implemented.
37 
38 public:
39 
41  virtual ~TFPBlock();
42 
43  Long64_t GetPos(Int_t) const;
44  Int_t GetLen(Int_t) const;
45 
46  Long64_t *GetPos() const;
47  Int_t *GetLen() const;
48  Long64_t GetDataSize() const;
49  Long64_t GetCapacity() const;
50  Int_t GetNoElem() const;
51  char *GetBuffer() const;
52  char *GetPtrToPiece(Int_t index) const;
53 
54  void SetBuffer(char*);
55  void SetPos(Int_t, Long64_t);
56  void ReallocBlock(Long64_t*, Int_t*, Int_t);
57 
58  ClassDef(TFPBlock, 0); // File prefetch block
59 };
60 
61 /// Get pointer to the array of postions.
62 inline Long64_t* TFPBlock::GetPos() const
63 {
64  return fPos;
65 }
66 
67 /// Get pointer to the array of lengths.
68 inline Int_t* TFPBlock::GetLen() const
69 {
70 
71  return fLen;
72 }
73 
74 /// Return size of the data in the block.
76 {
77  return fDataSize;
78 }
79 
80 /// Return capacity of the block.
82 {
83  return fCapacity;
84 }
85 
86 /// Return number of elements in the block.
87 inline Int_t TFPBlock::GetNoElem() const
88 {
89  return fNblock;
90 }
91 
92 /// Get position of the element at index i.
94 {
95  return fPos[i];
96 }
97 
98 /// Get length of the element at index i.
99 inline Int_t TFPBlock::GetLen(Int_t i) const
100 {
101  return fLen[i];
102 }
103 
104 /// Get block buffer.
105 inline char* TFPBlock::GetBuffer() const
106 {
107  return fBuffer;
108 }
109 
110 /// Get block buffer.
111 inline char* TFPBlock::GetPtrToPiece(Int_t index) const
112 {
113  return (fBuffer + fRelOffset[index]);
114 }
115 
116 #endif
long long Long64_t
Definition: RtypesCore.h:69
void ReallocBlock(Long64_t *, Int_t *, Int_t)
Reallocate the block's buffer based on the length of the elements it will contain.
Definition: TFPBlock.cxx:94
char * GetPtrToPiece(Int_t index) const
Get block buffer.
Definition: TFPBlock.h:111
int Int_t
Definition: RtypesCore.h:41
void SetPos(Int_t, Long64_t)
Set pos value for index idx.
Definition: TFPBlock.cxx:72
ClassDef(TFPBlock, 0)
void SetBuffer(char *)
Set block buffer.
Definition: TFPBlock.cxx:81
This class represents the encapsulation of a block request.
Definition: TFPBlock.h:24
Long64_t fCapacity
Capacity of the buffer.
Definition: TFPBlock.h:30
Int_t * GetLen() const
Get pointer to the array of lengths.
Definition: TFPBlock.h:68
Long64_t * fRelOffset
Relative offset of piece in the buffer.
Definition: TFPBlock.h:33
Long64_t fDataSize
Total size of useful data in the block.
Definition: TFPBlock.h:29
char * GetBuffer() const
Get block buffer.
Definition: TFPBlock.h:105
Long64_t GetCapacity() const
Return capacity of the block.
Definition: TFPBlock.h:81
TFPBlock & operator=(const TFPBlock &)
Long64_t * GetPos() const
Get pointer to the array of postions.
Definition: TFPBlock.h:62
Int_t fNblock
Number of segment in the block.
Definition: TFPBlock.h:28
char * fBuffer
Content of the block.
Definition: TFPBlock.h:27
Long64_t * fPos
Array of positions of each segment.
Definition: TFPBlock.h:32
Mother of all ROOT objects.
Definition: TObject.h:58
Int_t * fLen
Array of lengths of each segment.
Definition: TFPBlock.h:31
Int_t GetNoElem() const
Return number of elements in the block.
Definition: TFPBlock.h:87
Long64_t GetDataSize() const
Return size of the data in the block.
Definition: TFPBlock.h:75
virtual ~TFPBlock()
Destructor.
Definition: TFPBlock.cxx:60
TFPBlock(const TFPBlock &)