TSQLClassInfo.cxx

Go to the documentation of this file.
00001 // @(#)root/sql:$Id: TSQLClassInfo.cxx 20882 2007-11-19 11:31:26Z rdm $
00002 // Author: Sergey Linev  20/11/2005
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2005, 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 //________________________________________________________________________
00013 // 
00014 // TSQLClassInfo class containes info about tables specific to one class and
00015 // version. It provides names of table for that class. For each version of 
00016 // class not more than two tables can exists. Normal table has typically
00017 // name like TH1_ver4 and additional table has name like TH1_raw4
00018 // List of this objects are kept by TSQLFile class
00019 //
00020 //________________________________________________________________________
00021 
00022 #include "TSQLClassInfo.h"
00023 
00024 #include "TObjArray.h"
00025 
00026 
00027 ClassImp(TSQLClassColumnInfo)
00028 
00029 //______________________________________________________________________________
00030 TSQLClassColumnInfo::TSQLClassColumnInfo() :
00031    TObject(),
00032    fName(),
00033    fSQLName(),
00034    fSQLType()
00035 {
00036    // default constructor 
00037 }
00038 
00039 //______________________________________________________________________________
00040 TSQLClassColumnInfo::TSQLClassColumnInfo(const char* name,
00041                                          const char* sqlname,
00042                                          const char* sqltype) :
00043    TObject(),
00044    fName(name),
00045    fSQLName(sqlname),
00046    fSQLType(sqltype)
00047 {
00048    // normal constructor 
00049 }
00050                      
00051 //______________________________________________________________________________
00052 TSQLClassColumnInfo::~TSQLClassColumnInfo()
00053 {
00054    // destructor
00055 }
00056 
00057 
00058 ClassImp(TSQLClassInfo)
00059 
00060 //______________________________________________________________________________
00061 TSQLClassInfo::TSQLClassInfo() :
00062    TObject(),
00063    fClassName(),
00064    fClassVersion(0),
00065    fClassId(0),
00066    fClassTable(),
00067    fRawTable(),
00068    fColumns(0),
00069    fRawtableExist(kFALSE)
00070 {
00071 // default constructor
00072 }
00073 
00074 //______________________________________________________________________________
00075 TSQLClassInfo::TSQLClassInfo(Long64_t classid,
00076                              const char* classname, 
00077                              Int_t version) : 
00078    TObject(),
00079    fClassName(classname),
00080    fClassVersion(version),
00081    fClassId(classid),
00082    fClassTable(),
00083    fRawTable(),
00084    fColumns(0),
00085    fRawtableExist(kFALSE)
00086 {
00087    // normal constructor of TSQLClassInfo class
00088    // Sets names of tables, which are used for that version of class    
00089    fClassTable.Form("%s_ver%d", classname, version);
00090    fRawTable.Form("%s_raw%d", classname, version);
00091 }
00092    
00093 //______________________________________________________________________________
00094 TSQLClassInfo::~TSQLClassInfo()
00095 {
00096 // destructor
00097 
00098    if (fColumns!=0) {
00099       fColumns->Delete();  
00100       delete fColumns; 
00101    }
00102 }
00103 
00104 //______________________________________________________________________________
00105 void TSQLClassInfo::SetColumns(TObjArray* columns)
00106 {
00107 // assigns new list of columns
00108     
00109    if (fColumns!=0) {
00110       fColumns->Delete();  
00111       delete fColumns; 
00112    }
00113    fColumns = columns;
00114 }
00115 
00116 //______________________________________________________________________________
00117 void TSQLClassInfo::SetTableStatus(TObjArray* columns, Bool_t israwtable)
00118 {
00119 // set current status of class tables
00120     
00121    SetColumns(columns); 
00122    fRawtableExist = israwtable;
00123 }
00124 
00125 //______________________________________________________________________________
00126 Int_t TSQLClassInfo::FindColumn(const char* name, Bool_t sqlname)
00127 {
00128    // Search for column of that name
00129    // Can search either for full column name (sqlname = kFALSE, default)
00130    // or for name, used as column name (sqlname = kTRUE)
00131    // Return index of column in list (-1 if not found)
00132 
00133    if ((name==0) || (fColumns==0)) return -1;
00134    
00135    TIter next(fColumns);
00136 
00137    TSQLClassColumnInfo* col = 0;
00138    
00139    Int_t indx = 0;
00140    
00141    while ((col = (TSQLClassColumnInfo*) next()) != 0) {
00142       const char* colname = sqlname ? col->GetSQLName() : col->GetName();
00143       if (strcmp(colname, name)==0) return indx;
00144       indx++;
00145    }
00146    
00147    return -1;
00148 }

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