Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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/// normal constructor
31
32TSQLClassColumnInfo::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
44TSQLClassInfo::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) {
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}
long long Long64_t
Definition RtypesCore.h:69
#define ClassImp(name)
Definition Rtypes.h:382
char name[80]
Definition TGX11.cxx:110
An array of TObjects.
Definition TObjArray.h:31
void Delete(Option_t *option="") override
Remove all objects from the array AND delete all heap based objects.
Mother of all ROOT objects.
Definition TObject.h:41
const char * GetSQLName() const
const char * GetName() const final
Returns name of object.
Contains information about tables specific to one class and version.
Int_t FindColumn(const char *name, Bool_t sqlname=kFALSE)
Search for column of that name.
void SetTableStatus(TObjArray *columns=nullptr, Bool_t israwtable=kFALSE)
set current status of class tables
TString fRawTable
! name of table with raw data
~TSQLClassInfo() override
destructor
Bool_t fRawtableExist
! indicate that raw table is exist
TObjArray * fColumns
! name and type of columns - array of TNamed
void SetColumns(TObjArray *columns)
assigns new list of columns
TString fClassTable
! name of table with class data
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition TString.cxx:2356