Logo ROOT   6.14/05
Reference Guide
Go to the documentation of this file.
1 // @(#)root/tree:$Id$
2 // Author: Rene Brun 12/01/96
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  *************************************************************************/
12 #ifndef ROOT_TTreeSQL
13 #define ROOT_TTreeSQL
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 //////////////////////////////////////////////////////////////////////////
33 #include "TTree.h"
35 #include <vector>
37 class TSQLServer;
38 class TSQLRow;
39 class TBasketSQL;
41 class TTreeSQL : public TTree {
43 protected:
54  void CheckBasket(TBranch * tb);
56  Bool_t CheckTable(const TString &table) const;
58  std::vector<Int_t> *GetColumnIndice(TBranch *branch);
59  void Init();
60  void ResetQuery();
61  TString ConvertTypeName(const TString& typeName );
62  virtual void CreateBranch(const TString& branchName,const TString &typeName);
63  Bool_t CreateTable(const TString& table);
64  virtual TBasket *CreateBasket(TBranch * br);
66  virtual TBranch *BranchImp(const char *branchname, const char *classname, TClass *ptrClass, void *addobj, Int_t bufsize, Int_t splitlevel);
67  virtual TBranch *BranchImp(const char *branchname, TClass *ptrClass, void *addobj, Int_t bufsize, Int_t splitlevel);
69 public:
70  TTreeSQL(TSQLServer * server, TString DB, const TString& table);
72  virtual Int_t Branch(TCollection *list, Int_t bufsize=32000, Int_t splitlevel=99, const char *name="");
73  virtual Int_t Branch(TList *list, Int_t bufsize=32000, Int_t splitlevel=99);
74  virtual Int_t Branch(const char *folder, Int_t bufsize=32000, Int_t splitlevel=99);
75  virtual TBranch *Bronch(const char *name, const char *classname, void *addobj, Int_t bufsize=32000, Int_t splitlevel=99);
76  virtual TBranch *BranchOld(const char *name, const char *classname, void *addobj, Int_t bufsize=32000, Int_t splitlevel=1);
77 #if !defined(__CINT__)
78  virtual TBranch *Branch(const char *name, const char *classname, void *addobj, Int_t bufsize=32000, Int_t splitlevel=99);
79 #endif
81  virtual TBranch *Branch(const char *name, void *address, const char *leaflist, Int_t bufsize);
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;
89  virtual Long64_t LoadTree(Long64_t entry);
90  virtual Long64_t PrepEntry(Long64_t entry);
91  void Refresh();
93  ClassDef(TTreeSQL,1); // TTree Implementation read and write to a SQL database.
94 };
97 #endif
TString CreateBranches(TSQLResult *rs)
determine leaf description string
Definition: TTreeSQL.cxx:378
TSQLServer * fServer
Definition: TTreeSQL.h:51
long long Long64_t
Definition: RtypesCore.h:69
virtual Int_t Fill()
Copy the information from the user object to the TTree.
Definition: TTreeSQL.cxx:563
TString GetTableName()
Definition: TTreeSQL.h:88
TSQLResult * fResult
Definition: TTreeSQL.h:49
Bool_t CheckTable(const TString &table) const
Check the table exist in the database.
Definition: TTreeSQL.cxx:254
void Init()
Initializeation routine.
Definition: TTreeSQL.cxx:547
Bool_t fBranchChecked
Definition: TTreeSQL.h:52
Basic string class.
Definition: TString.h:131
Bool_t CheckBranch(TBranch *tb)
Check if the table has a column corresponding the branch and that the resultset are properly setup...
Definition: TTreeSQL.cxx:206
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
virtual Long64_t GetEntries() const
Get the number of rows in the database.
Definition: TTreeSQL.cxx:677
TString fInsertQuery
Definition: TTreeSQL.h:46
Implement TTree for a SQL backend.
Definition: TTreeSQL.h:41
virtual TBranch * BranchOld(const char *name, const char *classname, void *addobj, Int_t bufsize=32000, Int_t splitlevel=1)
Not implemented yet.
Definition: TTreeSQL.cxx:127
virtual Long64_t GetEntries(const char *sel)
Return the number of entries matching the selection.
Definition: TTreeSQL.h:86
virtual TBranch * BranchImp(const char *branchname, const char *classname, TClass *ptrClass, void *addobj, Int_t bufsize, Int_t splitlevel)
Not implemented yet.
Definition: TTreeSQL.cxx:67
#define ClassDef(name, id)
Definition: Rtypes.h:320
virtual Long64_t LoadTree(Long64_t entry)
Setup the tree to the load the specified entry.
Definition: TTreeSQL.cxx:727
void ResetQuery()
Reset the internal query.
Definition: TTreeSQL.cxx:797
virtual void CreateBranch(const TString &branchName, const TString &typeName)
Create the column(s) in the database that correspond to the branch/.
Definition: TTreeSQL.cxx:356
std::vector< Int_t > * GetColumnIndice(TBranch *branch)
Return a vector of columns index corresponding to the current SQL table and the branch given as argum...
Definition: TTreeSQL.cxx:615
TString fTable
Definition: TTreeSQL.h:48
A doubly linked list.
Definition: TList.h:44
void Refresh()
Refresh contents of this Tree and its branches from the current Tree status in the database One can c...
Definition: TTreeSQL.cxx:785
TSQLRow * fRow
Definition: TTreeSQL.h:50
Collection abstract base class.
Definition: TCollection.h:63
Manages buffers for branches of a Tree.
Definition: TBasket.h:34
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:75
TString fDB
Definition: TTreeSQL.h:45
virtual Long64_t GetEntriesFast() const
Return the number of entries as of the last check.
Definition: TTreeSQL.cxx:710
Implement TBasket for a SQL backend.
Definition: TBasketSQL.h:30
TString fQuery
Definition: TTreeSQL.h:47
virtual Long64_t GetEntries() const
Definition: TTree.h:384
virtual Int_t GetEntry(Long64_t entry=0, Int_t getall=0)
Load the data for the entry from the database.
Definition: TTreeSQL.cxx:718
virtual Int_t Branch(TCollection *list, Int_t bufsize=32000, Int_t splitlevel=99, const char *name="")
Not implemented yet.
Definition: TTreeSQL.cxx:88
virtual TBranch * Bronch(const char *name, const char *classname, void *addobj, Int_t bufsize=32000, Int_t splitlevel=99)
Not implemented yet.
Definition: TTreeSQL.cxx:117
Bool_t CreateTable(const TString &table)
Create the database table corresponding to this TTree.
Definition: TTreeSQL.cxx:485
virtual TBasket * CreateBasket(TBranch *br)
Create a TBasketSQL.
Definition: TTreeSQL.cxx:338
void CheckBasket(TBranch *tb)
Check if the basket is properly setup.
Definition: TTreeSQL.cxx:178
A TTree object has a header with a name and a title.
Definition: TTree.h:70
TString ConvertTypeName(const TString &typeName)
Convert from ROOT typename to SQL typename.
Definition: TTreeSQL.cxx:281
A TTree is a list of TBranches.
Definition: TBranch.h:62
virtual Long64_t PrepEntry(Long64_t entry)
Make sure the server and result set are setup for the requested entry.
Definition: TTreeSQL.cxx:736
Int_t fCurrentEntry
Definition: TTreeSQL.h:44
char name[80]
Definition: TGX11.cxx:109
TTreeSQL(TSQLServer *server, TString DB, const TString &table)
Constructor with an explicit TSQLServer.
Definition: TTreeSQL.cxx:44