StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
TChair.h
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 
16 // //
17 // TChair //
18 // //
19 // It is a base class to create a custom interface for TTable objects //
20 // //
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; }
68  virtual TTableDescriptor *GetRowDescriptors() const {return GetThisTable()->GetRowDescriptors();}
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
void * ReAllocate(Int_t newsize)
Definition: TTable.cxx:1234
virtual TClass * GetRowClass() const
to be documented
Definition: TTable.cxx:1375
virtual Long_t GetRowSize() const
Returns the size (in bytes) of one table row.
Definition: TTable.cxx:1395
virtual void AddAt(TDataSet *dataset, Int_t idx)
Definition: TChair.h:104
Definition: TChair.h:27
virtual const Char_t * GetType() const
Returns the type of the wrapped C-structure kept as the TNamed title.
Definition: TTable.cxx:1444
virtual void Browse(TBrowser *b)
Wrap each table coulumn with TColumnView object to browse.
Definition: TTable.cxx:1294
virtual const Char_t * PrintHeader() const
Print general table inforamtion.
Definition: TTable.cxx:1620
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a primitive as a C++ statement(s) on output stream "out".
Definition: TTable.cxx:1810
virtual void ls(Int_t deep) const
Definition: TChair.h:76
virtual void Set(Int_t n)
Set array size of TTable object to n longs. If n<0 leave array unchanged.
Definition: TTable.cxx:1952
Int_t CopyRows(const TTable *srcTable, Long_t srcRow=0, Long_t dstRow=0, Long_t nRows=0, Bool_t expand=kFALSE)
Definition: TTable.cxx:332
virtual void Browse(TBrowser *b)
Browse this dataset (called by TBrowser).
Definition: TChair.h:51
virtual void ls(Option_t *option="") const
Definition: TChair.h:75
virtual TTableDescriptor * GetRowDescriptors() const
to be documented
Definition: TTable.cxx:2222
virtual Int_t Purge(Option_t *opt="")
Definition: TChair.h:86
virtual Long_t GetNRows() const
Returns the number of the used rows for the wrapped table.
Definition: TTable.cxx:1388
virtual void ls(Option_t *option="") const
Definition: TDataSet.cxx:495
virtual Int_t AddAt(const void *c)
Definition: TTable.cxx:1122
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: TTable.cxx:1422
virtual void Update()
to be documented
Definition: TTable.cxx:2377
Int_t NaN()
Definition: TTable.cxx:1474
virtual void AddAt(TDataSet *dataset, Int_t idx=0)
Definition: TDataSet.cxx:235
virtual void Update()
Definition: TChair.h:96
virtual void Update(TDataSet *set, UInt_t opt=0)
Definition: TChair.h:97
virtual Long_t GetTableSize() const
Returns the number of the allocated rows.
Definition: TTable.cxx:1402
Definition: TTable.h:48
virtual Char_t * MakeExpression(const Char_t *expressions[], Int_t nExpressions)
Definition: TTable.cxx:2003
const void * At(Int_t i) const
Returns a pointer to the i-th row of the table.
Definition: TTable.cxx:303
virtual Bool_t IsFolder() const
Definition: TTable.cxx:1456
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:1548
virtual void Adopt(Int_t n, void *array)
Definition: TTable.cxx:1107
virtual void CopySet(TTable &array)
to be documented
Definition: TTable.cxx:1158
virtual void Reset(Int_t c=0)
Fill the entire table with byte "c" ; / c=0 "be default"
Definition: TTable.cxx:2072
virtual Int_t Purge(Option_t *opt="")
Shrink the table to free the unused but still allocated rows.
Definition: TTable.cxx:1801