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