Logo ROOT   6.16/01
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
16Contains information about tables specific to one class and
17version. It provides names of table for that class. For each version of
18class not more than two tables can exists. Normal table has typically
19name like TH1_ver4 and additional table has name like TH1_raw4.
20List of this objects are kept by TSQLFile class.
21*/
22
23#include "TSQLClassInfo.h"
24
25#include "TObjArray.h"
26
28
29////////////////////////////////////////////////////////////////////////////////
30/// default constructor
31
32TSQLClassColumnInfo::TSQLClassColumnInfo() : TObject(), fName(), fSQLName(), fSQLType()
33{
34}
35
36////////////////////////////////////////////////////////////////////////////////
37/// normal constructor
38
39TSQLClassColumnInfo::TSQLClassColumnInfo(const char *name, const char *sqlname, const char *sqltype)
40 : TObject(), fName(name), fSQLName(sqlname), fSQLType(sqltype)
41{
42}
43
44////////////////////////////////////////////////////////////////////////////////
45/// destructor
46
48{
49}
50
52
53////////////////////////////////////////////////////////////////////////////////
54/// default constructor
55
57 : TObject(), fClassName(), fClassVersion(0), fClassId(0), fClassTable(), fRawTable(), fColumns(0),
58 fRawtableExist(kFALSE)
59{
60}
61
62////////////////////////////////////////////////////////////////////////////////
63/// normal constructor of TSQLClassInfo class
64/// Sets names of tables, which are used for that version of class
65
66TSQLClassInfo::TSQLClassInfo(Long64_t classid, const char *classname, Int_t version)
67 : TObject(), fClassName(classname), fClassVersion(version), fClassId(classid), fClassTable(), fRawTable(),
68 fColumns(0), fRawtableExist(kFALSE)
69{
70 fClassTable.Form("%s_ver%d", classname, version);
71 fRawTable.Form("%s_raw%d", classname, version);
72}
73
74////////////////////////////////////////////////////////////////////////////////
75/// destructor
76
78{
79 if (fColumns != 0) {
81 delete fColumns;
82 }
83}
84
85////////////////////////////////////////////////////////////////////////////////
86/// assigns new list of columns
87
89{
90 if (fColumns != 0) {
92 delete fColumns;
93 }
94 fColumns = columns;
95}
96
97////////////////////////////////////////////////////////////////////////////////
98/// set current status of class tables
99
101{
102 SetColumns(columns);
103 fRawtableExist = israwtable;
104}
105
106////////////////////////////////////////////////////////////////////////////////
107/// Search for column of that name
108///
109/// Can search either for full column name (sqlname = kFALSE, default)
110/// or for name, used as column name (sqlname = kTRUE)
111/// Return index of column in list (-1 if not found)
112
114{
115 if ((name == 0) || (fColumns == 0))
116 return -1;
117
118 TIter next(fColumns);
119
120 TSQLClassColumnInfo *col = 0;
121
122 Int_t indx = 0;
123
124 while ((col = (TSQLClassColumnInfo *)next()) != 0) {
125 const char *colname = sqlname ? col->GetSQLName() : col->GetName();
126 if (strcmp(colname, name) == 0)
127 return indx;
128 indx++;
129 }
130
131 return -1;
132}
int Int_t
Definition: RtypesCore.h:41
const Bool_t kFALSE
Definition: RtypesCore.h:88
bool Bool_t
Definition: RtypesCore.h:59
long long Long64_t
Definition: RtypesCore.h:69
#define ClassImp(name)
Definition: Rtypes.h:363
An array of TObjects.
Definition: TObjArray.h:37
virtual void Delete(Option_t *option="")
Remove all objects from the array AND delete all heap based objects.
Definition: TObjArray.cxx:355
Mother of all ROOT objects.
Definition: TObject.h:37
const char * GetSQLName() const
Definition: TSQLClassInfo.h:29
TSQLClassColumnInfo()
default constructor
virtual const char * GetName() const
Returns name of object.
Definition: TSQLClassInfo.h:28
virtual ~TSQLClassColumnInfo()
destructor
Contains information about tables specific to one class and version.
Definition: TSQLClassInfo.h:42
Int_t FindColumn(const char *name, Bool_t sqlname=kFALSE)
Search for column of that name.
TString fRawTable
! name of table with raw data
Definition: TSQLClassInfo.h:74
virtual ~TSQLClassInfo()
destructor
Bool_t fRawtableExist
! indicate that raw table is exist
Definition: TSQLClassInfo.h:76
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:75
void SetColumns(TObjArray *columns)
assigns new list of columns
TString fClassTable
! name of table with class data
Definition: TSQLClassInfo.h:73
TSQLClassInfo()
default constructor
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition: TString.cxx:2264