12 #ifndef ROOT_TEveChunkManager
13 #define ROOT_TEveChunkManager
27 class TEveChunkManager
30 TEveChunkManager(
const TEveChunkManager&);
31 TEveChunkManager& operator=(
const TEveChunkManager&);
41 std::vector<TArrayC*> fChunks;
47 TEveChunkManager(Int_t atom_size, Int_t chunk_size);
48 virtual ~TEveChunkManager();
50 void Reset(Int_t atom_size, Int_t chunk_size);
53 Int_t S()
const {
return fS; }
54 Int_t N()
const {
return fN; }
56 Int_t Size()
const {
return fSize; }
57 Int_t VecSize()
const {
return fVecSize; }
58 Int_t Capacity()
const {
return fCapacity; }
60 Char_t* Atom(Int_t idx)
const {
return fChunks[idx/fN]->fArray + idx%fN*fS; }
61 Char_t* Chunk(Int_t chk)
const {
return fChunks[chk]->fArray; }
62 Int_t NAtoms(Int_t chk)
const {
return (chk < fVecSize-1) ? fN : (fSize-1)%fN + 1; }
72 TEveChunkManager *fPlex;
78 const std::set<Int_t> *fSelection;
79 std::set<Int_t>::const_iterator fSelectionIterator;
81 iterator(TEveChunkManager* p) :
82 fPlex(p), fCurrent(0), fAtomIndex(-1),
83 fNextChunk(0), fAtomsToGo(0), fSelection(0), fSelectionIterator() {}
84 iterator(TEveChunkManager& p) :
85 fPlex(&p), fCurrent(0), fAtomIndex(-1),
86 fNextChunk(0), fAtomsToGo(0), fSelection(0), fSelectionIterator() {}
87 iterator(
const iterator& i) :
88 fPlex(i.fPlex), fCurrent(i.fCurrent), fAtomIndex(i.fAtomIndex),
89 fNextChunk(i.fNextChunk), fAtomsToGo(i.fAtomsToGo),
90 fSelection(i.fSelection), fSelectionIterator(i.fSelectionIterator) {}
92 iterator& operator=(
const iterator& i) {
93 fPlex = i.fPlex; fCurrent = i.fCurrent; fAtomIndex = i.fAtomIndex;
94 fNextChunk = i.fNextChunk; fAtomsToGo = i.fAtomsToGo;
95 fSelection = i.fSelection; fSelectionIterator = i.fSelectionIterator;
100 void reset() { fCurrent = 0; fAtomIndex = -1; fNextChunk = fAtomsToGo = 0; }
102 Char_t* operator()() {
return fCurrent; }
103 Char_t* operator*() {
return fCurrent; }
104 Int_t index() {
return fAtomIndex; }
107 ClassDef(TEveChunkManager, 1);
112 inline Char_t* TEveChunkManager::NewAtom()
114 Char_t *a = (fSize >= fCapacity) ? NewChunk() : Atom(fSize);
125 class TEveChunkVector :
public TEveChunkManager
128 TEveChunkVector(
const TEveChunkVector&);
129 TEveChunkVector& operator=(
const TEveChunkVector&);
132 TEveChunkVector() : TEveChunkManager() {}
133 TEveChunkVector(Int_t chunk_size) : TEveChunkManager(sizeof(T), chunk_size) {}
134 virtual ~TEveChunkVector() {}
136 void Reset(Int_t chunk_size) { Reset(
sizeof(T), chunk_size); }
138 T* At(Int_t idx) {
return reinterpret_cast<T*
>(Atom(idx)); }
139 T& Ref(Int_t idx) {
return *At(idx); }
141 ClassDef(TEveChunkVector, 1);