TTreeSQL.h

Go to the documentation of this file.
00001 // @(#)root/tree:$Id: TTreeSQL.h 30663 2009-10-11 22:11:51Z pcanal $
00002 // Author: Rene Brun   12/01/96
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, 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_TTreeSQL
00013 #define ROOT_TTreeSQL
00014 
00015 //////////////////////////////////////////////////////////////////////////
00016 //                                                                      //
00017 // TTreeSQL                                                             //
00018 //                                                                      //
00019 // A TTree object is a list of TBranch.                                 //
00020 //   To Create a TTree object one must:                                 //
00021 //    - Create the TTree header via the TTree constructor               //
00022 //    - Call the TBranch constructor for every branch.                  //
00023 //                                                                      //
00024 //   To Fill this object, use member function Fill with no parameters.  //
00025 //     The Fill function loops on all defined TBranch.                  //
00026 //                                                                      //
00027 // TTreeSQL is the TTree implementation interfacing with an SQL         //
00028 // database                                                             //
00029 //                                                                      //
00030 //////////////////////////////////////////////////////////////////////////
00031 
00032 
00033 #ifndef ROOT_TTree
00034 #include "TTree.h"
00035 #endif
00036 
00037 #include <vector>
00038 
00039 class TSQLServer;
00040 class TSQLRow;
00041 class TBasketSQL;
00042 
00043 class TTreeSQL : public TTree {
00044 
00045 protected:
00046    Int_t                  fCurrentEntry;
00047    TString                fDB;
00048    TString                fInsertQuery;   
00049    TString                fQuery;
00050    TString                fTable;
00051    TSQLResult            *fResult;
00052    TSQLRow               *fRow;
00053    TSQLServer            *fServer;
00054    Bool_t                 fBranchChecked;
00055 
00056    void                   CheckBasket(TBranch * tb);
00057    Bool_t                 CheckBranch(TBranch * tb);
00058    Bool_t                 CheckTable(const TString &table) const;
00059    TString                CreateBranches(TSQLResult * rs);
00060    std::vector<Int_t>    *GetColumnIndice(TBranch *branch);
00061    void                   Init();   
00062    void                   ResetQuery();
00063    TString                ConvertTypeName(const TString& typeName );
00064    virtual void           CreateBranch(const TString& branchName,const TString &typeName);
00065    Bool_t                 CreateTable(const TString& table);
00066    virtual TBasket       *CreateBasket(TBranch * br); 
00067 
00068    virtual TBranch *BranchImp(const char *branchname, const char *classname, TClass *ptrClass, void *addobj, Int_t bufsize, Int_t splitlevel);
00069    virtual TBranch *BranchImp(const char *branchname, TClass *ptrClass, void *addobj, Int_t bufsize, Int_t splitlevel);
00070    
00071 public:
00072    TTreeSQL(TSQLServer * server, TString DB, const TString& table);
00073 
00074    virtual Int_t          Branch(TCollection *list, Int_t bufsize=32000, Int_t splitlevel=99, const char *name="");
00075    virtual Int_t          Branch(TList *list, Int_t bufsize=32000, Int_t splitlevel=99);
00076    virtual Int_t          Branch(const char *folder, Int_t bufsize=32000, Int_t splitlevel=99);
00077    virtual TBranch       *Bronch(const char *name, const char *classname, void *addobj, Int_t bufsize=32000, Int_t splitlevel=99);
00078    virtual TBranch       *BranchOld(const char *name, const char *classname, void *addobj, Int_t bufsize=32000, Int_t splitlevel=1);
00079 #if !defined(__CINT__)
00080    virtual TBranch       *Branch(const char *name, const char *classname, void *addobj, Int_t bufsize=32000, Int_t splitlevel=99);
00081 #endif
00082 
00083    virtual TBranch       *Branch(const char *name, void *address, const char *leaflist, Int_t bufsize);
00084 
00085    virtual Int_t          Fill();
00086    virtual Int_t          GetEntry(Long64_t entry=0, Int_t getall=0);
00087    virtual Long64_t       GetEntries()    const;
00088    virtual Long64_t       GetEntries(const char *sel) { return TTree::GetEntries(sel); }
00089    virtual Long64_t       GetEntriesFast()const;
00090            TString        GetTableName(){ return fTable; }
00091    virtual Long64_t       LoadTree(Long64_t entry);
00092    virtual Long64_t       PrepEntry(Long64_t entry);
00093            void           Refresh();
00094 
00095    ClassDef(TTreeSQL,1);  // TTree Implementation read and write to a SQL database.
00096 };
00097 
00098 
00099 #endif

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