ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 #ifndef ROOT_TTree
34 #include "TTree.h"
35 #endif
36 
37 #include <vector>
38 
39 class TSQLServer;
40 class TSQLRow;
41 class TBasketSQL;
42 
43 class TTreeSQL : public TTree {
44 
45 protected:
55 
56  void CheckBasket(TBranch * tb);
58  Bool_t CheckTable(const TString &table) const;
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 #if !defined(__CINT__)
80  virtual TBranch *Branch(const char *name, const char *classname, void *addobj, Int_t bufsize=32000, Int_t splitlevel=99);
81 #endif
82 
83  virtual TBranch *Branch(const char *name, void *address, const char *leaflist, Int_t bufsize);
84 
85  virtual Int_t Fill();
86  virtual Int_t GetEntry(Long64_t entry=0, Int_t getall=0);
87  virtual Long64_t GetEntries() const;
88  virtual Long64_t GetEntries(const char *sel) { return TTree::GetEntries(sel); }
89  virtual Long64_t GetEntriesFast()const;
93  void Refresh();
94 
95  ClassDef(TTreeSQL,1); // TTree Implementation read and write to a SQL database.
96 };
97 
98 
99 #endif
TString CreateBranches(TSQLResult *rs)
determine leaf description string
Definition: TTreeSQL.cxx:376
TSQLServer * fServer
Definition: TTreeSQL.h:53
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:561
TString GetTableName()
Definition: TTreeSQL.h:90
TSQLResult * fResult
Definition: TTreeSQL.h:51
void Init()
Initializeation routine.
Definition: TTreeSQL.cxx:545
ClassDef(TTreeSQL, 1)
Bool_t fBranchChecked
Definition: TTreeSQL.h:54
Basic string class.
Definition: TString.h:137
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:204
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
virtual Long64_t GetEntriesFast() const
Return the number of entries as of the last check.
Definition: TTreeSQL.cxx:708
TString fInsertQuery
Definition: TTreeSQL.h:48
Implement TTree for a SQL backend.
Definition: TTreeSQL.h:43
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:125
virtual Long64_t GetEntries(const char *sel)
Return the number of entries matching the selection.
Definition: TTreeSQL.h:88
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:65
virtual Long64_t LoadTree(Long64_t entry)
Setup the tree to the load the specified entry.
Definition: TTreeSQL.cxx:725
void ResetQuery()
Reset the internal query.
Definition: TTreeSQL.cxx:795
virtual void CreateBranch(const TString &branchName, const TString &typeName)
Create the column(s) in the database that correspond to the branch/.
Definition: TTreeSQL.cxx:354
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:613
TString fTable
Definition: TTreeSQL.h:50
A doubly linked list.
Definition: TList.h:47
void Refresh()
Refresh contents of this Tree and its branches from the current Tree status in the database One can c...
Definition: TTreeSQL.cxx:783
TSQLRow * fRow
Definition: TTreeSQL.h:52
Collection abstract base class.
Definition: TCollection.h:48
Manages buffers for branches of a Tree.
Definition: TBasket.h:38
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:81
TString fDB
Definition: TTreeSQL.h:47
Long64_t entry
Implement TBasket for a SQL backend.
Definition: TBasketSQL.h:30
TString fQuery
Definition: TTreeSQL.h:49
virtual Int_t GetEntry(Long64_t entry=0, Int_t getall=0)
Load the data for the entry from the database.
Definition: TTreeSQL.cxx:716
#define name(a, b)
Definition: linkTestLib0.cpp:5
virtual Int_t Branch(TCollection *list, Int_t bufsize=32000, Int_t splitlevel=99, const char *name="")
Not implemented yet.
Definition: TTreeSQL.cxx:86
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:115
Bool_t CreateTable(const TString &table)
Create the database table corresponding to this TTree.
Definition: TTreeSQL.cxx:483
Bool_t CheckTable(const TString &table) const
Check the table exist in the database.
Definition: TTreeSQL.cxx:252
virtual Long64_t GetEntries() const
Get the number of rows in the database.
Definition: TTreeSQL.cxx:675
virtual TBasket * CreateBasket(TBranch *br)
Create a TBasketSQL.
Definition: TTreeSQL.cxx:336
void CheckBasket(TBranch *tb)
Check if the basket is properly setup.
Definition: TTreeSQL.cxx:176
virtual Long64_t GetEntries() const
Definition: TTree.h:386
A TTree object has a header with a name and a title.
Definition: TTree.h:98
TString ConvertTypeName(const TString &typeName)
Convert from ROOT typename to SQL typename.
Definition: TTreeSQL.cxx:279
A TTree is a list of TBranches.
Definition: TBranch.h:58
virtual Long64_t PrepEntry(Long64_t entry)
Make sure the server and result set are setup for the requested entry.
Definition: TTreeSQL.cxx:734
Int_t fCurrentEntry
Definition: TTreeSQL.h:46
TTreeSQL(TSQLServer *server, TString DB, const TString &table)