Warning, file /include/root/TEveChunkManager.h was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef ROOT_TEveChunkManager
0013 #define ROOT_TEveChunkManager
0014
0015 #include "TEveUtil.h"
0016
0017 #include "TArrayC.h"
0018
0019 #include <vector>
0020 #include <set>
0021
0022
0023
0024
0025
0026 class TEveChunkManager
0027 {
0028 private:
0029 TEveChunkManager(const TEveChunkManager&) = delete;
0030 TEveChunkManager& operator=(const TEveChunkManager&) = delete;
0031
0032 protected:
0033 Int_t fS;
0034 Int_t fN;
0035
0036 Int_t fSize;
0037 Int_t fVecSize;
0038 Int_t fCapacity;
0039
0040 std::vector<TArrayC*> fChunks;
0041
0042 void ReleaseChunks();
0043
0044 public:
0045 TEveChunkManager();
0046 TEveChunkManager(Int_t atom_size, Int_t chunk_size);
0047 virtual ~TEveChunkManager();
0048
0049 void Reset(Int_t atom_size, Int_t chunk_size);
0050 void Refit();
0051
0052 Int_t S() const { return fS; }
0053 Int_t N() const { return fN; }
0054
0055 Int_t Size() const { return fSize; }
0056 Int_t VecSize() const { return fVecSize; }
0057 Int_t Capacity() const { return fCapacity; }
0058
0059 Char_t* Atom(Int_t idx) const { return fChunks[idx/fN]->fArray + idx%fN*fS; }
0060 Char_t* Chunk(Int_t chk) const { return fChunks[chk]->fArray; }
0061 Int_t NAtoms(Int_t chk) const { return (chk < fVecSize-1) ? fN : (fSize-1)%fN + 1; }
0062
0063 Char_t* NewAtom();
0064 Char_t* NewChunk();
0065
0066
0067
0068
0069 struct iterator
0070 {
0071 TEveChunkManager *fPlex;
0072 Char_t *fCurrent;
0073 Int_t fAtomIndex;
0074 Int_t fNextChunk;
0075 Int_t fAtomsToGo;
0076
0077 const std::set<Int_t> *fSelection;
0078 std::set<Int_t>::const_iterator fSelectionIterator;
0079
0080 iterator(TEveChunkManager* p) :
0081 fPlex(p), fCurrent(nullptr), fAtomIndex(-1),
0082 fNextChunk(0), fAtomsToGo(0), fSelection(nullptr), fSelectionIterator() {}
0083 iterator(TEveChunkManager& p) :
0084 fPlex(&p), fCurrent(nullptr), fAtomIndex(-1),
0085 fNextChunk(0), fAtomsToGo(0), fSelection(nullptr), fSelectionIterator() {}
0086 iterator(const iterator& i) :
0087 fPlex(i.fPlex), fCurrent(i.fCurrent), fAtomIndex(i.fAtomIndex),
0088 fNextChunk(i.fNextChunk), fAtomsToGo(i.fAtomsToGo),
0089 fSelection(i.fSelection), fSelectionIterator(i.fSelectionIterator) {}
0090
0091 iterator& operator=(const iterator& i) {
0092 fPlex = i.fPlex; fCurrent = i.fCurrent; fAtomIndex = i.fAtomIndex;
0093 fNextChunk = i.fNextChunk; fAtomsToGo = i.fAtomsToGo;
0094 fSelection = i.fSelection; fSelectionIterator = i.fSelectionIterator;
0095 return *this;
0096 }
0097
0098 Bool_t next();
0099 void reset() { fCurrent = nullptr; fAtomIndex = -1; fNextChunk = fAtomsToGo = 0; }
0100
0101 Char_t* operator()() { return fCurrent; }
0102 Char_t* operator*() { return fCurrent; }
0103 Int_t index() { return fAtomIndex; }
0104 };
0105
0106 ClassDef(TEveChunkManager, 1);
0107 };
0108
0109
0110
0111 inline Char_t* TEveChunkManager::NewAtom()
0112 {
0113 Char_t *a = (fSize >= fCapacity) ? NewChunk() : Atom(fSize);
0114 ++fSize;
0115 return a;
0116 }
0117
0118
0119
0120
0121
0122
0123 template<class T>
0124 class TEveChunkVector : public TEveChunkManager
0125 {
0126 private:
0127 TEveChunkVector(const TEveChunkVector&);
0128 TEveChunkVector& operator=(const TEveChunkVector&);
0129
0130 public:
0131 TEveChunkVector() : TEveChunkManager() {}
0132 TEveChunkVector(Int_t chunk_size) : TEveChunkManager(sizeof(T), chunk_size) {}
0133 ~TEveChunkVector() override {}
0134
0135 void Reset(Int_t chunk_size) { Reset(sizeof(T), chunk_size); }
0136
0137 T* At(Int_t idx) { return reinterpret_cast<T*>(Atom(idx)); }
0138 T& Ref(Int_t idx) { return *At(idx); }
0139
0140 ClassDefOverride(TEveChunkVector, 1);
0141 };
0142
0143 #endif