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