Logo ROOT   6.12/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 #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);
73  Bool_t PrepareForRawData();
74 
75 protected:
76  Bool_t ExtractBlobValues();
77  Bool_t ShiftBlobRow();
78 
79  Int_t GetNumClassFields();
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 extrcted, but didnot used rows
124 
125  ClassDef(TSQLObjectDataPool, 1) // XML object keeper class
126 };
127 
128 #endif
Version_t fVersion
const char * fBlobPrefixName
! name prefix in current blob row
XML object keeper class.
An array of TObjects.
Definition: TObjArray.h:37
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:42
Basic string class.
Definition: TString.h:125
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
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:320
TSQLResult * fBlobData
A doubly linked list.
Definition: TList.h:44
TSQLResult * GetClassData() const
Version_t GetObjVersion() const
TString fClassName
TObjArray * fUnpack
const char * GetBlobPrefixName() const
TSQLClassInfo * GetSqlInfo() const
const char * GetLocatedField() const
const Bool_t kFALSE
Definition: RtypesCore.h:88
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: RtypesCore.h:87
const Int_t n
Definition: legend1.C:16
const char * fLocatedField
const char * Data() const
Definition: TString.h:345