Logo ROOT   6.12/07
Reference Guide
TChair.h
Go to the documentation of this file.
1 // @(#)root/table:$Id$
2 // Author: Valery Fine(fine@bnl.gov) 13/03/2000
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TChair
13 #define ROOT_TChair
14 
15 //////////////////////////////////////////////////////////////////////////
16 // //
17 // TChair //
18 // //
19 // It is a base class to create a custom interface for TTable objects //
20 // //
21 //////////////////////////////////////////////////////////////////////////
22 
23 #include "TTable.h"
24 
25 #include "TCut.h"
26 
27 class TChair : public TDataSet {
28 
29 protected:
30 
31  TTable *fTable; // the "TTable" object this object is pthe proxy for
32  ULong_t fLastIndx; // index pof the last used table row;
33  void *fLastRow; // pointer to the last used table row; fLastRow = table[fLastIndx]
34 
35  TTable *GetThisTable() {return fTable; }
36  const TTable *GetThisTable() const {return fTable; }
37  static void *GetOffset(const void *base,ULong_t offset) { return (void *)((Char_t *)base + offset);}
38  TChair() : fTable(0), fLastIndx(0), fLastRow(0) { ; }
39 
40 public:
41 
42  TChair(TTable *table) : fTable(table),fLastIndx(0),fLastRow(0) { ; }
43  TChair(const TChair &org) : TDataSet(org) {assert(0);}
44 // TChair &operator=(const TChair &rhs){ assert(0); return rhs;}
45  virtual ~TChair(){;}
46 
47  virtual void Adopt(Int_t n, void *array){GetThisTable()->Adopt(n,array);}
48  virtual void AddAt(TDataSet *dataset,Int_t idx);
49  virtual void AddAt(const void *c, Int_t i){GetThisTable()->AddAt(c,i);}
50  const void *At(Int_t i) const {return GetThisTable()->At(i);}
51  virtual void Browse(TBrowser *b){GetThisTable()->Browse(b);}
52  virtual void CopySet(TChair &chair){GetThisTable()->CopySet(*chair.GetThisTable());}
53  Int_t CopyRows(const TChair *srcChair, Int_t srcRow=0, Int_t dstRow=0, Int_t nRows=0, Bool_t expand=kFALSE)
54  {return GetThisTable()->CopyRows(srcChair->GetThisTable(),srcRow,dstRow,nRows,expand);}
55  virtual void Draw(Option_t *opt){GetThisTable()->Draw(opt);}
56  virtual TH1 *Draw(TCut varexp, TCut selection, Option_t *option="",
57  Int_t nentries=1000000000, Int_t firstentry=0)
58  {return GetThisTable()->Draw(varexp,selection,option,nentries,firstentry);}
59  virtual TH1 *Draw(const char *varexp, const char *selection, Option_t *option="",
60  Int_t nentries=1000000000, Int_t firstentry=0) {
61  return GetThisTable()->Draw(varexp,selection,option,nentries,firstentry);}
62  virtual Char_t *GetArray() const {return (Char_t *)GetThisTable()->GetArray();}
63  virtual TClass *GetRowClass() const {return GetThisTable()->GetRowClass();}
64  virtual Long_t GetNRows() const {return GetThisTable()->GetNRows();}
65  virtual Long_t GetRowSize() const {return GetThisTable()->GetRowSize();}
66  virtual Long_t GetTableSize() const{return GetThisTable()->GetTableSize();}
67  const TTable *Table() const {return fTable; }
69  virtual const Char_t *GetType() const {return GetThisTable()->GetType();}
70  virtual void Fit(const char *formula ,const char *varexp, const char *selection="",Option_t *option="",Option_t *goption="",
71  Int_t nentries=1000000000, Int_t firstentry=0) {
72  GetThisTable()->Fit(formula,varexp,selection,option,goption,nentries,firstentry);}
73  virtual Long_t HasData() const { return GetThisTable()->HasData();}
74  virtual Bool_t IsFolder() const { return GetThisTable()->IsFolder();}
75  virtual void ls(Option_t *option="") const {GetThisTable()->ls(option);}
76  virtual void ls(Int_t deep) const {GetThisTable()->ls(deep);}
77  Int_t NaN() {return GetThisTable()->NaN();}
78  virtual Char_t *MakeExpression(const Char_t *expressions[],Int_t nExpressions)
79  {return GetThisTable()->MakeExpression(expressions,nExpressions);}
80  virtual Char_t *Print(Char_t *buf,Int_t n) const { return GetThisTable()->Print(buf, n);}
81  virtual void Print(Option_t *opt="") const {GetThisTable()->Print(opt);}
82  virtual const Char_t *Print(Int_t row, Int_t rownumber=10,
83  const Char_t *colfirst="",const Char_t *collast="") const {
84  return GetThisTable()->Print(row,rownumber,colfirst,collast); }
85  virtual const Char_t *PrintHeader() const {return GetThisTable()->PrintHeader();}
86  virtual Int_t Purge(Option_t *opt="") {return GetThisTable()->Purge(opt);}
87 
88  void *ReAllocate(Int_t newsize) { return GetThisTable()->ReAllocate(newsize); }
89  void *ReAllocate() { return GetThisTable()->ReAllocate(); }
90  virtual void SavePrimitive(std::ostream &out, Option_t *option="") {GetThisTable()->SavePrimitive(out,option);}
91 
92  virtual void Set(Int_t n) {GetThisTable()->Set(n);}
93  virtual void Set(Int_t n, Char_t *array) {GetThisTable()->Set(n,array);}
94  virtual void SetNRows(Int_t n) {GetThisTable()->SetNRows(n);}
95  virtual void Reset(Int_t c=0) {GetThisTable()->Reset(c) ;}
96  virtual void Update() {GetThisTable()->Update();}
97  virtual void Update(TDataSet *set, UInt_t opt=0) {GetThisTable()->Update(set,opt);}
98  void *operator[](Int_t i);
99  const void *operator[](Int_t i) const;
100 
101  ClassDef(TChair,0) // A base class to provide a user custom interface to TTable class objects
102 };
103 
104 inline void TChair::AddAt(TDataSet *dataset,Int_t idx)
105 {TDataSet::AddAt(dataset,idx);}
106 
107 inline void *TChair::operator[](Int_t i)
108 {
109 
110 // if (!GetThisTable()->BoundsOk("TChair::operator[]", i))
111 // i = 0;
112  return (void *)((char *)GetArray()+i*GetRowSize());
113 }
114 
115 inline const void *TChair::operator[](Int_t i) const
116 {
117 // if (!GetThisTable()->BoundsOk("TChair::operator[]", i))
118 // i = 0;
119  return (const void *)((char *)GetArray()+i*GetRowSize());
120 }
121 
122 // $Log: TChair.h,v $
123 // Revision 1.5 2006/07/03 16:10:46 brun
124 // from Axel:
125 // Change the signature of SavePrimitive from
126 //
127 // void SavePrimitive(std::ofstream &out, Option_t *option);
128 // to
129 // void SavePrimitive(std::ostream &out, Option_t *option = "");
130 //
131 // With this change one can do, eg
132 // myhist.SavePrimitive(std::cout);
133 //
134 // WARNING: do rm -f tree/src/*.o
135 //
136 // Revision 1.4 2005/04/25 17:23:29 brun
137 // From Valeri Fine:
138 //
139 // TChair.h:
140 // - Make the "fTable" data-member to be "protected" (it was "private")
141 // to facilitate the class reuse (thanks Y.Fisyak)
142 //
143 // TColumnView.cxx:
144 // - extra protection against of zero gPad
145 //
146 // TPad.cxx
147 // - initialize the "fPadView3D" data-member
148 // (causes the crash within "table" package occasionally)
149 //
150 // Revision 1.3 2003/01/27 20:41:36 brun
151 // New version of the Table package by Valeri Fine.
152 // New classes TIndexTable TResponseIterator TResponseTable TTableMap
153 //
154 // Revision 1.1.1.2 2002/12/02 21:57:31 fisyak
155 // *** empty log message ***
156 //
157 // Revision 1.2 2002/12/02 18:50:05 rdm
158 // mega patch to remove almost all compiler warnings on MacOS X where the
159 // compiler is by default in pedantic mode (LHCb also like to use this option).
160 // The following issues have been fixed:
161 // - removal of unused arguments
162 // - comparison between signed and unsigned integers
163 // - not calling of base class copy ctor in copy ctor's
164 // To be done, the TGeo classes where we get still many hundred warnings of
165 // the above nature. List forwarded to Andrei.
166 //
167 // Revision 1.1 2002/05/27 16:26:59 rdm
168 // rename star to table.
169 //
170 // Revision 1.9 2001/02/07 08:18:15 brun
171 //
172 // New version of the STAR classes compiling with no warnings.
173 //
174 // Revision 1.1.1.3 2001/01/22 12:59:34 fisyak
175 // *** empty log message ***
176 //
177 // Revision 1.8 2001/01/19 07:22:54 brun
178 // A few changes in the STAR classes to remove some compiler warnings.
179 //
180 // Revision 1.2 2001/01/14 01:26:54 fine
181 // New implementation TTable::SavePrimitive and AsString
182 //
183 // Revision 1.1.1.2 2000/12/18 21:05:26 fisyak
184 // *** empty log message ***
185 //
186 // Revision 1.7 2000/12/13 15:13:53 brun
187 // W A R N I N G !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
188 // ==================================================================
189 // A very long list of changes in this pre-release of version 3.00.
190 // We have modified the signature of many functions (in particular TObject)
191 // to introduce more constness in the system.
192 // You must change your code if your class derives from TObject and uses
193 // one of the modified functions such as ls, Print, Compare, Hash, etc.
194 // The modified functions in TObject have the following signature:
195 // virtual TObject *Clone() const;
196 // virtual Int_t Compare(const TObject *obj) const;
197 // virtual void Delete(Option_t *option=""); // *MENU*
198 // virtual void DrawClass() const; // *MENU*
199 // virtual void DrawClone(Option_t *option="") const; // *MENU*
200 // virtual void Dump() const; // *MENU*
201 // virtual TObject *FindObject(const TObject *obj) const;
202 // virtual char *GetObjectInfo(Int_t px, Int_t py) const;
203 // virtual ULong_t Hash() const;
204 // virtual void Inspect() const; // *MENU*
205 // virtual Bool_t IsEqual(const TObject *obj) const;
206 // virtual void ls(Option_t *option="") const;
207 // virtual void Print(Option_t *option="") const;
208 //
209 // A similar operation has been done with classes such as TH1, TVirtualPad,
210 // TTree, etc.
211 //
212 // Revision 1.6 2000/12/11 09:52:24 brun
213 // Functions ls declared const like in the base class
214 //
215 // Revision 1.5 2000/09/29 07:15:30 brun
216 // Remove unused function ReadGenericArray
217 //
218 // Revision 1.4 2000/09/05 09:21:24 brun
219 // The following headers and classes have been modified to take into account;
220 // - the new signature of IsFolder (now const)
221 // - the new TObject::FindObject
222 // - the fact that the static functions of TObject have been moved to TROOT.
223 //
224 // Revision 1.3 2000/08/09 08:41:22 brun
225 // Import new versions of the STAR classes from Valery Fine
226 //
227 // Revision 1.4 2000/08/05 19:01:59 fisyak
228 // Merge
229 //
230 // Revision 1.3 2000/06/05 21:22:01 fisyak
231 // mergre with Rene's corrections
232 //
233 // Revision 1.1.1.2 2000/06/05 12:44:33 fisyak
234 // *** empty log message ***
235 //
236 // Revision 1.2 2000/06/05 08:01:03 brun
237 // Merge with valery's version
238 //
239 // Revision 1.2 2000/06/02 14:51:37 fine
240 // new helper class to browse tables has been introduced
241 //
242 // Revision 1.1.1.1 2000/05/19 12:46:09 fisyak
243 // CVS version of root 2.24.05 without history
244 //
245 // Revision 1.1.1.1 2000/05/16 17:00:49 rdm
246 // Initial import of ROOT into CVS
247 //
248 // Revision 1.1 2000/03/09 21:57:03 fine
249 // TChair class to be moved to ROOT later
250 //
251 // Revision 1.1 2000/02/28 03:42:24 fine
252 // New base class to provide a custom interface to the TTable objects
253 //
254 
255 #endif
virtual Long_t GetNRows() const
Definition: TChair.h:64
virtual void Reset(Int_t c=0)
Definition: TChair.h:95
TChair(TTable *table)
Definition: TChair.h:42
void * ReAllocate(Int_t newsize)
Reallocate this table leaving only <newsize> allocated GetTableSize() = newsize; returns a pointer to...
Definition: TTable.cxx:1233
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)
Definition: TChair.h:70
virtual const Char_t * Print(Int_t row, Int_t rownumber=10, const Char_t *colfirst="", const Char_t *collast="") const
Definition: TChair.h:82
ULong_t fLastIndx
Definition: TChair.h:32
Int_t NaN()
Definition: TChair.h:77
virtual TH1 * Draw(TCut varexp, TCut selection, Option_t *option="", Int_t nentries=1000000000, Int_t firstentry=0)
Definition: TChair.h:56
virtual Long_t HasData() const
Definition: TTable.h:126
const char Option_t
Definition: RtypesCore.h:62
virtual void ls(Option_t *option="") const
// ls(Option_t <em>option) // // option - defines the path to be listed // = "</em>" - means print al...
Definition: TDataSet.cxx:495
virtual void Print(Option_t *opt="") const
Print TNamed name and title.
Definition: TChair.h:81
virtual void ls(Option_t *option="") const
// ls(Option_t <em>option) // // option - defines the path to be listed // = "</em>" - means print al...
Definition: TChair.h:75
virtual Bool_t IsFolder() const
return Folder flag to be used by TBrowse object The table is a folder if
Definition: TTable.cxx:1455
virtual TClass * GetRowClass() const
to be documented
Definition: TTable.cxx:1374
TChair()
Definition: TChair.h:38
virtual const Char_t * PrintHeader() const
Print general table inforamtion.
Definition: TTable.cxx:1619
virtual void AddAt(TDataSet *dataset, Int_t idx)
Add TDataSet object at the "idx" position in ds or at the end of the dataset The final result is defi...
Definition: TChair.h:104
Definition: TChair.h:27
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
virtual TTableDescriptor * GetRowDescriptors() const
Definition: TChair.h:68
const TTable * GetThisTable() const
Definition: TChair.h:36
virtual const Char_t * GetType() const
Returns the type of the wrapped C-structure kept as the TNamed title.
Definition: TTable.cxx:1443
virtual TH1 * Draw(const char *varexp, const char *selection, Option_t *option="", Int_t nentries=1000000000, Int_t firstentry=0)
Definition: TChair.h:59
virtual void Browse(TBrowser *b)
Wrap each table coulumn with TColumnView object to browse.
Definition: TTable.cxx:1293
void * fLastRow
Definition: TChair.h:33
virtual Char_t * Print(Char_t *buf, Int_t n) const
Create IDL table defintion (to be used for XDF I/O)
Definition: TTable.cxx:1547
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a primitive as a C++ statement(s) on output stream "out".
Definition: TTable.cxx:1809
#define ClassDef(name, id)
Definition: Rtypes.h:320
void * operator[](Int_t i)
Definition: TChair.h:107
virtual void SetNRows(Int_t n)
Definition: TTable.h:288
virtual Long_t GetTableSize() const
Definition: TChair.h:66
virtual void Draw(Option_t *opt)
Default Draw method for all objects.
Definition: TTable.h:308
TTable * GetThisTable()
Definition: TChair.h:35
void * ReAllocate(Int_t newsize)
Definition: TChair.h:88
virtual void Set(Int_t n, Char_t *array)
Definition: TChair.h:93
virtual void Set(Int_t n)
Set array size of TTable object to n longs. If n<0 leave array unchanged.
Definition: TTable.cxx:1951
Int_t CopyRows(const TTable *srcTable, Long_t srcRow=0, Long_t dstRow=0, Long_t nRows=0, Bool_t expand=kFALSE)
CopyRows copies nRows from starting from the srcRow of srcTable to the dstRow in this table upto nRow...
Definition: TTable.cxx:331
A specialized string object used for TTree selections.
Definition: TCut.h:25
virtual void Browse(TBrowser *b)
Browse this dataset (called by TBrowser).
Definition: TChair.h:51
const void * At(Int_t i) const
Returns a pointer to the i-th row of the table.
Definition: TTable.cxx:302
const TTable * Table() const
Definition: TChair.h:67
TTable * fTable
Definition: TChair.h:31
Using a TBrowser one can browse all ROOT objects.
Definition: TBrowser.h:37
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a primitive as a C++ statement(s) on output stream "out".
Definition: TChair.h:90
virtual TTableDescriptor * GetRowDescriptors() const
to be documented
Definition: TTable.cxx:2221
virtual Long_t HasData() const
Definition: TChair.h:73
virtual Int_t Purge(Option_t *opt="")
Purge - deletes all "dummy" "Structural Members" those are not ended up with some dataset with data i...
Definition: TChair.h:86
virtual Int_t AddAt(const void *c)
Add the "row" at the GetNRows() position, and reallocate the table if neccesary, and return the row i...
Definition: TTable.cxx:1121
virtual Long_t GetRowSize() const
Definition: TChair.h:65
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)
Fit a projected item(s) from a TTable.
Definition: TTable.cxx:1421
virtual Char_t * GetArray() const
Definition: TChair.h:62
virtual void Set(Int_t n)
Definition: TChair.h:92
virtual void ls(Int_t deep) const
// ls(Int_t depth) // // Prints the list of the this TDataSet.
Definition: TChair.h:76
unsigned int UInt_t
Definition: RtypesCore.h:42
virtual void Update()
to be documented
Definition: TTable.cxx:2376
static void * GetOffset(const void *base, ULong_t offset)
Definition: TChair.h:37
Int_t NaN()
return the total number of the NaN for float/double cells of this table Thanks Victor Perevoztchikov ...
Definition: TTable.cxx:1473
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:75
virtual void AddAt(const void *c, Int_t i)
Definition: TChair.h:49
void * GetArray() const
Definition: TTable.h:280
const Bool_t kFALSE
Definition: RtypesCore.h:88
TChair(const TChair &org)
Definition: TChair.h:43
virtual void Adopt(Int_t n, void *array)
Definition: TChair.h:47
long Long_t
Definition: RtypesCore.h:50
const void * At(Int_t i) const
Definition: TChair.h:50
virtual void AddAt(TDataSet *dataset, Int_t idx=0)
Add TDataSet object at the "idx" position in ds or at the end of the dataset The final result is defi...
Definition: TDataSet.cxx:235
virtual const Char_t * PrintHeader() const
Definition: TChair.h:85
unsigned long ULong_t
Definition: RtypesCore.h:51
virtual void CopySet(TChair &chair)
Definition: TChair.h:52
int nentries
Definition: THbookFile.cxx:89
The TH1 histogram class.
Definition: TH1.h:56
virtual void Update()
Update()
Definition: TChair.h:96
Int_t CopyRows(const TChair *srcChair, Int_t srcRow=0, Int_t dstRow=0, Int_t nRows=0, Bool_t expand=kFALSE)
Definition: TChair.h:53
virtual void Update(TDataSet *set, UInt_t opt=0)
Update this TDataSet with "set".
Definition: TChair.h:97
Definition: TTable.h:48
virtual Long_t GetTableSize() const
Returns the number of the allocated rows.
Definition: TTable.cxx:1401
#define org(otri, vertexptr)
Definition: triangle.c:1037
virtual Bool_t IsFolder() const
Returns kTRUE in case object contains browsable objects (like containers or lists of other objects)...
Definition: TChair.h:74
char Char_t
Definition: RtypesCore.h:29
virtual Char_t * MakeExpression(const Char_t *expressions[], Int_t nExpressions)
Create CINT macro to evaluate the user-provided expresssion Expression may contains: ...
Definition: TTable.cxx:2002
virtual void Draw(Option_t *opt)
Default Draw method for all objects.
Definition: TChair.h:55
virtual Long_t GetNRows() const
Returns the number of the used rows for the wrapped table.
Definition: TTable.cxx:1387
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
Definition: TRolke.cxx:630
virtual ~TChair()
Definition: TChair.h:45
virtual Long_t GetRowSize() const
Returns the size (in bytes) of one table row.
Definition: TTable.cxx:1394
virtual void SetNRows(Int_t n)
Definition: TChair.h:94
virtual Char_t * MakeExpression(const Char_t *expressions[], Int_t nExpressions)
Definition: TChair.h:78
virtual const Char_t * GetType() const
Definition: TChair.h:69
virtual TClass * GetRowClass() const
Definition: TChair.h:63
virtual Char_t * Print(Char_t *buf, Int_t n) const
Definition: TChair.h:80
virtual void Adopt(Int_t n, void *array)
Adopt array arr into TTable, i.e.
Definition: TTable.cxx:1106
const Int_t n
Definition: legend1.C:16
virtual void CopySet(TTable &array)
to be documented
Definition: TTable.cxx:1157
void * ReAllocate()
Definition: TChair.h:89
virtual void Reset(Int_t c=0)
Fill the entire table with byte "c" ; / c=0 "be default".
Definition: TTable.cxx:2071
virtual Int_t Purge(Option_t *opt="")
Shrink the table to free the unused but still allocated rows.
Definition: TTable.cxx:1800