Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
REveChunkManager.hxx
Go to the documentation of this file.
1// @(#)root/eve7:$Id$
2// Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2018
3
4/*************************************************************************
5 * Copyright (C) 1995-2019, 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_REveChunkManager
13#define ROOT_REveChunkManager
14
15#include <ROOT/REveUtil.hxx>
16
17#include "TArrayC.h"
18
19#include <vector>
20#include <set>
21
22namespace ROOT {
23namespace Experimental {
24
25/******************************************************************************/
26// REveChunkManager
27/******************************************************************************/
28
30{
31private:
34
35protected:
36 Int_t fS; // Size of atom
37 Int_t fN; // Number of atoms in a chunk
38
39 Int_t fSize; // Size of container, number of atoms
40 Int_t fVecSize; // Number of allocated chunks
41 Int_t fCapacity; // Available capacity within the chunks
42
43 std::vector<TArrayC*> fChunks; // Memory blocks
44
45 void ReleaseChunks();
46
47public:
49 REveChunkManager(Int_t atom_size, Int_t chunk_size);
50 virtual ~REveChunkManager();
51
52 void Reset(Int_t atom_size, Int_t chunk_size);
53 void Refit();
54
55 Int_t S() const { return fS; }
56 Int_t N() const { return fN; }
57
58 Int_t Size() const { return fSize; }
59 Int_t VecSize() const { return fVecSize; }
60 Int_t Capacity() const { return fCapacity; }
61
62 Char_t* Atom(Int_t idx) const { return fChunks[idx/fN]->fArray + idx%fN*fS; }
63 Char_t* Chunk(Int_t chk) const { return fChunks[chk]->fArray; }
64 Int_t NAtoms(Int_t chk) const { return (chk < fVecSize-1) ? fN : (fSize-1)%fN + 1; }
65
66 Char_t* NewAtom();
68
69
70 // Iterator
71
72 struct iterator
73 {
75 Char_t *fCurrent{nullptr};
79
80 const std::set<Int_t> *fSelection{nullptr};
81 std::set<Int_t>::const_iterator fSelectionIterator;
82
84
85/* iterator(const iterator &i) :
86 fPlex(i.fPlex), fCurrent(i.fCurrent), fAtomIndex(i.fAtomIndex),
87 fNextChunk(i.fNextChunk), fAtomsToGo(i.fAtomsToGo),
88 fSelection(i.fSelection), fSelectionIterator(i.fSelectionIterator) {}
89
90 iterator& operator=(const iterator& i) {
91 fPlex = i.fPlex; fCurrent = i.fCurrent; fAtomIndex = i.fAtomIndex;
92 fNextChunk = i.fNextChunk; fAtomsToGo = i.fAtomsToGo;
93 fSelection = i.fSelection; fSelectionIterator = i.fSelectionIterator;
94 return *this;
95 }
96*/
97
98 Bool_t next();
99 void reset() { fCurrent = nullptr; fAtomIndex = -1; fNextChunk = fAtomsToGo = 0; }
100
102 Char_t* operator*() { return fCurrent; }
103 Int_t index() { return fAtomIndex; }
104 };
105
106};
107
108
109//______________________________________________________________________________
111{
112 Char_t *a = (fSize >= fCapacity) ? NewChunk() : Atom(fSize);
113 ++fSize;
114 return a;
115}
116
117
118/******************************************************************************/
119// Templated some-class REveChunkVector
120/******************************************************************************/
121
122template<class T>
124{
125private:
128
129public:
130 REveChunkVector() = default;
131 REveChunkVector(Int_t chunk_size) : REveChunkManager(sizeof(T), chunk_size) {}
132 ~REveChunkVector() override {}
133
134 void Reset(Int_t chunk_size) { Reset(sizeof(T), chunk_size); }
135
136 T *At(Int_t idx) { return reinterpret_cast<T*>(Atom(idx)); }
137 T &Ref(Int_t idx) { return *At(idx); }
138};
139
140} // namespace Experimental
141} // namespace ROOT
142
143#endif
#define a(i)
Definition RSha256.hxx:99
char Char_t
Definition RtypesCore.h:37
winID h TVirtualViewer3D TVirtualGLPainter p
REveChunkManager & operator=(const REveChunkManager &)=delete
void Reset(Int_t atom_size, Int_t chunk_size)
Empty the container and reset it with given atom and chunk sizes.
void Refit()
Refit the container so that all current data fits into a single chunk.
void ReleaseChunks()
Release all memory chunks.
Char_t * NewChunk()
Allocate a new memory chunk and register it.
REveChunkManager(const REveChunkManager &)=delete
REveChunkVector & operator=(const REveChunkVector &)=delete
REveChunkVector(const REveChunkVector &)=delete
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
std::set< Int_t >::const_iterator fSelectionIterator
unsigned long Atom
Definition xatom.h:9