Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TEveChunkManager.cxx
Go to the documentation of this file.
1// @(#)root/eve:$Id$
2// Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
3
4/*************************************************************************
5 * Copyright (C) 1995-2007, 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#include "TEveChunkManager.h"
13
14/** \class TEveChunkManager
15\ingroup TEve
16Vector-like container with chunked memory allocation.
17
18Allocation chunk can accommodate fN atoms of byte-size fS each.
19The chunks themselves are TArrayCs and are stored in a std::vector<TArrayC*>.
20Holes in the structure are not supported, neither is removal of atoms.
21The structure can be Refit() to occupy a single contiguous array.
22*/
23
24
25////////////////////////////////////////////////////////////////////////////////
26/// Release all memory chunks.
27
29{
30 for (Int_t i=0; i<fVecSize; ++i)
31 delete fChunks[i];
32 fChunks.clear();
33}
34
35////////////////////////////////////////////////////////////////////////////////
36/// Default constructor.
37/// Call reset for initialization.
38
40 fS(0), fN(0),
41 fSize(0), fVecSize(0), fCapacity(0)
42{
43}
44
45////////////////////////////////////////////////////////////////////////////////
46/// Constructor.
47
49 fS(atom_size), fN(chunk_size),
50 fSize(0), fVecSize(0), fCapacity(0)
51{
52}
53
54////////////////////////////////////////////////////////////////////////////////
55/// Destructor.
56
61
62////////////////////////////////////////////////////////////////////////////////
63/// Empty the container and reset it with given atom and chunk sizes.
64
72
73////////////////////////////////////////////////////////////////////////////////
74/// Refit the container so that all current data fits into a single
75/// chunk.
76
78{
79 if (fSize == 0 || (fVecSize == 1 && fSize == fCapacity))
80 return;
81
82 TArrayC* one = new TArrayC(fS*fSize);
83 Char_t* pos = one->fArray;
84 for (Int_t i=0; i<fVecSize; ++i)
85 {
86 Int_t size = fS * NAtoms(i);
87 memcpy(pos, fChunks[i]->fArray, size);
88 pos += size;
89 }
91 fN = fCapacity = fSize;
92 fVecSize = 1;
93 fChunks.push_back(one);
94}
95
96////////////////////////////////////////////////////////////////////////////////
97/// Allocate a new memory chunk and register it.
98
100{
101 fChunks.push_back(new TArrayC(fS*fN));
102 ++fVecSize;
103 fCapacity += fN;
104 return fChunks.back()->fArray;
105}
106
107////////////////////////////////////////////////////////////////////////////////
108/// Go to next atom.
109
111{
112 if (fSelection == nullptr)
113 {
114 if (fAtomsToGo <= 0)
115 {
117 {
120 ++fNextChunk;
121 }
122 else
123 {
124 return kFALSE;
125 }
126 }
127 else
128 {
129 fCurrent += fPlex->S();
130 }
131 ++fAtomIndex;
132 --fAtomsToGo;
133 return kTRUE;
134 }
135 else
136 {
137 if (fAtomIndex == -1)
139 else
141
143 {
146 return kTRUE;
147 }
148 else
149 {
150 return kFALSE;
151 }
152 }
153}
dim_t fSize
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
char Char_t
Character 1 byte (char)
Definition RtypesCore.h:51
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
const_iterator begin() const
const_iterator end() const
Array of chars or bytes (8 bits per element).
Definition TArrayC.h:27
void ReleaseChunks()
Release all memory chunks.
Char_t * Chunk(Int_t chk) const
Int_t NAtoms(Int_t chk) const
std::vector< TArrayC * > fChunks
virtual ~TEveChunkManager()
Destructor.
Char_t * Atom(Int_t idx) const
void Reset(Int_t atom_size, Int_t chunk_size)
Empty the container and reset it with given atom and chunk sizes.
Int_t VecSize() const
Char_t * NewChunk()
Allocate a new memory chunk and register it.
void Refit()
Refit the container so that all current data fits into a single chunk.
TEveChunkManager()
Default constructor.
Bool_t next()
Go to next atom.
const std::set< Int_t > * fSelection
std::set< Int_t >::const_iterator fSelectionIterator