TSQLObjectData.h

Go to the documentation of this file.
00001 // @(#)root/sql:$Id: TSQLObjectData.h 34907 2010-08-20 17:51:15Z pcanal $
00002 // Author: Sergey Linev  20/11/2005
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2005, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOT_TSQLObjectData
00013 #define ROOT_TSQLObjectData
00014 
00015 
00016 /////////////////////////////////////////////////////////////////////////
00017 //                                                                     //
00018 // TSQLObjectData keeps data, requested from SQL server for object     //
00019 //                                                                     //
00020 /////////////////////////////////////////////////////////////////////////
00021 
00022 
00023 #ifndef ROOT_TObject
00024 #include "TObject.h"
00025 #endif
00026 
00027 #ifndef ROOT_TString
00028 #include "TString.h"
00029 #endif
00030 
00031 class TObjArray;
00032 class TList;
00033 class TSQLClassInfo;
00034 class TSQLResult;
00035 class TSQLRow;
00036 class TSQLStatement;
00037 
00038 
00039 class TSQLObjectInfo : public TObject {
00040 
00041 public:
00042 
00043    TSQLObjectInfo();
00044    TSQLObjectInfo(Long64_t objid, const char* classname, Version_t version);
00045    virtual ~TSQLObjectInfo();
00046   
00047    Long64_t          GetObjId() const { return fObjId; }
00048    const char*       GetObjClassName() const { return fClassName.Data(); }
00049    Version_t         GetObjVersion() const { return fVersion; }
00050 
00051 protected:
00052    Long64_t          fObjId;
00053    TString           fClassName;
00054    Version_t         fVersion;
00055 
00056    ClassDef(TSQLObjectInfo, 1)  //Info (classname, version) about object in database 
00057     
00058 };
00059 
00060 //=======================================================================
00061 
00062 class TSQLObjectData : public TObject {
00063 
00064 public:
00065    TSQLObjectData();
00066    
00067    TSQLObjectData(TSQLClassInfo* sqlinfo,
00068                   Long64_t       objid,
00069                   TSQLResult*    classdata,
00070                   TSQLRow*       classrow,
00071                   TSQLResult*    blobdata,
00072                   TSQLStatement* blobstmt);
00073    
00074    virtual ~TSQLObjectData();
00075    
00076    Long64_t          GetObjId() const { return fObjId; }
00077    TSQLClassInfo*    GetInfo() const { return fInfo; }
00078    
00079    Bool_t            LocateColumn(const char* colname, Bool_t isblob = kFALSE);
00080    Bool_t            IsBlobData() const { return fCurrentBlob || (fUnpack!=0); }
00081    void              ShiftToNextValue();
00082    
00083    void              AddUnpack(const char* tname, const char* value);
00084    void              AddUnpackInt(const char* tname, Int_t value);
00085    
00086    const char*       GetValue() const { return fLocatedValue; }
00087    const char*       GetLocatedField() const { return fLocatedField; }
00088    const char*       GetBlobPrefixName() const { return fBlobPrefixName; }
00089    const char*       GetBlobTypeName() const { return fBlobTypeName; }
00090    
00091    Bool_t            VerifyDataType(const char* tname, Bool_t errormsg = kTRUE);
00092    Bool_t            PrepareForRawData();
00093    
00094 protected: 
00095    Bool_t            ExtractBlobValues();
00096    Bool_t            ShiftBlobRow();
00097    
00098    Int_t             GetNumClassFields();
00099    const char*       GetClassFieldName(Int_t n);
00100    
00101    TSQLClassInfo*    fInfo;           //!
00102    Long64_t          fObjId;          //!
00103    Bool_t            fOwner;          //!
00104    TSQLResult*       fClassData;      //!
00105    TSQLResult*       fBlobData;       //!
00106    TSQLStatement*    fBlobStmt;      //!
00107    Int_t             fLocatedColumn;  //!
00108    TSQLRow*          fClassRow;       //!
00109    TSQLRow*          fBlobRow;        //!
00110    const char*       fLocatedField;   //!
00111    const char*       fLocatedValue;   //!
00112    Bool_t            fCurrentBlob;    //!
00113    const char*       fBlobPrefixName; //! name prefix in current blob row
00114    const char*       fBlobTypeName;   //! name type (without prefix) in current blob row
00115    TObjArray*        fUnpack;         //! 
00116    
00117    ClassDef(TSQLObjectData, 1) // Keeps the data requested from the SQL server for an object.
00118       
00119 };
00120 
00121 // ======================================================================
00122 
00123 class TSQLObjectDataPool : public TObject {
00124 
00125 public:
00126    TSQLObjectDataPool();
00127    TSQLObjectDataPool(TSQLClassInfo* info, TSQLResult* data);
00128    virtual ~TSQLObjectDataPool();
00129    
00130    TSQLClassInfo*    GetSqlInfo() const { return fInfo; }
00131    TSQLResult*       GetClassData() const { return fClassData; }
00132    TSQLRow*          GetObjectRow(Long64_t objid);   
00133    
00134 protected:
00135 
00136    TSQLClassInfo*    fInfo;          //!  classinfo, for which pool is created
00137    TSQLResult*       fClassData;     //!  results with request to selected table
00138    Bool_t            fIsMoreRows;    //!  indicates if class data has not yet read rows
00139    TList*            fRowsPool;      //!  pool of extrcted, but didnot used rows
00140 
00141    ClassDef(TSQLObjectDataPool,1) // XML object keeper class     
00142     
00143 };
00144 
00145 #endif

Generated on Tue Jul 5 14:28:13 2011 for ROOT_528-00b_version by  doxygen 1.5.1