Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
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:
29  TSQLObjectInfo();
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:
38  Long64_t fObjId;
39  TString fClassName;
40  Version_t fVersion;
41 
42  ClassDef(TSQLObjectInfo, 1) // Info (classname, version) about object in database
43 };
44 
45 //=======================================================================
46 
47 class TSQLObjectData : public TObject {
48 
49 public:
50  TSQLObjectData();
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 
82  TSQLClassInfo *fInfo; //!
83  Long64_t fObjId; //!
84  Bool_t fOwner; //!
85  TSQLResult *fClassData; //!
86  TSQLResult *fBlobData; //!
87  TSQLStatement *fBlobStmt; //!
88  Int_t fLocatedColumn; //!
89  TSQLRow *fClassRow; //!
90  TSQLRow *fBlobRow; //!
91  const char *fLocatedField; //!
92  const char *fLocatedValue; //!
93  Bool_t fCurrentBlob; //!
94  const char *fBlobPrefixName; ///<! name prefix in current blob row
95  const char *fBlobTypeName; ///<! name type (without prefix) in current blob row
96  TObjArray *fUnpack; //!
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:
111  TSQLObjectDataPool();
112  TSQLObjectDataPool(TSQLClassInfo *info, TSQLResult *data);
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