/usr/include/root/TEveChunkManager.h is in libroot-graf3d-eve-dev 5.34.14-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | // @(#)root/eve:$Id$
// Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
/*************************************************************************
* Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/
#ifndef ROOT_TEveChunkManager
#define ROOT_TEveChunkManager
#include "TEveUtil.h"
#include "TObject.h"
#include "TArrayC.h"
#include <vector>
/******************************************************************************/
// TEveChunkManager
/******************************************************************************/
class TEveChunkManager
{
private:
TEveChunkManager(const TEveChunkManager&); // Not implemented
TEveChunkManager& operator=(const TEveChunkManager&); // Not implemented
protected:
Int_t fS; // Size of atom
Int_t fN; // Number of atoms in a chunk
Int_t fSize; // Size of container, number of atoms
Int_t fVecSize; // Number of allocated chunks
Int_t fCapacity; // Available capacity within the chunks
std::vector<TArrayC*> fChunks; // Memory blocks
void ReleaseChunks();
public:
TEveChunkManager();
TEveChunkManager(Int_t atom_size, Int_t chunk_size);
virtual ~TEveChunkManager();
void Reset(Int_t atom_size, Int_t chunk_size);
void Refit();
Int_t S() const { return fS; }
Int_t N() const { return fN; }
Int_t Size() const { return fSize; }
Int_t VecSize() const { return fVecSize; }
Int_t Capacity() const { return fCapacity; }
Char_t* Atom(Int_t idx) const { return fChunks[idx/fN]->fArray + idx%fN*fS; }
Char_t* Chunk(Int_t chk) const { return fChunks[chk]->fArray; }
Int_t NAtoms(Int_t chk) const { return (chk < fVecSize-1) ? fN : (fSize-1)%fN + 1; }
Char_t* NewAtom();
Char_t* NewChunk();
// Iterator
struct iterator
{
TEveChunkManager *fPlex;
Char_t *fCurrent;
Int_t fAtomIndex;
Int_t fNextChunk;
Int_t fAtomsToGo;
const std::set<Int_t> *fSelection;
std::set<Int_t>::const_iterator fSelectionIterator;
iterator(TEveChunkManager* p) :
fPlex(p), fCurrent(0), fAtomIndex(-1),
fNextChunk(0), fAtomsToGo(0), fSelection(0), fSelectionIterator() {}
iterator(TEveChunkManager& p) :
fPlex(&p), fCurrent(0), fAtomIndex(-1),
fNextChunk(0), fAtomsToGo(0), fSelection(0), fSelectionIterator() {}
iterator(const iterator& i) :
fPlex(i.fPlex), fCurrent(i.fCurrent), fAtomIndex(i.fAtomIndex),
fNextChunk(i.fNextChunk), fAtomsToGo(i.fAtomsToGo),
fSelection(i.fSelection), fSelectionIterator(i.fSelectionIterator) {}
iterator& operator=(const iterator& i) {
fPlex = i.fPlex; fCurrent = i.fCurrent; fAtomIndex = i.fAtomIndex;
fNextChunk = i.fNextChunk; fAtomsToGo = i.fAtomsToGo;
fSelection = i.fSelection; fSelectionIterator = i.fSelectionIterator;
return *this;
}
Bool_t next();
void reset() { fCurrent = 0; fAtomIndex = -1; fNextChunk = fAtomsToGo = 0; }
Char_t* operator()() { return fCurrent; }
Char_t* operator*() { return fCurrent; }
Int_t index() { return fAtomIndex; }
};
ClassDef(TEveChunkManager, 1); // Vector-like container with chunked memory allocation.
};
//______________________________________________________________________________
inline Char_t* TEveChunkManager::NewAtom()
{
Char_t *a = (fSize >= fCapacity) ? NewChunk() : Atom(fSize);
++fSize;
return a;
}
/******************************************************************************/
// Templated some-class TEveChunkVector
/******************************************************************************/
template<class T>
class TEveChunkVector : public TEveChunkManager
{
private:
TEveChunkVector(const TEveChunkVector&); // Not implemented
TEveChunkVector& operator=(const TEveChunkVector&); // Not implemented
public:
TEveChunkVector() : TEveChunkManager() {}
TEveChunkVector(Int_t chunk_size) : TEveChunkManager(sizeof(T), chunk_size) {}
virtual ~TEveChunkVector() {}
void Reset(Int_t chunk_size) { Reset(sizeof(T), chunk_size); }
T* At(Int_t idx) { return reinterpret_cast<T*>(Atom(idx)); }
T& Ref(Int_t idx) { return *At(idx); }
ClassDef(TEveChunkVector, 1); // Templated class for specific atom classes (given as template argument).
};
#endif
|