Logo ROOT  
Reference Guide
TSQLObjectData.h
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 #ifndef ROOT_TSQLObjectData
13 #define ROOT_TSQLObjectData
14 
15 #include "TObject.h"
16 
17 #include "TString.h"
18 
19 class TObjArray;
20 class TList;
21 class TSQLClassInfo;
22 class TSQLResult;
23 class TSQLRow;
24 class TSQLStatement;
25 
26 class TSQLObjectInfo : public TObject {
27 
28 public:
30  TSQLObjectInfo(Long64_t objid, const char *classname, Version_t version);
31  virtual ~TSQLObjectInfo();
32 
33  Long64_t GetObjId() const { return fObjId; }
34  const char *GetObjClassName() const { return fClassName.Data(); }
35  Version_t GetObjVersion() const { return fVersion; }
36 
37 protected:
41 
42  ClassDef(TSQLObjectInfo, 1) // Info (classname, version) about object in database
43 };
44 
45 //=======================================================================
46 
47 class TSQLObjectData : public TObject {
48 
49 public:
51 
52  TSQLObjectData(TSQLClassInfo *sqlinfo, Long64_t objid, TSQLResult *classdata, TSQLRow *classrow,
53  TSQLResult *blobdata, TSQLStatement *blobstmt);
54 
55  virtual ~TSQLObjectData();
56 
57  Long64_t GetObjId() const { return fObjId; }
58  TSQLClassInfo *GetInfo() const { return fInfo; }
59 
60  Bool_t LocateColumn(const char *colname, Bool_t isblob = kFALSE);
61  Bool_t IsBlobData() const { return fCurrentBlob || (fUnpack != 0); }
62  void ShiftToNextValue();
63 
64  void AddUnpack(const char *tname, const char *value);
65  void AddUnpackInt(const char *tname, Int_t value);
66 
67  const char *GetValue() const { return fLocatedValue; }
68  const char *GetLocatedField() const { return fLocatedField; }
69  const char *GetBlobPrefixName() const { return fBlobPrefixName; }
70  const char *GetBlobTypeName() const { return fBlobTypeName; }
71 
72  Bool_t VerifyDataType(const char *tname, Bool_t errormsg = kTRUE);
74 
75 protected:
78 
80  const char *GetClassFieldName(Int_t n);
81 
91  const char *fLocatedField; //!
92  const char *fLocatedValue; //!
94  const char *fBlobPrefixName; ///<! name prefix in current blob row
95  const char *fBlobTypeName; ///<! name type (without prefix) in current blob row
97 
98  ClassDef(TSQLObjectData, 1) // Keeps the data requested from the SQL server for an object.
99 };
100 
101 // ======================================================================
102 /**
103 \class TSQLObjectDataPool
104 \ingroup IO
105 XML object keeper class
106 */
107 
108 class TSQLObjectDataPool : public TObject {
109 
110 public:
113  virtual ~TSQLObjectDataPool();
114 
115  TSQLClassInfo *GetSqlInfo() const { return fInfo; }
116  TSQLResult *GetClassData() const { return fClassData; }
117  TSQLRow *GetObjectRow(Long64_t objid);
118 
119 protected:
120  TSQLClassInfo *fInfo; ///<! classinfo, for which pool is created
121  TSQLResult *fClassData; ///<! results with request to selected table
122  Bool_t fIsMoreRows; ///<! indicates if class data has not yet read rows
123  TList *fRowsPool; ///<! pool of extracted, but didnot used rows
124 
125  ClassDef(TSQLObjectDataPool, 1) // XML object keeper class
126 };
127 
128 #endif
TSQLObjectDataPool::fIsMoreRows
Bool_t fIsMoreRows
! indicates if class data has not yet read rows
Definition: TSQLObjectData.h:122
TSQLObjectData::fClassData
TSQLResult * fClassData
Definition: TSQLObjectData.h:85
TSQLObjectDataPool::~TSQLObjectDataPool
virtual ~TSQLObjectDataPool()
Destructor of TSQLObjectDataPool class Deletes not used rows and class data table.
Definition: TSQLObjectData.cxx:405
TSQLObjectDataPool::TSQLObjectDataPool
TSQLObjectDataPool()
Definition: TSQLObjectData.cxx:390
n
const Int_t n
Definition: legend1.C:16
TSQLObjectData::ShiftBlobRow
Bool_t ShiftBlobRow()
shift cursor to next blob value
Definition: TSQLObjectData.cxx:196
TSQLObjectDataPool::GetClassData
TSQLResult * GetClassData() const
Definition: TSQLObjectData.h:116
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
Version_t
short Version_t
Definition: RtypesCore.h:65
TObjArray
An array of TObjects.
Definition: TObjArray.h:37
TSQLObjectData::fOwner
Bool_t fOwner
Definition: TSQLObjectData.h:84
TSQLObjectDataPool::GetSqlInfo
TSQLClassInfo * GetSqlInfo() const
Definition: TSQLObjectData.h:115
TSQLObjectData::fBlobRow
TSQLRow * fBlobRow
Definition: TSQLObjectData.h:90
TSQLObjectData::LocateColumn
Bool_t LocateColumn(const char *colname, Bool_t isblob=kFALSE)
locate column of that name in results
Definition: TSQLObjectData.cxx:142
TSQLClassInfo
Contains information about tables specific to one class and version.
Definition: TSQLClassInfo.h:41
TSQLObjectInfo::TSQLObjectInfo
TSQLObjectInfo()
Definition: TSQLObjectData.cxx:45
TString::Data
const char * Data() const
Definition: TString.h:369
TSQLObjectData::fBlobPrefixName
const char * fBlobPrefixName
! name prefix in current blob row
Definition: TSQLObjectData.h:94
Long64_t
long long Long64_t
Definition: RtypesCore.h:73
TSQLObjectData::fClassRow
TSQLRow * fClassRow
Definition: TSQLObjectData.h:89
TSQLObjectData::fCurrentBlob
Bool_t fCurrentBlob
Definition: TSQLObjectData.h:93
TSQLObjectData::IsBlobData
Bool_t IsBlobData() const
Definition: TSQLObjectData.h:61
TSQLObjectData::VerifyDataType
Bool_t VerifyDataType(const char *tname, Bool_t errormsg=kTRUE)
checks if data type corresponds to that stored in raw table
Definition: TSQLObjectData.cxx:330
Int_t
int Int_t
Definition: RtypesCore.h:45
TSQLObjectDataPool
XML object keeper class.
Definition: TSQLObjectData.h:108
TSQLObjectDataPool::fRowsPool
TList * fRowsPool
! pool of extracted, but didnot used rows
Definition: TSQLObjectData.h:123
TSQLObjectDataPool::fClassData
TSQLResult * fClassData
! results with request to selected table
Definition: TSQLObjectData.h:121
TString
Basic string class.
Definition: TString.h:136
Bool_t
bool Bool_t
Definition: RtypesCore.h:63
TSQLObjectData::GetObjId
Long64_t GetObjId() const
Definition: TSQLObjectData.h:57
TString.h
TSQLObjectInfo::fVersion
Version_t fVersion
Definition: TSQLObjectData.h:40
bool
TSQLResult
Definition: TSQLResult.h:32
TSQLObjectData::ShiftToNextValue
void ShiftToNextValue()
shift to next column or next row in blob data
Definition: TSQLObjectData.cxx:289
TSQLObjectData::GetBlobPrefixName
const char * GetBlobPrefixName() const
Definition: TSQLObjectData.h:69
TSQLObjectInfo::GetObjClassName
const char * GetObjClassName() const
Definition: TSQLObjectData.h:34
TSQLObjectInfo::GetObjId
Long64_t GetObjId() const
Definition: TSQLObjectData.h:33
TSQLObjectData::AddUnpack
void AddUnpack(const char *tname, const char *value)
add emulated data this used to place version or TObject raw data, read from normal tables
Definition: TSQLObjectData.cxx:263
TSQLObjectData::fLocatedColumn
Int_t fLocatedColumn
Definition: TSQLObjectData.h:88
TSQLObjectData::AddUnpackInt
void AddUnpackInt(const char *tname, Int_t value)
emulate integer value in raw data
Definition: TSQLObjectData.cxx:279
TSQLObjectData::GetInfo
TSQLClassInfo * GetInfo() const
Definition: TSQLObjectData.h:58
TSQLObjectData::fObjId
Long64_t fObjId
Definition: TSQLObjectData.h:83
TSQLObjectData::GetLocatedField
const char * GetLocatedField() const
Definition: TSQLObjectData.h:68
TSQLObjectData::~TSQLObjectData
virtual ~TSQLObjectData()
destructor of TSQLObjectData object
Definition: TSQLObjectData.cxx:101
TSQLObjectData::fBlobStmt
TSQLStatement * fBlobStmt
Definition: TSQLObjectData.h:87
TSQLObjectInfo
Info (classname, version) about object in database.
Definition: TSQLObjectData.h:26
TSQLObjectData::fLocatedField
const char * fLocatedField
Definition: TSQLObjectData.h:91
TSQLObjectDataPool::fInfo
TSQLClassInfo * fInfo
! classinfo, for which pool is created
Definition: TSQLObjectData.h:120
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
TSQLRow
Definition: TSQLRow.h:30
TSQLObjectData::ExtractBlobValues
Bool_t ExtractBlobValues()
extract from curent blob row value and names identifiers
Definition: TSQLObjectData.cxx:215
TSQLObjectData::PrepareForRawData
Bool_t PrepareForRawData()
prepare to read data from raw table
Definition: TSQLObjectData.cxx:364
TSQLObjectInfo::fClassName
TString fClassName
Definition: TSQLObjectData.h:39
TSQLObjectInfo::fObjId
Long64_t fObjId
Definition: TSQLObjectData.h:38
TSQLObjectData::GetValue
const char * GetValue() const
Definition: TSQLObjectData.h:67
TSQLObjectData::fInfo
TSQLClassInfo * fInfo
Definition: TSQLObjectData.h:82
TSQLObjectData
TSQLObjectData is used in TBufferSQL2 class in reading procedure.
Definition: TSQLObjectData.h:47
TObject.h
TSQLObjectData::GetClassFieldName
const char * GetClassFieldName(Int_t n)
get name of class table column
Definition: TSQLObjectData.cxx:132
TSQLStatement
Definition: TSQLStatement.h:21
TObject
Mother of all ROOT objects.
Definition: TObject.h:37
TSQLObjectData::fUnpack
TObjArray * fUnpack
Definition: TSQLObjectData.h:96
TSQLObjectData::TSQLObjectData
TSQLObjectData()
default contrsuctor
Definition: TSQLObjectData.cxx:73
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TSQLObjectDataPool::GetObjectRow
TSQLRow * GetObjectRow(Long64_t objid)
Returns single sql row with object data for that class.
Definition: TSQLObjectData.cxx:418
TSQLObjectData::fBlobTypeName
const char * fBlobTypeName
! name type (without prefix) in current blob row
Definition: TSQLObjectData.h:95
TSQLObjectData::GetNumClassFields
Int_t GetNumClassFields()
return number of columns in class table result
Definition: TSQLObjectData.cxx:122
TSQLObjectData::GetBlobTypeName
const char * GetBlobTypeName() const
Definition: TSQLObjectData.h:70
TSQLObjectInfo::GetObjVersion
Version_t GetObjVersion() const
Definition: TSQLObjectData.h:35
TSQLObjectInfo::~TSQLObjectInfo
virtual ~TSQLObjectInfo()
Definition: TSQLObjectData.cxx:58
TSQLObjectData::fBlobData
TSQLResult * fBlobData
Definition: TSQLObjectData.h:86
TSQLObjectData::fLocatedValue
const char * fLocatedValue
Definition: TSQLObjectData.h:92
TList
A doubly linked list.
Definition: TList.h:44
int