| 1 | // @(#)root/tree:$Id: MTreeSQL.h 30663 2009-10-11 22:11:51Z pcanal $
|
|---|
| 2 | // Author: Rene Brun 12/01/96
|
|---|
| 3 |
|
|---|
| 4 | /*************************************************************************
|
|---|
| 5 | * Copyright (C) 1995-2000, 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_MTreeSQL
|
|---|
| 13 | #define ROOT_MTreeSQL
|
|---|
| 14 |
|
|---|
| 15 | //////////////////////////////////////////////////////////////////////////
|
|---|
| 16 | // //
|
|---|
| 17 | // MTreeSQL //
|
|---|
| 18 | // //
|
|---|
| 19 | // A TTree object is a list of TBranch. //
|
|---|
| 20 | // To Create a TTree object one must: //
|
|---|
| 21 | // - Create the TTree header via the TTree constructor //
|
|---|
| 22 | // - Call the TBranch constructor for every branch. //
|
|---|
| 23 | // //
|
|---|
| 24 | // To Fill this object, use member function Fill with no parameters. //
|
|---|
| 25 | // The Fill function loops on all defined TBranch. //
|
|---|
| 26 | // //
|
|---|
| 27 | // MTreeSQL is the TTree implementation interfacing with an SQL //
|
|---|
| 28 | // database //
|
|---|
| 29 | // //
|
|---|
| 30 | //////////////////////////////////////////////////////////////////////////
|
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 | #ifndef ROOT_TTree
|
|---|
| 34 | #include "TTree.h"
|
|---|
| 35 | #endif
|
|---|
| 36 |
|
|---|
| 37 | #include <vector>
|
|---|
| 38 |
|
|---|
| 39 | class MSQLServer;
|
|---|
| 40 | class TSQLRow;
|
|---|
| 41 |
|
|---|
| 42 | class MTreeSQL : public TTree
|
|---|
| 43 | {
|
|---|
| 44 | protected:
|
|---|
| 45 | MSQLServer *fServer;
|
|---|
| 46 |
|
|---|
| 47 | TString fQuery;
|
|---|
| 48 |
|
|---|
| 49 | TSQLResult *fResult;
|
|---|
| 50 | TSQLRow *fRow;
|
|---|
| 51 |
|
|---|
| 52 | std::vector<TString> fTables;
|
|---|
| 53 | std::vector<TSQLRow*> fRows;
|
|---|
| 54 |
|
|---|
| 55 | Bool_t CheckTable(const TString &table) const;
|
|---|
| 56 | void Init();
|
|---|
| 57 |
|
|---|
| 58 | virtual TBranch *BranchImp(const char *branchname, const char *classname, TClass *ptrClass, void *addobj, Int_t bufsize, Int_t splitlevel);
|
|---|
| 59 | virtual TBranch *BranchImp(const char *branchname, TClass *ptrClass, void *addobj, Int_t bufsize, Int_t splitlevel);
|
|---|
| 60 |
|
|---|
| 61 | public:
|
|---|
| 62 | MTreeSQL(MSQLServer *server, const TString& table, const TString &addon="");
|
|---|
| 63 | ~MTreeSQL();
|
|---|
| 64 |
|
|---|
| 65 | Int_t Branch(TCollection *list, Int_t bufsize=32000, Int_t splitlevel=99, const char *name="");
|
|---|
| 66 | Int_t Branch(TList *list, Int_t bufsize=32000, Int_t splitlevel=99);
|
|---|
| 67 | Int_t Branch(const char *folder, Int_t bufsize=32000, Int_t splitlevel=99);
|
|---|
| 68 | TBranch *Bronch(const char *name, const char *classname, void *addobj, Int_t bufsize=32000, Int_t splitlevel=99);
|
|---|
| 69 | TBranch *BranchOld(const char *name, const char *classname, void *addobj, Int_t bufsize=32000, Int_t splitlevel=1);
|
|---|
| 70 | TBranch *Branch(const char *name, void *address, const char *leaflist, Int_t bufsize) { return TTree::Branch(name, address, leaflist, bufsize); }
|
|---|
| 71 | #if !defined(__CINT__)
|
|---|
| 72 | TBranch *Branch(const char *name, const char *classname, void *addobj, Int_t bufsize=32000, Int_t splitlevel=99);
|
|---|
| 73 | #endif
|
|---|
| 74 |
|
|---|
| 75 | Int_t Fill();
|
|---|
| 76 | Long64_t GetEntries() const;
|
|---|
| 77 | Long64_t GetEntries(const char *sel) { return TTree::GetEntries(sel); }
|
|---|
| 78 | Long64_t GetEntriesFast()const;
|
|---|
| 79 | Long64_t LoadTree(Long64_t entry);
|
|---|
| 80 |
|
|---|
| 81 | void Refresh();
|
|---|
| 82 |
|
|---|
| 83 | ClassDef(MTreeSQL,1); // TTree Implementation read and write to a SQL database.
|
|---|
| 84 | };
|
|---|
| 85 |
|
|---|
| 86 |
|
|---|
| 87 | #endif
|
|---|