TChair.h

Go to the documentation of this file.
00001 // @(#)root/table:$Id: TChair.h 35397 2010-09-18 05:56:29Z brun $
00002 // Author: Valery Fine(fine@bnl.gov)   13/03/2000
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOT_TChair
00013 #define ROOT_TChair
00014 
00015 //////////////////////////////////////////////////////////////////////////
00016 //                                                                      //
00017 //  TChair                                                              //
00018 //                                                                      //
00019 //  It is a base class to create a custom interface for TTable objects  //
00020 //                                                                      //
00021 //////////////////////////////////////////////////////////////////////////
00022 
00023 #include "TTable.h"
00024 
00025 class TChair : public TDataSet {
00026 
00027 protected:
00028 
00029    TTable  *fTable;     // the "TTable" object this object is pthe proxy for
00030    ULong_t  fLastIndx;  // index pof the last used  table row;
00031    void    *fLastRow;   // pointer to the last used table row; fLastRow = table[fLastIndx]
00032    
00033          TTable *GetThisTable()       {return fTable; }
00034    const TTable *GetThisTable() const {return fTable; }
00035    static void  *GetOffset(const void *base,ULong_t offset) { return (void  *)((Char_t *)base + offset);}
00036    TChair() : fTable(0), fLastIndx(0), fLastRow(0) { ; }
00037 
00038 public:
00039 
00040    TChair(TTable *table) : fTable(table),fLastIndx(0),fLastRow(0) { ; }
00041    TChair(const TChair &org) : TDataSet(org) {assert(0);}
00042 //   TChair     &operator=(const TChair &rhs){ assert(0); return rhs;}
00043    virtual    ~TChair(){;}
00044 
00045    virtual     void       Adopt(Int_t n, void *array){GetThisTable()->Adopt(n,array);}
00046    virtual     void       AddAt(TDataSet *dataset,Int_t idx);
00047    virtual     void       AddAt(const void *c, Int_t i){GetThisTable()->AddAt(c,i);}
00048               const void *At(Int_t i) const {return GetThisTable()->At(i);}
00049    virtual     void       Browse(TBrowser *b){GetThisTable()->Browse(b);}
00050    virtual     void       CopySet(TChair &chair){GetThisTable()->CopySet(*chair.GetThisTable());}
00051                Int_t      CopyRows(const TChair *srcChair, Int_t srcRow=0, Int_t dstRow=0, Int_t nRows=0, Bool_t expand=kFALSE)
00052                           {return GetThisTable()->CopyRows(srcChair->GetThisTable(),srcRow,dstRow,nRows,expand);}
00053    virtual     void       Draw(Option_t *opt){GetThisTable()->Draw(opt);}
00054    virtual     TH1       *Draw(TCut varexp, TCut selection, Option_t *option="",
00055                           Int_t nentries=1000000000, Int_t firstentry=0)
00056                           {return GetThisTable()->Draw(varexp,selection,option,nentries,firstentry);}
00057    virtual     TH1       *Draw(const char *varexp, const char *selection, Option_t *option="",
00058                                Int_t nentries=1000000000, Int_t firstentry=0) {
00059                            return GetThisTable()->Draw(varexp,selection,option,nentries,firstentry);}
00060    virtual     Char_t    *GetArray() const    {return (Char_t *)GetThisTable()->GetArray();}
00061    virtual     TClass    *GetRowClass() const {return GetThisTable()->GetRowClass();}
00062    virtual     Long_t     GetNRows() const    {return GetThisTable()->GetNRows();}
00063    virtual     Long_t     GetRowSize() const  {return GetThisTable()->GetRowSize();}
00064    virtual     Long_t     GetTableSize() const{return GetThisTable()->GetTableSize();}
00065                const TTable  *Table() const {return fTable; }
00066    virtual     TTableDescriptor *GetRowDescriptors()   const {return GetThisTable()->GetRowDescriptors();}
00067    virtual     const Char_t       *GetType()             const {return GetThisTable()->GetType();}
00068    virtual     void       Fit(const char *formula ,const char *varexp, const char *selection="",Option_t *option="",Option_t *goption="",
00069                               Int_t nentries=1000000000, Int_t firstentry=0) {
00070                            GetThisTable()->Fit(formula,varexp,selection,option,goption,nentries,firstentry);}
00071    virtual     Long_t     HasData() const  { return GetThisTable()->HasData();}
00072    virtual     Bool_t     IsFolder() const { return GetThisTable()->IsFolder();}
00073    virtual     void       ls(Option_t *option="") const {GetThisTable()->ls(option);}
00074    virtual     void       ls(Int_t deep) const  {GetThisTable()->ls(deep);}
00075                Int_t      NaN()           {return GetThisTable()->NaN();}
00076    virtual     Char_t    *MakeExpression(const Char_t *expressions[],Int_t nExpressions)
00077                          {return GetThisTable()->MakeExpression(expressions,nExpressions);}
00078    virtual     Char_t    *Print(Char_t *buf,Int_t n) const { return GetThisTable()->Print(buf, n);}
00079    virtual     void       Print(Option_t *opt="")    const {GetThisTable()->Print(opt);}
00080    virtual  const Char_t *Print(Int_t row, Int_t rownumber=10,
00081                                 const Char_t *colfirst="",const Char_t *collast="") const {
00082                            return GetThisTable()->Print(row,rownumber,colfirst,collast); }
00083    virtual  const Char_t *PrintHeader() const {return GetThisTable()->PrintHeader();}
00084    virtual  Int_t         Purge(Option_t *opt="")    {return GetThisTable()->Purge(opt);}
00085 
00086                void      *ReAllocate(Int_t newsize) { return GetThisTable()->ReAllocate(newsize); }
00087                void      *ReAllocate()              { return GetThisTable()->ReAllocate(); }
00088    virtual     void       SavePrimitive(ostream &out, Option_t *option="") {GetThisTable()->SavePrimitive(out,option);}
00089 
00090    virtual     void       Set(Int_t n)                                   {GetThisTable()->Set(n);}
00091    virtual     void       Set(Int_t n, Char_t *array)                    {GetThisTable()->Set(n,array);}
00092    virtual     void       SetNRows(Int_t n)                              {GetThisTable()->SetNRows(n);}
00093    virtual     void       Reset(Int_t c=0)                               {GetThisTable()->Reset(c) ;}
00094    virtual     void       Update()                                       {GetThisTable()->Update();}
00095    virtual     void       Update(TDataSet *set, UInt_t opt=0)            {GetThisTable()->Update(set,opt);}
00096                void      *operator[](Int_t i);
00097               const void *operator[](Int_t i) const;
00098 
00099    ClassDef(TChair,0)  // A base class to provide a user custom interface to TTable class objects
00100 };
00101 
00102 inline void  TChair::AddAt(TDataSet *dataset,Int_t idx)
00103 {TDataSet::AddAt(dataset,idx);}
00104 
00105 inline void *TChair::operator[](Int_t i)
00106 {
00107 
00108 //   if (!GetThisTable()->BoundsOk("TChair::operator[]", i))
00109 //      i = 0;
00110     return (void *)((char *)GetArray()+i*GetRowSize());
00111 }
00112 
00113 inline const void *TChair::operator[](Int_t i) const
00114 {
00115 //   if (!GetThisTable()->BoundsOk("TChair::operator[]", i))
00116 //      i = 0;
00117     return (const void *)((char *)GetArray()+i*GetRowSize());
00118 }
00119 
00120 // $Log: TChair.h,v $
00121 // Revision 1.5  2006/07/03 16:10:46  brun
00122 // from Axel:
00123 // Change the signature of SavePrimitive from
00124 //
00125 //   void SavePrimitive(ofstream &out, Option_t *option);
00126 // to
00127 //   void SavePrimitive(ostream &out, Option_t *option = "");
00128 //
00129 // With this change one can do, eg
00130 //    myhist.SavePrimitive(std::cout);
00131 //
00132 // WARNING: do rm -f tree/src/*.o
00133 //
00134 // Revision 1.4  2005/04/25 17:23:29  brun
00135 // From Valeri Fine:
00136 //
00137 //   TChair.h:
00138 //      - Make the "fTable" data-member to be "protected" (it was "private")
00139 //        to facilitate the class reuse (thanks Y.Fisyak)
00140 //
00141 //   TColumnView.cxx:
00142 //      - extra protection against of zero gPad
00143 //
00144 //   TPad.cxx
00145 //     - initialize the "fPadView3D" data-member
00146 //      (causes the crash within "table" package occasionally)
00147 //
00148 // Revision 1.3  2003/01/27 20:41:36  brun
00149 // New version of the Table package by Valeri Fine.
00150 // New classes TIndexTable TResponseIterator TResponseTable TTableMap
00151 //
00152 // Revision 1.1.1.2  2002/12/02 21:57:31  fisyak
00153 // *** empty log message ***
00154 //
00155 // Revision 1.2  2002/12/02 18:50:05  rdm
00156 // mega patch to remove almost all compiler warnings on MacOS X where the
00157 // compiler is by default in pedantic mode (LHCb also like to use this option).
00158 // The following issues have been fixed:
00159 // - removal of unused arguments
00160 // - comparison between signed and unsigned integers
00161 // - not calling of base class copy ctor in copy ctor's
00162 // To be done, the TGeo classes where we get still many hundred warnings of
00163 // the above nature. List forwarded to Andrei.
00164 //
00165 // Revision 1.1  2002/05/27 16:26:59  rdm
00166 // rename star to table.
00167 //
00168 // Revision 1.9  2001/02/07 08:18:15  brun
00169 //
00170 // New version of the STAR classes compiling with no warnings.
00171 //
00172 // Revision 1.1.1.3  2001/01/22 12:59:34  fisyak
00173 // *** empty log message ***
00174 //
00175 // Revision 1.8  2001/01/19 07:22:54  brun
00176 // A few changes in the STAR classes to remove some compiler warnings.
00177 //
00178 // Revision 1.2  2001/01/14 01:26:54  fine
00179 // New implementation TTable::SavePrimitive and AsString
00180 //
00181 // Revision 1.1.1.2  2000/12/18 21:05:26  fisyak
00182 // *** empty log message ***
00183 //
00184 // Revision 1.7  2000/12/13 15:13:53  brun
00185 //       W A R N I N G   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
00186 //      ==================================================================
00187 // A very long list of changes in this pre-release of version 3.00.
00188 // We have modified the signature of many functions (in particular TObject)
00189 // to introduce more constness in the system.
00190 // You must change your code if your class derives from TObject and uses
00191 // one of the modified functions such as ls, Print, Compare, Hash, etc.
00192 // The modified functions in TObject have the following signature:
00193 //    virtual TObject    *Clone() const;
00194 //    virtual Int_t       Compare(const TObject *obj) const;
00195 //    virtual void        Delete(Option_t *option=""); // *MENU*
00196 //    virtual void        DrawClass() const; // *MENU*
00197 //    virtual void        DrawClone(Option_t *option="") const; // *MENU*
00198 //    virtual void        Dump() const; // *MENU*
00199 //    virtual TObject    *FindObject(const TObject *obj) const;
00200 //    virtual char       *GetObjectInfo(Int_t px, Int_t py) const;
00201 //    virtual ULong_t     Hash() const;
00202 //    virtual void        Inspect() const; // *MENU*
00203 //    virtual Bool_t      IsEqual(const TObject *obj) const;
00204 //    virtual void        ls(Option_t *option="") const;
00205 //    virtual void        Print(Option_t *option="") const;
00206 //
00207 // A similar operation has been done with classes such as TH1, TVirtualPad,
00208 // TTree, etc.
00209 //
00210 // Revision 1.6  2000/12/11 09:52:24  brun
00211 // Functions ls declared const like in the base class
00212 //
00213 // Revision 1.5  2000/09/29 07:15:30  brun
00214 // Remove unused function ReadGenericArray
00215 //
00216 // Revision 1.4  2000/09/05 09:21:24  brun
00217 // The following headers and classes have been modified to take into account;
00218 //   - the new signature of IsFolder (now const)
00219 //   - the new TObject::FindObject
00220 //   - the fact that the static functions of TObject have been moved to TROOT.
00221 //
00222 // Revision 1.3  2000/08/09 08:41:22  brun
00223 // Import new versions of the STAR classes from Valery Fine
00224 //
00225 // Revision 1.4  2000/08/05 19:01:59  fisyak
00226 // Merge
00227 //
00228 // Revision 1.3  2000/06/05 21:22:01  fisyak
00229 // mergre with Rene's corrections
00230 //
00231 // Revision 1.1.1.2  2000/06/05 12:44:33  fisyak
00232 // *** empty log message ***
00233 //
00234 // Revision 1.2  2000/06/05 08:01:03  brun
00235 // Merge with valery's version
00236 //
00237 // Revision 1.2  2000/06/02 14:51:37  fine
00238 // new helper class to browse tables has been introduced
00239 //
00240 // Revision 1.1.1.1  2000/05/19 12:46:09  fisyak
00241 // CVS version of root 2.24.05 without history
00242 //
00243 // Revision 1.1.1.1  2000/05/16 17:00:49  rdm
00244 // Initial import of ROOT into CVS
00245 //
00246 // Revision 1.1  2000/03/09 21:57:03  fine
00247 // TChair class to be moved to ROOT later
00248 //
00249 // Revision 1.1  2000/02/28 03:42:24  fine
00250 // New base class to provide a custom interface to the TTable objects
00251 //
00252 
00253 #endif

Generated on Tue Jul 5 14:26:40 2011 for ROOT_528-00b_version by  doxygen 1.5.1