Logo ROOT   6.08/07
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);
84  Bool_t PrepareForRawData();
85 
86 protected:
87  Bool_t ExtractBlobValues();
88  Bool_t ShiftBlobRow();
89 
90  Int_t GetNumClassFields();
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
const char * GetValue() const
virtual ~TSQLObjectInfo()
const char * GetObjClassName() const
short Version_t
Definition: RtypesCore.h:61
TSQLStatement * fBlobStmt
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
Bool_t IsBlobData() const
TSQLClassInfo * fInfo
TSQLObjectData is used in TBufferSQL2 class in reading procedure.
const char * GetBlobTypeName() const
#define ClassDef(name, id)
Definition: Rtypes.h:254
TSQLResult * fBlobData
A doubly linked list.
Definition: TList.h:47
TSQLResult * GetClassData() const
Version_t GetObjVersion() const
TString fClassName
TObjArray * fUnpack
const char * GetBlobPrefixName() const
TSQLClassInfo * GetSqlInfo() const
const char * GetLocatedField() const
TSQLResult * fClassData
TSQLClassInfo * GetInfo() const
TList * fRowsPool
! pool of extrcted, but didnot used rows
Long64_t GetObjId() const
Mother of all ROOT objects.
Definition: TObject.h:37
Bool_t fIsMoreRows
! indicates if class data has not yet read rows
TSQLRow * fClassRow
TSQLRow * fBlobRow
Long64_t GetObjId() const
const Bool_t kTRUE
Definition: Rtypes.h:91
const Int_t n
Definition: legend1.C:16
const char * fLocatedField
const char * Data() const
Definition: TString.h:349