TGenericTable


class description - source file - inheritance tree

class TGenericTable : public TTable

    private:
protected:
virtual TTableDescriptor* GetDescriptorPointer() const virtual void SetDescriptorPointer(TTableDescriptor* list) void SetGenericType() public:
TGenericTable TGenericTable() TGenericTable TGenericTable(const char* structName, const Text_t* name) TGenericTable TGenericTable(const char* structName, Int_t n) TGenericTable TGenericTable(const char* structName, const Text_t* name, Int_t n) TGenericTable TGenericTable(const TTableDescriptor& dsc, const Text_t* name) TGenericTable TGenericTable(const TTableDescriptor& dsc, Int_t n) TGenericTable TGenericTable(const TTableDescriptor& dsc, const Text_t* name, Int_t n) TGenericTable TGenericTable(TGenericTable&) virtual void ~TGenericTable() TGenericTable::iterator begin() const static TClass* Class() TGenericTable::iterator end() TGenericTable::iterator end() const virtual TTableDescriptor* GetRowDescriptors() const char* GetTable(Int_t i = 0) const virtual TTableDescriptor* GetTableDescriptors() const virtual TClass* IsA() const char& operator[](Int_t i) const char& operator[](Int_t i) const virtual void ShowMembers(TMemberInspector& insp, char* parent) virtual void Streamer(TBuffer& b) void StreamerNVirtual(TBuffer& b)

Data Members

    private:
protected:
TTableDescriptor* fColDescriptors public:

Class Description

                                                                      
  TGenericTable                                                       
                                                                      
  This is the class to represent the array of C-struct                
  defined at run-time                                                 
                                                                      
   Example: see $ROOTSYS/star/demo/staff.C                            
   -------                                                            
 !{
 !//   example of macro to read data from an ascii file and
 !//   create a root file with an histogram and an ntuple.
 !//   A'la the famous ROOT/PAW staff data example
 !//   ( see PAW - Long write up, CERN, page33. )
 !
 !   gROOT->Reset();
 !   gSystem->Load("libStar");
 !
 !   struct staff_t {
 !                Int_t cat;
 !                Int_t division;
 !                Int_t flag;
 !                Int_t age;
 !                Int_t service;
 !                Int_t children;
 !                Int_t grade;
 !                Int_t step;
 !                Int_t nation;
 !                Int_t hrweek;
 !                Int_t cost;
 !    };
 !
 !   staff_t staff;
 !
 !   // open ASCII data file
 !   FILE *fp = fopen("staff.dat","r");
 !
 !   char line[81];
 !
 !   // Create the generic table for 1000 rows (it may grow then)
 !   TGenericTable *allStaff = new TGenericTable("staff_t","Staff-data",1000);
 !
 !   // Fill the memory resident table
 !   while (fgets(&line,80,fp)) {
 !      sscanf(&line[0] ,"%d%d%d%d", &staff.cat,&staff.division,&staff.flag,&staff.age);
 !      sscanf(&line[13],"%d%d%d%d", &staff.service,&staff.children,&staff.grade,&staff.step);
 !      sscanf(&line[24],"%d%d%d",   &staff.nation,&staff.hrweek,&staff.cost);
 !      allStaff->AddAt(&staff);
 !   }
 !   fclose(fp);
 !   // Delete unused space;
 !   allStaff->Purge();
 !
 !   allStaff->Print(0,10);
 !
 !//  Create ROOT file
 !   TFile *f = new TFile("aptuple.root","RECREATE");
 !          allStaff->Write();
 !   f->Write();
 !
 !   // We should close  TFile otherwise all histograms we create below
 !   // may be written to the file too occasionaly
 !   f->Close();
 !
 !//  Create ROOT Browser
 !   new TBrowser("staff",allStaff);
 !
 !//  Create couple of the histograms
 !   TCanvas *canva = new TCanvas("Staff","CERN Population",600,600);
 !   canva->Divide(1,2);
 !
 !
 !// one can use 2 meta variable:
 !//  n$ - the total number of the rows in the table
 !//  i$ - stands for the current row index i = [0 -> (n$-1)]
 !
 !   gStyle->SetHistFillColor(10);
 !   gStyle->SetHistFillStyle(3013);
 !   canva->cd(1);
 !   allStaff->Draw("age");
 !   canva->Update();
 !   canva->cd(2);
 !   allStaff->Draw("cost");
 !   canva->Update();
 !}



TGenericTable(const TTableDescriptor &dsc, const Text_t *name) : TTable(name,dsc.Sizeof()),fColDescriptors(0)

   Create TGenericTable by TTableDescriptor pointer:

   dsc   - Pointer to the table descriptor
   name  - The name of this object



TGenericTable(const TTableDescriptor &dsc, Int_t n) : TTable("TGenericTable",n,dsc.Sizeof()),fColDescriptors(0)

   Create TGenericTable by TTableDescriptor pointer:

   dsc   - Pointer to the table descriptor
   name  - "TGenericTable"
   n     - The initial number of allocated rows



TGenericTable(const TTableDescriptor &dsc,const Text_t *name,Int_t n) : TTable(name,n,dsc.Sizeof()),fColDescriptors(0)

   Create TGenericTable by TTableDescriptor pointer:

   dsc   - Pointer to the table descriptor
   name  - The name of this object
   n     - The initial number of allocated rows



TGenericTable(const char *structName, const Text_t *name) : TTable(name,-1),fColDescriptors(0)

  Create TGenericTable by C structure name provided:

   dsc   - Pointer to the table descriptor
   name  - The name of this object
   n     - The initial number of allocated rows



TGenericTable(const char *structName, Int_t n) : TTable("TGenericTable",-1),fColDescriptors(0)

  Create TGenericTable by C structure name provided:

   dsc   - Pointer to the table descriptor
   name  - The name of this object
   n     - The initial number of allocated rows



TGenericTable(const char *structName, const Text_t *name,Int_t n) : TTable(name,-1),fColDescriptors(0)

   Create TGenericTable by C structure name provided:

   dsc   - Pointer to the table descriptor
   name  - The name of this object
   n     - The initial number of allocated rows



~TGenericTable()



Inline Functions


              TTableDescriptor* GetDescriptorPointer() const
                           void SetDescriptorPointer(TTableDescriptor* list)
                           void SetGenericType()
                  TGenericTable TGenericTable(const TTableDescriptor& dsc, const Text_t* name, Int_t n)
                          char* GetTable(Int_t i = 0) const
              TTableDescriptor* GetTableDescriptors() const
              TTableDescriptor* GetRowDescriptors() const
                          char& operator[](Int_t i)
                    const char& operator[](Int_t i) const
        TGenericTable::iterator begin() const
        TGenericTable::iterator end()
        TGenericTable::iterator end() const
                        TClass* Class()
                        TClass* IsA() const
                           void ShowMembers(TMemberInspector& insp, char* parent)
                           void Streamer(TBuffer& b)
                           void StreamerNVirtual(TBuffer& b)
                  TGenericTable TGenericTable(TGenericTable&)


Author: Valery Fine(fine@bnl.gov) 30/06/2001
Last update: root/star:$Name: $Id: TGenericTable.cxx,v 1.1 2001/07/11 06:46:19 brun Exp $


ROOT page - Class index - Top of the page

This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.