Logo ROOT  
Reference Guide
Go to the documentation of this file.
1// @(#)root/tree:$Id$
2// Author: Rene Brun 12/01/96
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
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// //
33#include "TTree.h"
35#include <vector>
37class TSQLServer;
38class TSQLRow;
39class TBasketSQL;
40class TSQLTableInfo;
42class TTreeSQL : public TTree {
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);
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);
72 TTreeSQL(TSQLServer * server, TString DB, const TString& table);
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);
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 virtual ~TTreeSQL();
94 ClassDef(TTreeSQL,2); // TTree Implementation read and write to a SQL database.
long long Long64_t
Definition: RtypesCore.h:71
#define ClassDef(name, id)
Definition: Rtypes.h:322
char name[80]
Definition: TGX11.cxx:109
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:91
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:131
Implement TTree for a SQL backend.
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:284
virtual Long64_t GetEntries() const
Get the number of rows in the database.
Definition: TTreeSQL.cxx:682
virtual Long64_t GetEntriesFast() const
Return the number of entries as of the last check.
Definition: TTreeSQL.cxx:715
Bool_t CheckTable(const TString &table) const
Check the table exist in the database.
Definition: TTreeSQL.cxx:257
virtual Int_t GetEntry(Long64_t entry=0, Int_t getall=0)
Load the data for the entry from the database.
Definition: TTreeSQL.cxx:723
void CreateBranches()
determine leaf description string
Definition: TTreeSQL.cxx:385
virtual Int_t Fill()
Copy the information from the user object to the TTree.
Definition: TTreeSQL.cxx:564
TSQLTableInfo * fTableInfo
Definition: TTreeSQL.h:54
void Init()
Initializeation routine.
Definition: TTreeSQL.cxx:544
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:616
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:209
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:119
virtual Long64_t PrepEntry(Long64_t entry)
Make sure the server and result set are setup for the requested entry.
Definition: TTreeSQL.cxx:741
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:732
virtual Int_t Branch(TCollection *list, Int_t bufsize=32000, Int_t splitlevel=99, const char *name="")
Not implemented yet.
Definition: TTreeSQL.cxx:90
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:129
virtual void CreateBranch(const TString &branchName, const TString &typeName)
Create the column(s) in the database that correspond to the branch/.
Definition: TTreeSQL.cxx:363
void Refresh()
Refresh contents of this Tree and its branches from the current Tree status in the database One can c...
Definition: TTreeSQL.cxx:790
virtual ~TTreeSQL()
Definition: TTreeSQL.cxx:811
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:802
TTreeSQL(TSQLServer *server, TString DB, const TString &table)
Constructor with an explicit TSQLServer.
Definition: TTreeSQL.cxx:46
virtual TBasket * CreateBasket(TBranch *br)
Create a TBasketSQL.
Definition: TTreeSQL.cxx:345
Bool_t CreateTable(const TString &table)
Create the database table corresponding to this TTree.
Definition: TTreeSQL.cxx:482
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:70
void CheckBasket(TBranch *tb)
Check if the basket is properly setup.
Definition: TTreeSQL.cxx:181
A TTree represents a columnar dataset.
Definition: TTree.h:78
virtual Long64_t GetEntries() const
Definition: TTree.h:457