Logo ROOT   6.21/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 
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 
28 
29 ////////////////////////////////////////////////////////////////////////////////
30 /// normal constructor
31 
32 TSQLClassColumnInfo::TSQLClassColumnInfo(const char *name, const char *sqlname, const char *sqltype)
33  : TObject(), fName(name), fSQLName(sqlname), fSQLType(sqltype)
34 {
35 }
36 
38 
39 
40 ////////////////////////////////////////////////////////////////////////////////
41 /// normal constructor of TSQLClassInfo class
42 /// Sets names of tables, which are used for that version of class
43 
44 TSQLClassInfo::TSQLClassInfo(Long64_t classid, const char *classname, Int_t version)
45  : TObject(), fClassName(classname), fClassVersion(version), fClassId(classid)
46 {
47  fClassTable.Form("%s_ver%d", classname, version);
48  fRawTable.Form("%s_raw%d", classname, version);
49 }
50 
51 ////////////////////////////////////////////////////////////////////////////////
52 /// destructor
53 
55 {
56  SetColumns(nullptr);
57 }
58 
59 ////////////////////////////////////////////////////////////////////////////////
60 /// assigns new list of columns
61 
63 {
64  if (fColumns) {
65  fColumns->Delete();
66  delete fColumns;
67  }
68  fColumns = columns;
69 }
70 
71 ////////////////////////////////////////////////////////////////////////////////
72 /// set current status of class tables
73 
75 {
76  SetColumns(columns);
77  fRawtableExist = israwtable;
78 }
79 
80 ////////////////////////////////////////////////////////////////////////////////
81 /// Search for column of that name
82 ///
83 /// Can search either for full column name (sqlname = kFALSE, default)
84 /// or for name, used as column name (sqlname = kTRUE)
85 /// Return index of column in list (-1 if not found)
86 
88 {
89  if (!name || !fColumns)
90  return -1;
91 
92  TIter next(fColumns);
93 
94  TSQLClassColumnInfo *col = nullptr;
95 
96  Int_t indx = 0;
97 
98  while ((col = (TSQLClassColumnInfo *)next()) != nullptr) {
99  const char *colname = sqlname ? col->GetSQLName() : col->GetName();
100  if (strcmp(colname, name) == 0)
101  return indx;
102  indx++;
103  }
104 
105  return -1;
106 }
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:355
Contains information about tables specific to one class and version.
Definition: TSQLClassInfo.h:41
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
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:74
const char * GetSQLName() const
Definition: TSQLClassInfo.h:28
TString fClassTable
! name of table with class data
Definition: TSQLClassInfo.h:72
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition: TString.cxx:2289
Bool_t fRawtableExist
! indicate that raw table is exist
Definition: TSQLClassInfo.h:75
#define ClassImp(name)
Definition: Rtypes.h:365
Mother of all ROOT objects.
Definition: TObject.h:37
TString fRawTable
! name of table with raw data
Definition: TSQLClassInfo.h:73
Int_t FindColumn(const char *name, Bool_t sqlname=kFALSE)
Search for column of that name.
char name[80]
Definition: TGX11.cxx:109
const char * GetName() const final
Returns name of object.
Definition: TSQLClassInfo.h:27
void SetColumns(TObjArray *columns)
assigns new list of columns