31 #include "tableDescriptor.h"
50 friend class St_XDFFile;
60 Bool_t BoundsOk(
const char *where, Int_t at)
const;
63 void CopyStruct(Char_t *dest,
const Char_t *src);
65 virtual void Clear(Option_t *opt=
"");
66 virtual void Delete(Option_t *opt=
"");
67 virtual Bool_t
EntryLoop(
const Char_t *exprFileName,Int_t &action, TObject *obj, Int_t nentries=1000000000, Int_t firstentry=0, Option_t *option=
"");
68 Int_t
SetfN(Long_t len);
70 void SetUsedRows(Int_t n);
71 virtual void SetType(
const char *
const type);
82 enum EColumnType {kNAN, kFloat, kInt, kLong, kShort, kDouble, kUInt
83 ,kULong, kUShort, kUChar, kChar, kPtr, kBool
89 static const char *fgTypeName[kEndColumnType];
90 TTable(
const char *name=0, Int_t size=0);
91 TTable(
const char *name, Int_t n,Int_t size);
92 TTable(
const char *name, Int_t n, Char_t *array,Int_t size);
93 TTable(
const char *name,
const char *type, Int_t n, Char_t *array, Int_t size);
98 virtual void Adopt(Int_t n,
void *array);
99 virtual Int_t
AddAt(
const void *c);
100 virtual void AddAt(
const void *c, Int_t i);
102 virtual Long_t
AppendRows(
const void *row, UInt_t nRows);
103 virtual void AsString(
void *buf, EColumnType type, Int_t width, std::ostream &out)
const;
104 const void *
At(Int_t i)
const;
105 virtual void Browse(TBrowser *b);
107 Int_t
CopyRows(
const TTable *srcTable,Long_t srcRow=0, Long_t dstRow=0, Long_t nRows=0, Bool_t expand=kFALSE);
108 virtual void DeleteRows(Long_t indx,UInt_t nRows=1);
109 virtual void Draw(Option_t *opt);
110 virtual TH1 *Draw(TCut varexp, TCut selection, Option_t *option=
""
111 ,Int_t nentries=1000000000, Int_t firstentry=0);
112 virtual TH1 *Draw(
const char *varexp,
const char *selection, Option_t *option=
""
113 ,Int_t nentries=1000000000, Int_t firstentry=0);
114 void *GetArray()
const ;
116 Int_t GetSize()
const {
return fN; }
122 virtual const Char_t *
GetType()
const;
123 virtual void Fit(
const char *formula ,
const char *varexp,
const char *selection=
"",Option_t *option=
"" ,Option_t *goption=
""
124 ,Int_t nentries=1000000000, Int_t firstentry=0);
126 virtual Long_t HasData()
const {
return 1; }
127 virtual Long_t
InsertRows(
const void *rows, Long_t indx, UInt_t nRows=1);
130 static TTable *
New(
const Char_t *name,
const Char_t *type,
void *array, UInt_t size);
131 virtual Char_t *
MakeExpression(
const Char_t *expressions[],Int_t nExpressions);
132 virtual Char_t *
Print(Char_t *buf,Int_t n)
const ;
133 virtual void Print(Option_t *opt=
"")
const;
134 virtual const Char_t *
Print(Int_t row, Int_t rownumber=10,
135 const Char_t *colfirst=
"",
const Char_t *collast=
"")
const;
138 virtual void Project(
const char *hname,
const char *varexp,
const char *selection=
"", Option_t *option=
""
139 ,Int_t nentries=1000000000, Int_t firstentry=0);
141 virtual Int_t
Purge(Option_t *opt=
"");
145 virtual void SavePrimitive(std::ostream &out, Option_t *option =
"");
146 virtual void Set(Int_t n);
147 virtual void Set(Int_t n, Char_t *array);
148 virtual void SetNRows(Int_t n);
149 virtual void Reset(Int_t c=0);
150 virtual void ResetMap(Bool_t wipe=kTRUE);
153 void *operator[](Int_t i);
154 const void *operator[](Int_t i)
const;
159 virtual Int_t GetColumnIndex(
const Char_t *columnName)
const;
160 virtual const Char_t *GetColumnName(Int_t columnIndex)
const;
161 virtual const UInt_t *GetIndexArray(Int_t columnIndex)
const;
162 virtual UInt_t GetNumberOfColumns()
const;
163 virtual UInt_t GetOffset(Int_t columnIndex)
const;
164 virtual Int_t GetOffset(
const Char_t *columnName=0)
const;
165 virtual UInt_t GetColumnSize(Int_t columnIndex)
const;
166 virtual Int_t GetColumnSize(
const Char_t *columnName=0)
const;
167 virtual UInt_t GetTypeSize(Int_t columnIndex)
const;
168 virtual Int_t GetTypeSize(
const Char_t *columnName=0)
const ;
169 virtual UInt_t GetDimensions(Int_t columnIndex)
const;
170 virtual Int_t GetDimensions(
const Char_t *columnName=0)
const ;
171 virtual EColumnType GetColumnType(Int_t columnIndex)
const;
172 virtual EColumnType GetColumnType(
const Char_t *columnName=0)
const;
176 static EColumnType
GetTypeId(
const char *typeName);
181 typedef std::vector<Long_t>::iterator vec_iterator;
182 typedef std::vector<Long_t>::const_iterator vec_const_iterator;
186 vec_iterator fCurrentRow;
189 fRowSize(table.
GetRowSize()), fThisTable(&table), fCurrentRow(arowPtr) {;}
191 fRowSize(table.
GetRowSize()), fThisTable(&table),
192 fCurrentRow(*(std::vector<Long_t>::iterator *)(
void *)&arowPtr) {;}
194 iterator(
const iterator& iter) : fRowSize (iter.fRowSize), fThisTable(iter.fThisTable),fCurrentRow(iter.fCurrentRow){}
195 iterator &operator=(
const iterator& iter) { fRowSize = iter.fRowSize; fThisTable = iter.fThisTable; fCurrentRow=iter.fCurrentRow;
return *
this; }
197 void operator++(
int);
199 void operator--(
int);
202 void operator+=(Int_t idx);
203 void operator-=(Int_t idx);
204 void *rowPtr()
const;
205 operator void *()
const;
206 Int_t operator-(
const iterator &it)
const;
207 Long_t operator *()
const;
208 Bool_t operator==(
const iterator &t)
const;
209 Bool_t operator!=(
const iterator &t)
const;
211 const TTable &Table()
const {
return *fThisTable;}
212 const Long_t &RowSize()
const {
return fRowSize;}
214 const std::vector<Long_t>::iterator &Row()
const {
return fCurrentRow;}
227 std::vector<ULong_t> fPtrs;
228 UInt_t fCurrentRowIndex;
229 UInt_t fCurrentColIndex;
231 const Char_t *fCurrentRowPtr;
232 void **fCurrentColPtr;
235 void **
column() {
return fCurrentColPtr = (
void **)(fCurrentRowPtr + fPtrs[fCurrentColIndex]);}
243 void operator++(
int);
245 void operator--(
int);
250 Bool_t operator==(
const piterator &t)
const;
251 Bool_t operator!=(
const piterator &t)
const;
254 UInt_t Column()
const;
256 void MakeEnd(UInt_t lastRowIndex);
260 piterator pend(){ piterator pLast(
this); pLast.MakeEnd(
GetNRows());
return pLast; }
262 static const char *TableDictionary() {
return 0; };
271 inline Bool_t TTable::BoundsOk(
const char *where, Int_t at)
const
273 return (at < 0 || at >= fN)
279 inline void *TTable::GetArray()
const {
return (
void *)fTable;}
285 inline void TTable::SetUsedRows(Int_t n) { fMaxIndex = n;}
287 inline void TTable::SetNRows(Int_t n) {SetUsedRows(n);}
291 inline void *TTable::operator[](Int_t i)
293 if (!BoundsOk(
"TTable::operator[]", i))
295 return (
void *)(fTable+i*fSize);
299 inline const void *TTable::operator[](Int_t i)
const
301 if (!BoundsOk(
"TTable::operator[]", i))
303 return (
const void *)(fTable+i*fSize);
307 inline void TTable::Draw(Option_t *opt)
308 { Draw(opt,
"",
"", 1000000000, 0); }
314 fCurrentRowIndex(iter.fCurrentRowIndex),
315 fCurrentColIndex(iter.fCurrentColIndex),
316 fRowSize(iter.fRowSize),
317 fCurrentRowPtr(iter.fCurrentRowPtr),
318 fCurrentColPtr(iter.fCurrentColPtr)
321 inline void TTable::piterator::operator=(
const piterator& iter){
323 fCurrentRowIndex = iter.fCurrentRowIndex;
324 fCurrentColIndex = iter.fCurrentColIndex;
325 fRowSize = iter.fRowSize;
326 fCurrentRowPtr = iter.fCurrentRowPtr;
327 fCurrentColPtr = iter.fCurrentColPtr;
330 inline void TTable::piterator::operator++()
333 if (fCurrentColIndex >= fPtrs.size()) {
334 fCurrentColIndex = 0;
336 fCurrentRowPtr += fRowSize;
341 inline void TTable::piterator::operator++(
int) { operator++(); }
343 inline void TTable::piterator::operator--()
345 if (fCurrentColIndex > 0) {
347 fCurrentColIndex = fPtrs.size()-1;
349 fCurrentRowPtr -= fRowSize;
356 inline void TTable::piterator::operator--(
int) { operator--(); }
360 inline void **TTable::piterator::operator *() {
return fCurrentColPtr; }
362 inline Bool_t TTable::piterator::operator==(
const piterator &t)
const {
364 (fCurrentRowIndex== t.fCurrentRowIndex)
365 && (fCurrentColIndex == t.fCurrentColIndex)
371 inline Bool_t TTable::piterator::operator!=(
const piterator &t)
const {
return !operator==(t); }
373 inline void TTable::piterator::MakeEnd(UInt_t lastRowIndex){fCurrentColIndex = 0; fCurrentRowIndex = lastRowIndex;}
375 inline UInt_t TTable::piterator::Row()
const {
return fCurrentRowIndex;}
377 inline UInt_t TTable::piterator::Column()
const {
return fCurrentColIndex;}
virtual Long_t InsertRows(const void *rows, Long_t indx, UInt_t nRows=1)
Int_t SetfN(Long_t len)
to be documented
virtual TClass * GetRowClass() const
to be documented
virtual Long_t GetRowSize() const
Returns the size (in bytes) of one table row.
virtual const Char_t * GetType() const
Returns the type of the wrapped C-structure kept as the TNamed title.
void StreamerHeader(TBuffer &b, Version_t version=3)
Read "table parameters first".
TTable & operator=(const TTable &rhs)
virtual void Browse(TBrowser *b)
Wrap each table coulumn with TColumnView object to browse.
virtual const Char_t * PrintHeader() const
Print general table inforamtion.
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a primitive as a C++ statement(s) on output stream "out".
TTable(const char *name=0, Int_t size=0)
Default TTable ctor.
virtual void PrintContents(Option_t *opt="") const
to be documented
static const char * TableDictionary(const char *className, const char *structName, TTableDescriptor *&ColDescriptors)
virtual void Set(Int_t n)
Set array size of TTable object to n longs. If n<0 leave array unchanged.
Int_t CopyRows(const TTable *srcTable, Long_t srcRow=0, Long_t dstRow=0, Long_t nRows=0, Bool_t expand=kFALSE)
virtual Bool_t EntryLoop(const Char_t *exprFileName, Int_t &action, TObject *obj, Int_t nentries=1000000000, Int_t firstentry=0, Option_t *option="")
virtual TTableDescriptor * GetRowDescriptors() const
to be documented
virtual void SetType(const char *const type)
to be documented
virtual Long_t GetNRows() const
Returns the number of the used rows for the wrapped table.
Bool_t OutOfBoundsError(const char *where, Int_t i) const
Generate an out-of-bounds error. Always returns false.
virtual Int_t AddAt(const void *c)
virtual Long_t AppendRows(const void *row, UInt_t nRows)
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)
virtual void Update()
to be documented
virtual void ResetMap(Bool_t wipe=kTRUE)
virtual void DeleteRows(Long_t indx, UInt_t nRows=1)
virtual ~TTable()
Delete TTable object.
virtual TTableDescriptor * GetTableDescriptors() const
protected: create a new TTableDescriptor descriptor for this table
void StreamerTable(TBuffer &b, Version_t version=3)
Stream an object of class TTable.
virtual void AddAt(TDataSet *dataset, Int_t idx=0)
void SetTablePointer(void *table)
to be documented
void CopyStruct(Char_t *dest, const Char_t *src)
static EColumnType GetTypeId(const char *typeName)
static TTable * New(const Char_t *name, const Char_t *type, void *array, UInt_t size)
This static method creates a new TTable object if provided.
virtual Long_t GetTableSize() const
Returns the number of the allocated rows.
virtual Char_t * MakeExpression(const Char_t *expressions[], Int_t nExpressions)
static const char * GetTypeName(EColumnType type)
return table type name
virtual void Project(const char *hname, const char *varexp, const char *selection="", Option_t *option="", Int_t nentries=1000000000, Int_t firstentry=0)
const void * At(Int_t i) const
Returns a pointer to the i-th row of the table.
virtual TTableDescriptor * GetDescriptorPointer() const
to be documented
virtual void SetDescriptorPointer(TTableDescriptor *list)
to be documented
piterator(const TTable *t=0, EColumnType type=kPtr)
to be documented
virtual void Delete(Option_t *opt="")
virtual Bool_t IsFolder() const
virtual void Clear(Option_t *opt="")
virtual Char_t * Print(Char_t *buf, Int_t n) const
Create IDL table defintion (to be used for XDF I/O)
virtual void Adopt(Int_t n, void *array)
virtual void CopySet(TTable &array)
to be documented
void ReAlloc(Int_t newsize)
The table is reallocated if it is an owner of the internal array.
virtual const Char_t * GetColumnComment(Int_t columnIndex) const
Get a comment from the table descriptor.
virtual void AsString(void *buf, EColumnType type, Int_t width, std::ostream &out) const
virtual void Reset(Int_t c=0)
Fill the entire table with byte "c" ; / c=0 "be default"
virtual Int_t Purge(Option_t *opt="")
Shrink the table to free the unused but still allocated rows.