Logo ROOT   6.10/09
Reference Guide
TSQLClassInfo.cxx
Go to the documentation of this file.
1 // @(#)root/sql:$Id$
2 // Author: Sergey Linev 20/11/2005
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2005, 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 \class TSQLClassInfo
14 \ingroup IO
15 
16 Contains information about tables specific to one class and
17 version. It provides names of table for that class. For each version of
18 class not more than two tables can exists. Normal table has typically
19 name like TH1_ver4 and additional table has name like TH1_raw4.
20 List of this objects are kept by TSQLFile class.
21 */
22 
23 #include "TSQLClassInfo.h"
24 
25 #include "TObjArray.h"
26 
27 
29 
30 ////////////////////////////////////////////////////////////////////////////////
31 /// default constructor
32 
34  TObject(),
35  fName(),
36  fSQLName(),
37  fSQLType()
38 {
39 }
40 
41 ////////////////////////////////////////////////////////////////////////////////
42 /// normal constructor
43 
45  const char* sqlname,
46  const char* sqltype) :
47  TObject(),
48  fName(name),
49  fSQLName(sqlname),
50  fSQLType(sqltype)
51 {
52 }
53 
54 ////////////////////////////////////////////////////////////////////////////////
55 /// destructor
56 
58 {
59 }
60 
61 
63 
64 ////////////////////////////////////////////////////////////////////////////////
65 /// default constructor
66 
68  TObject(),
69  fClassName(),
70  fClassVersion(0),
71  fClassId(0),
72  fClassTable(),
73  fRawTable(),
74  fColumns(0),
75  fRawtableExist(kFALSE)
76 {
77 }
78 
79 ////////////////////////////////////////////////////////////////////////////////
80 /// normal constructor of TSQLClassInfo class
81 /// Sets names of tables, which are used for that version of class
82 
84  const char* classname,
85  Int_t version) :
86  TObject(),
87  fClassName(classname),
88  fClassVersion(version),
89  fClassId(classid),
90  fClassTable(),
91  fRawTable(),
92  fColumns(0),
93  fRawtableExist(kFALSE)
94 {
95  fClassTable.Form("%s_ver%d", classname, version);
96  fRawTable.Form("%s_raw%d", classname, version);
97 }
98 
99 ////////////////////////////////////////////////////////////////////////////////
100 /// destructor
101 
103 {
104  if (fColumns!=0) {
105  fColumns->Delete();
106  delete fColumns;
107  }
108 }
109 
110 ////////////////////////////////////////////////////////////////////////////////
111 /// assigns new list of columns
112 
114 {
115  if (fColumns!=0) {
116  fColumns->Delete();
117  delete fColumns;
118  }
119  fColumns = columns;
120 }
121 
122 ////////////////////////////////////////////////////////////////////////////////
123 /// set current status of class tables
124 
126 {
127  SetColumns(columns);
128  fRawtableExist = israwtable;
129 }
130 
131 ////////////////////////////////////////////////////////////////////////////////
132 /// Search for column of that name
133 ///
134 /// Can search either for full column name (sqlname = kFALSE, default)
135 /// or for name, used as column name (sqlname = kTRUE)
136 /// Return index of column in list (-1 if not found)
137 
139 {
140  if ((name==0) || (fColumns==0)) return -1;
141 
142  TIter next(fColumns);
143 
144  TSQLClassColumnInfo* col = 0;
145 
146  Int_t indx = 0;
147 
148  while ((col = (TSQLClassColumnInfo*) next()) != 0) {
149  const char* colname = sqlname ? col->GetSQLName() : col->GetName();
150  if (strcmp(colname, name)==0) return indx;
151  indx++;
152  }
153 
154  return -1;
155 }
An array of TObjects.
Definition: TObjArray.h:37
long long Long64_t
Definition: RtypesCore.h:69
virtual ~TSQLClassInfo()
destructor
virtual void Delete(Option_t *option="")
Remove all objects from the array AND delete all heap based objects.
Definition: TObjArray.cxx:329
Contains information about tables specific to one class and version.
Definition: TSQLClassInfo.h:44
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
virtual ~TSQLClassColumnInfo()
destructor
void SetTableStatus(TObjArray *columns=0, Bool_t israwtable=kFALSE)
set current status of class tables
TObjArray * fColumns
! name and type of columns - array of TNamed
Definition: TSQLClassInfo.h:81
const char * GetSQLName() const
Definition: TSQLClassInfo.h:31
TSQLClassColumnInfo()
default constructor
TString fClassTable
! name of table with class data
Definition: TSQLClassInfo.h:79
TSQLClassInfo()
default constructor
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition: TString.cxx:2332
Bool_t fRawtableExist
! indicate that raw table is exist
Definition: TSQLClassInfo.h:82
const Bool_t kFALSE
Definition: RtypesCore.h:92
#define ClassImp(name)
Definition: Rtypes.h:336
Mother of all ROOT objects.
Definition: TObject.h:37
virtual const char * GetName() const
Returns name of object.
Definition: TSQLClassInfo.h:30
TString fRawTable
! name of table with raw data
Definition: TSQLClassInfo.h:80
Int_t FindColumn(const char *name, Bool_t sqlname=kFALSE)
Search for column of that name.
void SetColumns(TObjArray *columns)
assigns new list of columns