TSQLTableInfo.cxx

Go to the documentation of this file.
00001 // @(#)root/net:$Id: TSQLTableInfo.cxx 23091 2008-04-09 15:04:27Z rdm $
00002 // Author: Sergey Linev   31/05/2006
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2006, 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 // TSQLTableInfo
00015 //
00016 // Contains information about table and table columns.
00017 // For MySQL additional information like engine type, 
00018 // creation and last update time is provided
00019 //                                                                      
00020 ////////////////////////////////////////////////////////////////////////////////
00021 
00022 
00023 
00024 #include "TSQLTableInfo.h"
00025 
00026 #include "TSQLColumnInfo.h"
00027 #include "TList.h"
00028 #include "TROOT.h"
00029 #include "Riostream.h"
00030 
00031 ClassImp(TSQLTableInfo)
00032 
00033 //______________________________________________________________________________
00034 TSQLTableInfo::TSQLTableInfo() : 
00035    TNamed(),
00036    fColumns(0),
00037    fEngine(),
00038    fCreateTime(),
00039    fUpdateTime()
00040 {
00041    // default constructor
00042 }
00043 
00044 //______________________________________________________________________________
00045 TSQLTableInfo::TSQLTableInfo(const char* tablename, 
00046                              TList* columns,
00047                              const char* comment,
00048                              const char* engine,
00049                              const char* create_time,
00050                              const char* update_time) : 
00051    TNamed(tablename, comment),
00052    fColumns(columns),
00053    fEngine(engine),
00054    fCreateTime(create_time),
00055    fUpdateTime(update_time)
00056 {
00057    // normal constructor
00058    
00059 }
00060 
00061 //______________________________________________________________________________
00062 TSQLTableInfo::~TSQLTableInfo()
00063 {
00064    // destructor
00065    
00066    if (fColumns!=0) {
00067       fColumns->Delete();
00068       delete fColumns;
00069       fColumns = 0;
00070    }
00071 }
00072 
00073 //______________________________________________________________________________
00074 void TSQLTableInfo::Print(Option_t*) const
00075 {
00076    // Prints table and table columns info
00077    
00078    TROOT::IndentLevel();
00079    cout << "Table:" << GetName();
00080    
00081    if ((GetTitle()!=0) && (strlen(GetTitle())!=0))
00082       cout << " comm:'" << GetTitle() << "'";
00083    
00084    if (fEngine.Length()>0)
00085       cout << " engine:" << fEngine;
00086 
00087    if (fCreateTime.Length()>0)
00088       cout << " create:" << fCreateTime;
00089 
00090    if (fUpdateTime.Length()>0)
00091       cout << " update:" << fUpdateTime;
00092    
00093    cout << endl;
00094     
00095    TROOT::IncreaseDirLevel();
00096    if (fColumns!=0)
00097       fColumns->Print("*");
00098    TROOT::DecreaseDirLevel();
00099 }
00100 
00101 //______________________________________________________________________________
00102 TSQLColumnInfo* TSQLTableInfo::FindColumn(const char* columnname)
00103 {
00104    // Return column info object of given name
00105    
00106    if ((columnname==0) || (fColumns==0)) return 0;
00107    
00108    return dynamic_cast<TSQLColumnInfo*> (fColumns->FindObject(columnname));
00109    
00110 }

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