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
21namespace ROOT {
22namespace Experimental {
23
24/******************************************************************************/
25// REveChunkManager
26/******************************************************************************/
27
29{
30private:
33
34protected:
35 Int_t fS; // Size of atom
36 Int_t fN; // Number of atoms in a chunk
37
38 Int_t fSize; // Size of container, number of atoms
39 Int_t fVecSize; // Number of allocated chunks
40 Int_t fCapacity; // Available capacity within the chunks
41
42 std::vector<TArrayC*> fChunks; // Memory blocks
43
44 void ReleaseChunks();
45
46public:
48 REveChunkManager(Int_t atom_size, Int_t chunk_size);
49 virtual ~REveChunkManager();
50
51 void Reset(Int_t atom_size, Int_t chunk_size);
52 void Refit();
53
54 Int_t S() const { return fS; }
55 Int_t N() const { return fN; }
56
57 Int_t Size() const { return fSize; }
58 Int_t VecSize() const { return fVecSize; }
59 Int_t Capacity() const { return fCapacity; }
60
61 Char_t* Atom(Int_t idx) const { return fChunks[idx/fN]->fArray + idx%fN*fS; }
62 Char_t* Chunk(Int_t chk) const { return fChunks[chk]->fArray; }
63 Int_t NAtoms(Int_t chk) const { return (chk < fVecSize-1) ? fN : (fSize-1)%fN + 1; }
64
65 Char_t* NewAtom();
67
68
69 // Iterator
70
71 struct iterator
72 {
74 Char_t *fCurrent{nullptr};
78
79 const std::set<Int_t> *fSelection{nullptr};
80 std::set<Int_t>::const_iterator fSelectionIterator;
81
83
84/* iterator(const iterator &i) :
85 fPlex(i.fPlex), fCurrent(i.fCurrent), fAtomIndex(i.fAtomIndex),
86 fNextChunk(i.fNextChunk), fAtomsToGo(i.fAtomsToGo),
87 fSelection(i.fSelection), fSelectionIterator(i.fSelectionIterator) {}
88
89 iterator& operator=(const iterator& i) {
90 fPlex = i.fPlex; fCurrent = i.fCurrent; fAtomIndex = i.fAtomIndex;
91 fNextChunk = i.fNextChunk; fAtomsToGo = i.fAtomsToGo;
92 fSelection = i.fSelection; fSelectionIterator = i.fSelectionIterator;
93 return *this;
94 }
95*/
96
97 Bool_t next();
98 void reset() { fCurrent = nullptr; fAtomIndex = -1; fNextChunk = fAtomsToGo = 0; }
99
101 Char_t* operator*() { return fCurrent; }
102 Int_t index() { return fAtomIndex; }
103 };
104
105};
106
107
108//______________________________________________________________________________
110{
111 Char_t *a = (fSize >= fCapacity) ? NewChunk() : Atom(fSize);
112 ++fSize;
113 return a;
114}
115
116
117/******************************************************************************/
118// Templated some-class REveChunkVector
119/******************************************************************************/
120
121template<class T>
123{
124private:
127
128public:
129 REveChunkVector() = default;
130 REveChunkVector(Int_t chunk_size) : REveChunkManager(sizeof(T), chunk_size) {}
131 virtual ~REveChunkVector() {}
132
133 void Reset(Int_t chunk_size) { Reset(sizeof(T), chunk_size); }
134
135 T *At(Int_t idx) { return reinterpret_cast<T*>(Atom(idx)); }
136 T &Ref(Int_t idx) { return *At(idx); }
137};
138
139} // namespace Experimental
140} // namespace ROOT
141
142#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
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.
std::set< Int_t >::const_iterator fSelectionIterator
unsigned long Atom
Definition xatom.h:9