Logo ROOT   6.10/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 #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&); // Not implemented.
34  TFPBlock &operator=(const TFPBlock&); // Not implemented.
35 
36 public:
37 
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.
74 {
75  return fDataSize;
76 }
77 
78 /// Return capacity of the block.
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.
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
long long Long64_t
Definition: RtypesCore.h:69
void ReallocBlock(Long64_t *, Int_t *, Int_t)
Reallocate the block&#39;s buffer based on the length of the elements it will contain.
Definition: TFPBlock.cxx:94
Int_t GetNoElem() const
Return number of elements in the block.
Definition: TFPBlock.h:85
char * GetPtrToPiece(Int_t index) const
Get block buffer.
Definition: TFPBlock.h:109
int Int_t
Definition: RtypesCore.h:41
Int_t * GetLen() const
Get pointer to the array of lengths.
Definition: TFPBlock.h:66
char * GetBuffer() const
Get block buffer.
Definition: TFPBlock.h:103
void SetPos(Int_t, Long64_t)
Set pos value for index idx.
Definition: TFPBlock.cxx:72
#define ClassDef(name, id)
Definition: Rtypes.h:297
void SetBuffer(char *)
Set block buffer.
Definition: TFPBlock.cxx:81
This class represents the encapsulation of a block request.
Definition: TFPBlock.h:22
Long64_t fCapacity
Capacity of the buffer.
Definition: TFPBlock.h:28
Long64_t * fRelOffset
Relative offset of piece in the buffer.
Definition: TFPBlock.h:31
Long64_t fDataSize
Total size of useful data in the block.
Definition: TFPBlock.h:27
TFPBlock & operator=(const TFPBlock &)
Int_t fNblock
Number of segment in the block.
Definition: TFPBlock.h:26
Long64_t GetDataSize() const
Return size of the data in the block.
Definition: TFPBlock.h:73
char * fBuffer
Content of the block.
Definition: TFPBlock.h:25
Long64_t GetCapacity() const
Return capacity of the block.
Definition: TFPBlock.h:79
Long64_t * fPos
Array of positions of each segment.
Definition: TFPBlock.h:30
Mother of all ROOT objects.
Definition: TObject.h:37
Int_t * fLen
Array of lengths of each segment.
Definition: TFPBlock.h:29
Long64_t * GetPos() const
Get pointer to the array of postions.
Definition: TFPBlock.h:60
virtual ~TFPBlock()
Destructor.
Definition: TFPBlock.cxx:60
TFPBlock(const TFPBlock &)