Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TTreeSQL.h
Go to the documentation of this file.
1 // @(#)root/tree:$Id$
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_TTreeSQL
13 #define ROOT_TTreeSQL
14 
15 //////////////////////////////////////////////////////////////////////////
16 // //
17 // TTreeSQL //
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 // TTreeSQL is the TTree implementation interfacing with an SQL //
28 // database //
29 // //
30 //////////////////////////////////////////////////////////////////////////
31 
32 
33 #include "TTree.h"
34 
35 #include <vector>
36 
37 class TSQLServer;
38 class TSQLRow;
39 class TBasketSQL;
40 class TSQLTableInfo;
41 
42 class TTreeSQL : public TTree {
43 
44 protected:
45  Int_t fCurrentEntry;
46  TString fDB;
47  TString fInsertQuery;
48  TString fQuery;
49  TString fTable;
50  TSQLResult *fResult;
51  TSQLRow *fRow;
52  TSQLServer *fServer;
53  Bool_t fBranchChecked;
54  TSQLTableInfo *fTableInfo;
55 
56  void CheckBasket(TBranch * tb);
57  Bool_t CheckBranch(TBranch * tb);
58  Bool_t CheckTable(const TString &table) const;
59  void CreateBranches();
60  std::vector<Int_t> *GetColumnIndice(TBranch *branch);
61  void Init();
62  void ResetQuery();
63  TString ConvertTypeName(const TString& typeName );
64  virtual void CreateBranch(const TString& branchName,const TString &typeName);
65  Bool_t CreateTable(const TString& table);
66  virtual TBasket *CreateBasket(TBranch * br);
67 
68  virtual TBranch *BranchImp(const char *branchname, const char *classname, TClass *ptrClass, void *addobj, Int_t bufsize, Int_t splitlevel);
69  virtual TBranch *BranchImp(const char *branchname, TClass *ptrClass, void *addobj, Int_t bufsize, Int_t splitlevel);
70 
71 public:
72  TTreeSQL(TSQLServer * server, TString DB, const TString& table);
73 
74  virtual Int_t Branch(TCollection *list, Int_t bufsize=32000, Int_t splitlevel=99, const char *name="");
75  virtual Int_t Branch(TList *list, Int_t bufsize=32000, Int_t splitlevel=99);
76  virtual Int_t Branch(const char *folder, Int_t bufsize=32000, Int_t splitlevel=99);
77  virtual TBranch *Bronch(const char *name, const char *classname, void *addobj, Int_t bufsize=32000, Int_t splitlevel=99);
78  virtual TBranch *BranchOld(const char *name, const char *classname, void *addobj, Int_t bufsize=32000, Int_t splitlevel=1);
79  virtual TBranch *Branch(const char *name, const char *classname, void *addobj, Int_t bufsize=32000, Int_t splitlevel=99);
80 
81  virtual TBranch *Branch(const char *name, void *address, const char *leaflist, Int_t bufsize);
82 
83  virtual Int_t Fill();
84  virtual Int_t GetEntry(Long64_t entry=0, Int_t getall=0);
85  virtual Long64_t GetEntries() const;
86  virtual Long64_t GetEntries(const char *sel) { return TTree::GetEntries(sel); }
87  virtual Long64_t GetEntriesFast()const;
88  TString GetTableName(){ return fTable; }
89  virtual Long64_t LoadTree(Long64_t entry);
90  virtual Long64_t PrepEntry(Long64_t entry);
91  void Refresh();
92 
93  virtual ~TTreeSQL();
94  ClassDef(TTreeSQL,2); // TTree Implementation read and write to a SQL database.
95 };
96 
97 
98 #endif