Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
37class TSQLServer;
38class TSQLRow;
39class TBasketSQL;
40class TSQLTableInfo;
41
42class TTreeSQL : public TTree {
43
44protected:
55
56 void CheckBasket(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
71public:
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;
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
long long Long64_t
Definition RtypesCore.h:73
#define ClassDef(name, id)
Definition Rtypes.h:325
char name[80]
Definition TGX11.cxx:110
Implement TBasket for a SQL backend.
Definition TBasketSQL.h:31
Manages buffers for branches of a Tree.
Definition TBasket.h:34
A TTree is a list of TBranches.
Definition TBranch.h:89
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:80
Collection abstract base class.
Definition TCollection.h:63
A doubly linked list.
Definition TList.h:44
Basic string class.
Definition TString.h:136
A TTree object is a list of TBranch.
Definition TTreeSQL.h:42
TString fDB
Definition TTreeSQL.h:46
TString ConvertTypeName(const TString &typeName)
Convert from ROOT typename to SQL typename.
Definition TTreeSQL.cxx:290
virtual Long64_t GetEntries() const
Get the number of rows in the database.
Definition TTreeSQL.cxx:688
virtual Long64_t GetEntriesFast() const
Return the number of entries as of the last check.
Definition TTreeSQL.cxx:721
Bool_t CheckTable(const TString &table) const
Check the table exist in the database.
Definition TTreeSQL.cxx:263
virtual Int_t GetEntry(Long64_t entry=0, Int_t getall=0)
Load the data for the entry from the database.
Definition TTreeSQL.cxx:729
void CreateBranches()
determine leaf description string
Definition TTreeSQL.cxx:391
virtual Int_t Fill()
Copy the information from the user object to the TTree.
Definition TTreeSQL.cxx:570
TSQLTableInfo * fTableInfo
Definition TTreeSQL.h:54
void Init()
Initialization routine.
Definition TTreeSQL.cxx:550
Bool_t fBranchChecked
Definition TTreeSQL.h:53
TSQLServer * fServer
Definition TTreeSQL.h:52
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:622
TSQLResult * fResult
Definition TTreeSQL.h:50
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:215
TString GetTableName()
Definition TTreeSQL.h: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:125
virtual Long64_t PrepEntry(Long64_t entry)
Make sure the server and result set are setup for the requested entry.
Definition TTreeSQL.cxx:747
TString fQuery
Definition TTreeSQL.h:48
virtual Long64_t LoadTree(Long64_t entry)
Setup the tree to the load the specified entry.
Definition TTreeSQL.cxx:738
virtual Int_t Branch(TCollection *list, Int_t bufsize=32000, Int_t splitlevel=99, const char *name="")
Not implemented yet.
Definition TTreeSQL.cxx:96
TString fTable
Definition TTreeSQL.h:49
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:135
virtual void CreateBranch(const TString &branchName, const TString &typeName)
Create the column(s) in the database that correspond to the branch/.
Definition TTreeSQL.cxx:369
void Refresh()
Refresh contents of this Tree and its branches from the current Tree status in the database One can c...
Definition TTreeSQL.cxx:796
virtual ~TTreeSQL()
Definition TTreeSQL.cxx:817
Int_t fCurrentEntry
Definition TTreeSQL.h:45
TString fInsertQuery
Definition TTreeSQL.h:47
TSQLRow * fRow
Definition TTreeSQL.h:51
virtual Long64_t GetEntries(const char *sel)
Return the number of entries matching the selection.
Definition TTreeSQL.h:86
void ResetQuery()
Reset the internal query.
Definition TTreeSQL.cxx:808
virtual TBasket * CreateBasket(TBranch *br)
Create a TBasketSQL.
Definition TTreeSQL.cxx:351
Bool_t CreateTable(const TString &table)
Create the database table corresponding to this TTree.
Definition TTreeSQL.cxx:488
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:76
void CheckBasket(TBranch *tb)
Check if the basket is properly setup.
Definition TTreeSQL.cxx:187
A TTree represents a columnar dataset.
Definition TTree.h:79
virtual Long64_t GetEntries() const
Definition TTree.h:460