Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:12:31

0001 // @(#)root/tree:$Id$
0002 // Author: Rene Brun   12/01/96
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_TTreeSQL
0013 #define ROOT_TTreeSQL
0014 
0015 //////////////////////////////////////////////////////////////////////////
0016 //                                                                      //
0017 // TTreeSQL                                                             //
0018 //                                                                      //
0019 // A TTree object is a list of TBranch.                                 //
0020 //   To Create a TTree object one must:                                 //
0021 //    - Create the TTree header via the TTree constructor               //
0022 //    - Call the TBranch constructor for every branch.                  //
0023 //                                                                      //
0024 //   To Fill this object, use member function Fill with no parameters.  //
0025 //     The Fill function loops on all defined TBranch.                  //
0026 //                                                                      //
0027 // TTreeSQL is the TTree implementation interfacing with an SQL         //
0028 // database                                                             //
0029 //                                                                      //
0030 //////////////////////////////////////////////////////////////////////////
0031 
0032 
0033 #include "TTree.h"
0034 
0035 #include <vector>
0036 
0037 class TSQLServer;
0038 class TSQLRow;
0039 class TBasketSQL;
0040 class TSQLTableInfo;
0041 
0042 class TTreeSQL : public TTree {
0043 
0044 protected:
0045    Int_t                  fCurrentEntry;
0046    TString                fDB;
0047    TString                fInsertQuery;
0048    TString                fQuery;
0049    TString                fTable;
0050    TSQLResult            *fResult;
0051    TSQLRow               *fRow;
0052    TSQLServer            *fServer;
0053    bool                   fBranchChecked;
0054    TSQLTableInfo         *fTableInfo;
0055 
0056    void                   CheckBasket(TBranch *tb);
0057    bool                   CheckBranch(TBranch *tb);
0058    bool                   CheckTable(const TString &table) const;
0059    void                   CreateBranches();
0060    std::vector<Int_t>    *GetColumnIndice(TBranch *branch);
0061    void                   Init();
0062    void                   ResetQuery();
0063    TString                ConvertTypeName(const TString& typeName );
0064    virtual void           CreateBranch(const TString& branchName,const TString &typeName);
0065    bool                   CreateTable(const TString& table);
0066    TBasket               *CreateBasket(TBranch * br) override;
0067 
0068    TBranch               *BranchImp(const char *branchname, const char *classname, TClass *ptrClass, void *addobj, Int_t bufsize, Int_t splitlevel) override;
0069    TBranch               *BranchImp(const char *branchname, TClass *ptrClass, void *addobj, Int_t bufsize, Int_t splitlevel) override;
0070 
0071 public:
0072    TTreeSQL(TSQLServer * server, TString DB, const TString& table);
0073    ~TTreeSQL() override;
0074 
0075    Int_t                  Branch(TCollection *list, Int_t bufsize=32000, Int_t splitlevel=99, const char *name="") override;
0076    Int_t                  Branch(TList *list, Int_t bufsize=32000, Int_t splitlevel=99) override;
0077    Int_t                  Branch(const char *folder, Int_t bufsize=32000, Int_t splitlevel=99) override;
0078    TBranch               *Bronch(const char *name, const char *classname, void *addobj, Int_t bufsize=32000, Int_t splitlevel=99) override;
0079    TBranch               *BranchOld(const char *name, const char *classname, void *addobj, Int_t bufsize=32000, Int_t splitlevel=1) override;
0080    TBranch               *Branch(const char *name, const char *classname, void *addobj, Int_t bufsize=32000, Int_t splitlevel=99) override;
0081 
0082    TBranch               *Branch(const char *name, void *address, const char *leaflist, Int_t bufsize) override;
0083 
0084    Int_t          Fill() override;
0085    Int_t          GetEntry(Long64_t entry=0, Int_t getall=0) override;
0086    Long64_t       GetEntries() const override;
0087    Long64_t               GetEntries(const char *sel) override { return TTree::GetEntries(sel); }
0088    Long64_t               GetEntriesFast()const override;
0089    TString                GetTableName(){ return fTable; }
0090    Long64_t       LoadTree(Long64_t entry) override;
0091    virtual Long64_t       PrepEntry(Long64_t entry);
0092    void                   Refresh() override;
0093 
0094    ClassDefOverride(TTreeSQL,2);  // TTree Implementation read and write to a SQL database.
0095 };
0096 
0097 
0098 #endif