Logo ROOT  
Reference Guide
TSQLTableInfo.cxx
Go to the documentation of this file.
1 // @(#)root/net:$Id$
2 // Author: Sergey Linev 31/05/2006
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2006, 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 ////////////////////////////////////////////////////////////////////////////////
13 //
14 // TSQLTableInfo
15 //
16 // Contains information about table and table columns.
17 // For MySQL additional information like engine type,
18 // creation and last update time is provided
19 //
20 ////////////////////////////////////////////////////////////////////////////////
21 
22 
23 
24 #include "TSQLTableInfo.h"
25 
26 #include "TSQLColumnInfo.h"
27 #include "TList.h"
28 #include "TROOT.h"
29 #include "Riostream.h"
30 
32 
33 ////////////////////////////////////////////////////////////////////////////////
34 /// default constructor
35 
37  TNamed(),
38  fColumns(0),
39  fEngine(),
40  fCreateTime(),
41  fUpdateTime()
42 {
43 }
44 
45 ////////////////////////////////////////////////////////////////////////////////
46 /// normal constructor
47 
48 TSQLTableInfo::TSQLTableInfo(const char* tablename,
49  TList* columns,
50  const char* comment,
51  const char* engine,
52  const char* create_time,
53  const char* update_time) :
54  TNamed(tablename, comment),
55  fColumns(columns),
56  fEngine(engine),
57  fCreateTime(create_time),
58  fUpdateTime(update_time)
59 {
60 }
61 
62 ////////////////////////////////////////////////////////////////////////////////
63 /// destructor
64 
66 {
67  if (fColumns!=0) {
68  fColumns->Delete();
69  delete fColumns;
70  fColumns = 0;
71  }
72 }
73 
74 ////////////////////////////////////////////////////////////////////////////////
75 /// Prints table and table columns info
76 
78 {
80  std::cout << "Table:" << GetName();
81 
82  if ((GetTitle()!=0) && (strlen(GetTitle())!=0))
83  std::cout << " comm:'" << GetTitle() << "'";
84 
85  if (fEngine.Length()>0)
86  std::cout << " engine:" << fEngine;
87 
88  if (fCreateTime.Length()>0)
89  std::cout << " create:" << fCreateTime;
90 
91  if (fUpdateTime.Length()>0)
92  std::cout << " update:" << fUpdateTime;
93 
94  std::cout << std::endl;
95 
97  if (fColumns!=0)
98  fColumns->Print("*");
100 }
101 
102 ////////////////////////////////////////////////////////////////////////////////
103 /// Return column info object of given name
104 
106 {
107  if ((columnname==0) || (fColumns==0)) return 0;
108 
109  return dynamic_cast<TSQLColumnInfo*> (fColumns->FindObject(columnname));
110 
111 }
TSQLTableInfo::TSQLTableInfo
TSQLTableInfo()
table update time
Definition: TSQLTableInfo.cxx:36
TSQLColumnInfo
Definition: TSQLColumnInfo.h:17
TCollection::Print
virtual void Print(Option_t *option="") const
Default print for collections, calls Print(option, 1).
Definition: TCollection.cxx:476
TROOT::DecreaseDirLevel
static Int_t DecreaseDirLevel()
Decrease the indentation level for ls().
Definition: TROOT.cxx:2702
Option_t
const char Option_t
Definition: RtypesCore.h:66
TList::FindObject
virtual TObject * FindObject(const char *name) const
Find an object in this list using its name.
Definition: TList.cxx:578
TList::Delete
virtual void Delete(Option_t *option="")
Remove all objects from the list AND delete all heap based objects.
Definition: TList.cxx:470
ClassImp
#define ClassImp(name)
Definition: Rtypes.h:364
TNamed::GetTitle
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:48
TSQLTableInfo::Print
virtual void Print(Option_t *option="") const
Prints table and table columns info.
Definition: TSQLTableInfo.cxx:77
TString::Length
Ssiz_t Length() const
Definition: TString.h:410
TSQLTableInfo
Definition: TSQLTableInfo.h:20
TList.h
TSQLTableInfo::fEngine
TString fEngine
list of TSQLColumnInfo objects, describing each table column
Definition: TSQLTableInfo.h:24
TSQLTableInfo::~TSQLTableInfo
virtual ~TSQLTableInfo()
destructor
Definition: TSQLTableInfo.cxx:65
TROOT.h
TSQLTableInfo::fUpdateTime
TString fUpdateTime
table creation time
Definition: TSQLTableInfo.h:26
TNamed
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
TROOT::IncreaseDirLevel
static Int_t IncreaseDirLevel()
Increase the indentation level for ls().
Definition: TROOT.cxx:2798
TROOT::IndentLevel
static void IndentLevel()
Functions used by ls() to indent an object hierarchy.
Definition: TROOT.cxx:2806
TSQLColumnInfo.h
TSQLTableInfo.h
TSQLTableInfo::fCreateTime
TString fCreateTime
SQL tables engine name.
Definition: TSQLTableInfo.h:25
TSQLTableInfo::fColumns
TList * fColumns
Definition: TSQLTableInfo.h:23
TSQLTableInfo::FindColumn
TSQLColumnInfo * FindColumn(const char *columnname)
Return column info object of given name.
Definition: TSQLTableInfo.cxx:105
ROOT::TMetaUtils::propNames::comment
static const std::string comment("comment")
TNamed::GetName
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
Riostream.h
TList
A doubly linked list.
Definition: TList.h:44