/usr/include/root/TTable.h is in libroot-misc-table-dev 5.34.30-0ubuntu8.
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 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 | // @(#)root/table:$Id$
// Author: Valery Fine(fine@mail.cern.ch) 03/07/98
/*************************************************************************
* Copyright (C) 1995-2000, 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_TTable
#define ROOT_TTable
//////////////////////////////////////////////////////////////////////////
// //
// TTable //
// //
// It is a base class to create a "wrapper" class //
// holding the plain C-structure array //
// (1 element of the structure per element) //
// //
//////////////////////////////////////////////////////////////////////////
#ifdef __CINT__
#pragma Ccomment on
#endif
#include "Ttypes.h"
#include "TDataSet.h"
#include "tableDescriptor.h"
#ifndef ROOT_TCut
# include "TCut.h"
#endif
# ifndef ROOT_Riosfwd
# include "Riosfwd.h"
# endif
#ifndef __CINT__
# include <string.h>
# include <assert.h>
#endif
#include <vector>
class TTableDescriptor;
class TH1;
class TTableMap;
typedef TTableMap* Ptr_t;
class TTable : public TDataSet {
friend class TDataSet;
friend class St_XDFFile;
protected:
Long_t fSize; // Size of the one element (row) of the table
protected:
Int_t fN; //Number of array elements
Char_t *fTable; // Array of (fN*fSize) longs
Long_t fMaxIndex; // The used capacity of this array
Bool_t BoundsOk(const char *where, Int_t at) const;
Bool_t OutOfBoundsError(const char *where, Int_t i) const;
void CopyStruct(Char_t *dest, const Char_t *src);
Char_t *Create();
virtual void Clear(Option_t *opt="");
virtual void Delete(Option_t *opt="");
virtual Bool_t EntryLoop(const Char_t *exprFileName,Int_t &action, TObject *obj, Int_t nentries=1000000000, Int_t firstentry=0, Option_t *option="");
Int_t SetfN(Long_t len);
void SetTablePointer(void *table);
void SetUsedRows(Int_t n);
virtual void SetType(const char *const type);
void StreamerHeader(TBuffer &b,Version_t version=3);
void StreamerTable(TBuffer &b,Version_t version=3);
virtual TTableDescriptor *GetDescriptorPointer() const;
virtual void SetDescriptorPointer(TTableDescriptor *list);
void ReAlloc(Int_t newsize);
static const char *TableDictionary(const char *className,const char *structName,TTableDescriptor *&ColDescriptors);
public:
enum EColumnType {kNAN, kFloat, kInt, kLong, kShort, kDouble, kUInt
,kULong, kUShort, kUChar, kChar, kPtr, kBool
,kEndColumnType };
enum ETableBits {
kIsNotOwn = BIT(23) // if the TTable wrapper doesn't own the STAF table
// As result of the Update() method for example
};
static const char *fgTypeName[kEndColumnType];
TTable(const char *name=0, Int_t size=0);
TTable(const char *name, Int_t n,Int_t size);
TTable(const char *name, Int_t n, Char_t *array,Int_t size);
TTable(const char *name, const char *type, Int_t n, Char_t *array, Int_t size);
TTable(const TTable &table);
TTable &operator=(const TTable &rhs);
virtual ~TTable();
virtual void Adopt(Int_t n, void *array);
virtual Int_t AddAt(const void *c);
virtual void AddAt(const void *c, Int_t i);
virtual void AddAt(TDataSet *dataset,Int_t idx=0);
virtual Long_t AppendRows(const void *row, UInt_t nRows);
virtual void AsString(void *buf, EColumnType type, Int_t width, ostream &out) const;
const void *At(Int_t i) const;
virtual void Browse(TBrowser *b);
virtual void CopySet(TTable &array);
Int_t CopyRows(const TTable *srcTable,Long_t srcRow=0, Long_t dstRow=0, Long_t nRows=0, Bool_t expand=kFALSE);
virtual void DeleteRows(Long_t indx,UInt_t nRows=1);
virtual void Draw(Option_t *opt);
virtual TH1 *Draw(TCut varexp, TCut selection, Option_t *option=""
,Int_t nentries=1000000000, Int_t firstentry=0);
virtual TH1 *Draw(const char *varexp, const char *selection, Option_t *option=""
,Int_t nentries=1000000000, Int_t firstentry=0); // *MENU*
void *GetArray() const ;
virtual TClass *GetRowClass() const ;
Int_t GetSize() const { return fN; }
virtual Long_t GetNRows() const;
virtual Long_t GetRowSize() const;
virtual Long_t GetTableSize() const;
virtual TTableDescriptor *GetTableDescriptors() const;
virtual TTableDescriptor *GetRowDescriptors() const;
virtual const Char_t *GetType() const;
virtual void Fit(const char *formula ,const char *varexp, const char *selection="",Option_t *option="" ,Option_t *goption=""
,Int_t nentries=1000000000, Int_t firstentry=0); // *MENU*
virtual Long_t HasData() const { return 1; }
virtual Long_t InsertRows(const void *rows, Long_t indx, UInt_t nRows=1);
virtual Bool_t IsFolder() const;
Int_t NaN();
static TTable *New(const Char_t *name, const Char_t *type, void *array, UInt_t size);
virtual Char_t *MakeExpression(const Char_t *expressions[],Int_t nExpressions);
virtual Char_t *Print(Char_t *buf,Int_t n) const ;
virtual void Print(Option_t *opt="") const;
virtual const Char_t *Print(Int_t row, Int_t rownumber=10,
const Char_t *colfirst="", const Char_t *collast="") const; // *MENU*
virtual void PrintContents(Option_t *opt="") const;
virtual const Char_t *PrintHeader() const; // *MENU*
virtual void Project(const char *hname, const char *varexp, const char *selection="", Option_t *option=""
,Int_t nentries=1000000000, Int_t firstentry=0);
virtual Int_t Purge(Option_t *opt="");
void *ReAllocate(Int_t newsize);
void *ReAllocate();
virtual void SavePrimitive(ostream &out, Option_t *option = "");
virtual void Set(Int_t n);
virtual void Set(Int_t n, Char_t *array);
virtual void SetNRows(Int_t n);
virtual void Reset(Int_t c=0);
virtual void ResetMap(Bool_t wipe=kTRUE);
virtual void Update();
virtual void Update(TDataSet *set,UInt_t opt=0);
void *operator[](Int_t i);
const void *operator[](Int_t i) const;
// ---- Table descriptor service ------
virtual Int_t GetColumnIndex(const Char_t *columnName) const;
virtual const Char_t *GetColumnName(Int_t columnIndex) const;
virtual const UInt_t *GetIndexArray(Int_t columnIndex) const;
virtual UInt_t GetNumberOfColumns() const;
virtual UInt_t GetOffset(Int_t columnIndex) const;
virtual Int_t GetOffset(const Char_t *columnName=0) const;
virtual UInt_t GetColumnSize(Int_t columnIndex) const;
virtual Int_t GetColumnSize(const Char_t *columnName=0) const;
virtual UInt_t GetTypeSize(Int_t columnIndex) const;
virtual Int_t GetTypeSize(const Char_t *columnName=0) const ;
virtual UInt_t GetDimensions(Int_t columnIndex) const;
virtual Int_t GetDimensions(const Char_t *columnName=0) const ;
virtual EColumnType GetColumnType(Int_t columnIndex) const;
virtual EColumnType GetColumnType(const Char_t *columnName=0) const;
virtual const Char_t *GetColumnComment(Int_t columnIndex) const;
static const char *GetTypeName(EColumnType type);
static EColumnType GetTypeId(const char *typeName);
// Table index iterator:
class iterator {
public:
typedef std::vector<Long_t>::iterator vec_iterator;
typedef std::vector<Long_t>::const_iterator vec_const_iterator;
private:
Long_t fRowSize;
const TTable *fThisTable;
vec_iterator fCurrentRow;
public:
iterator(): fRowSize(0), fThisTable(0) {;}
iterator(const TTable &table, vec_iterator &arowPtr) :
fRowSize(table.GetRowSize()), fThisTable(&table), fCurrentRow(arowPtr) {;}
iterator(const TTable &table, vec_const_iterator &arowPtr) :
fRowSize(table.GetRowSize()), fThisTable(&table),
fCurrentRow(*(std::vector<Long_t>::iterator *)(void *)&arowPtr) {;}
//fCurrentRow(* const_cast<vector<Long_t>::iterator *>(&arowPtr) ) {;}
iterator(const iterator& iter) : fRowSize (iter.fRowSize), fThisTable(iter.fThisTable),fCurrentRow(iter.fCurrentRow){}
iterator &operator=(const iterator& iter) { fRowSize = iter.fRowSize; fThisTable = iter.fThisTable; fCurrentRow=iter.fCurrentRow; return *this; }
void operator++() { ++fCurrentRow; }
void operator++(int) { fCurrentRow++; }
void operator--() { --fCurrentRow; }
void operator--(int) { fCurrentRow--; }
iterator operator+(Int_t idx) { std::vector<Long_t>::iterator addition = fCurrentRow+idx; return iterator(*fThisTable,addition); }
iterator operator-(Int_t idx) { std::vector<Long_t>::iterator subtraction = fCurrentRow-idx; return iterator(*fThisTable,subtraction); }
void operator+=(Int_t idx) { fCurrentRow+=idx; }
void operator-=(Int_t idx) { fCurrentRow-=idx; }
void *rowPtr() const { return (void *)(((const char *)fThisTable->GetArray()) + (*fCurrentRow)*fRowSize ); }
operator void *() const { return rowPtr(); }
Int_t operator-(const iterator &it) const { return (*fCurrentRow)-(*(it.fCurrentRow)); }
Long_t operator *() const { return *fCurrentRow; }
Bool_t operator==(const iterator &t) const { return ( (fCurrentRow == t.fCurrentRow) && (fThisTable == t.fThisTable) ); }
Bool_t operator!=(const iterator &t) const { return !operator==(t); }
const TTable &Table() const { return *fThisTable;}
const Long_t &RowSize() const { return fRowSize;}
#ifndef __CINT__
const std::vector<Long_t>::iterator &Row() const { return fCurrentRow;}
#endif
};
#ifndef __CINT__
// pointer iterator
// This create an iterator to iterate over all table column of the
// type provided.
// For example" piterator(table,kPtr) is to iterate over
// all cells of (TTableMap *) type
class piterator {
private:
std::vector<ULong_t> fPtrs;
UInt_t fCurrentRowIndex;
UInt_t fCurrentColIndex;
UInt_t fRowSize;
const Char_t *fCurrentRowPtr;
void **fCurrentColPtr;
protected:
void **column() {return fCurrentColPtr = (void **)(fCurrentRowPtr + fPtrs[fCurrentColIndex]);}
public:
piterator(const TTable *t=0,EColumnType type=kPtr);
piterator(const piterator& iter);
void operator=(const piterator& iter);
void operator++();
void operator++(int);
void operator--();
void operator--(int);
// operator const char *() const;
void **operator *();
Bool_t operator==(const piterator &t) const;
Bool_t operator!=(const piterator &t) const;
UInt_t Row() const;
UInt_t Column() const;
void MakeEnd(UInt_t lastRowIndex);
}; // class iterator over pointers
piterator pbegin(){ return piterator(this); }
piterator pend(){ piterator pLast(this); pLast.MakeEnd(GetNRows()); return pLast; }
#endif
static const char *TableDictionary() { return 0; };
ClassDef(TTable,4) // vector of the C structures
};
//________________________________________________________________________
inline void TTable::AddAt(TDataSet *dataset,Int_t idx)
{ TDataSet::AddAt(dataset,idx); }
//________________________________________________________________________
inline Bool_t TTable::BoundsOk(const char *where, Int_t at) const
{
return (at < 0 || at >= fN)
? OutOfBoundsError(where, at)
: kTRUE;
}
//________________________________________________________________________
inline void *TTable::GetArray() const { return (void *)fTable;}
//________________________________________________________________________
inline void TTable::Print(Option_t *) const { Print((Char_t *)0,Int_t(0)); }
//________________________________________________________________________
inline void TTable::SetUsedRows(Int_t n) { fMaxIndex = n;}
//________________________________________________________________________
inline void TTable::SetNRows(Int_t n) {SetUsedRows(n);}
// ULong_t &operator(){ return GetTable();}
//________________________________________________________________________
inline void *TTable::operator[](Int_t i)
{
if (!BoundsOk("TTable::operator[]", i))
i = 0;
return (void *)(fTable+i*fSize);
}
//________________________________________________________________________
inline const void *TTable::operator[](Int_t i) const
{
if (!BoundsOk("TTable::operator[]", i))
i = 0;
return (const void *)(fTable+i*fSize);
}
//________________________________________________________________________
inline void TTable::Draw(Option_t *opt)
{ Draw(opt, "", "", 1000000000, 0); }
#ifndef __CINT__
//________________________________________________________________________________________________________________
inline TTable::piterator::piterator(const piterator& iter) :
fPtrs (iter.fPtrs),
fCurrentRowIndex(iter.fCurrentRowIndex),
fCurrentColIndex(iter.fCurrentColIndex),
fRowSize(iter.fRowSize),
fCurrentRowPtr(iter.fCurrentRowPtr),
fCurrentColPtr(iter.fCurrentColPtr)
{}
//________________________________________________________________________________________________________________
inline void TTable::piterator::operator=(const piterator& iter){
fPtrs = iter.fPtrs;
fCurrentRowIndex = iter.fCurrentRowIndex;
fCurrentColIndex = iter.fCurrentColIndex;
fRowSize = iter.fRowSize;
fCurrentRowPtr = iter.fCurrentRowPtr;
fCurrentColPtr = iter.fCurrentColPtr;
}
//________________________________________________________________________________________________________________
inline void TTable::piterator::operator++()
{
++fCurrentColIndex;
if (fCurrentColIndex >= fPtrs.size()) {
fCurrentColIndex = 0;
++fCurrentRowIndex;
fCurrentRowPtr += fRowSize;
}
column();
}
//________________________________________________________________________________________________________________
inline void TTable::piterator::operator++(int) { operator++(); }
//________________________________________________________________________________________________________________
inline void TTable::piterator::operator--()
{
if (fCurrentColIndex > 0) {
fCurrentColIndex--;
fCurrentColIndex = fPtrs.size()-1;
--fCurrentRowIndex;
fCurrentRowPtr -= fRowSize;
} else {
fCurrentColIndex--;
}
column();
}
//________________________________________________________________________________________________________________
inline void TTable::piterator::operator--(int) { operator--(); }
//________________________________________________________________________________________________________________
// inline TTable::piterator::operator const char *() const { return fCurrentColPtr; }
//________________________________________________________________________________________________________________
inline void **TTable::piterator::operator *() { return fCurrentColPtr; }
//________________________________________________________________________________________________________________
inline Bool_t TTable::piterator::operator==(const piterator &t) const {
return (
(fCurrentRowIndex== t.fCurrentRowIndex)
&& (fCurrentColIndex == t.fCurrentColIndex)
// && (fCurrentRowPtr == t.fCurrentRowPtr )
// && (fCurrentColPtr == t.fCurrentColPtr )
);
}
//________________________________________________________________________________________________________________
inline Bool_t TTable::piterator::operator!=(const piterator &t) const { return !operator==(t); }
//________________________________________________________________________________________________________________
inline void TTable::piterator::MakeEnd(UInt_t lastRowIndex){fCurrentColIndex = 0; fCurrentRowIndex = lastRowIndex;}
//________________________________________________________________________________________________________________
inline UInt_t TTable::piterator::Row() const { return fCurrentRowIndex;}
//________________________________________________________________________________________________________________
inline UInt_t TTable::piterator::Column() const { return fCurrentColIndex;}
#endif
#include "TTableDescriptor.h"
#endif
|