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);
57 bool CheckBranch(TBranch *tb);
58 bool 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 CreateTable(const TString& table);
66 TBasket *CreateBasket(TBranch * br) override;
67
68 TBranch *BranchImp(const char *branchname, const char *classname, TClass *ptrClass, void *addobj, Int_t bufsize, Int_t splitlevel) override;
69 TBranch *BranchImp(const char *branchname, TClass *ptrClass, void *addobj, Int_t bufsize, Int_t splitlevel) override;
70
71public:
72 TTreeSQL(TSQLServer * server, TString DB, const TString& table);
73 ~TTreeSQL() override;
74
75 Int_t Branch(TCollection *list, Int_t bufsize=32000, Int_t splitlevel=99, const char *name="") override;
76 Int_t Branch(TList *list, Int_t bufsize=32000, Int_t splitlevel=99) override;
77 Int_t Branch(const char *folder, Int_t bufsize=32000, Int_t splitlevel=99) override;
78 TBranch *Bronch(const char *name, const char *classname, void *addobj, Int_t bufsize=32000, Int_t splitlevel=99) override;
79 TBranch *BranchOld(const char *name, const char *classname, void *addobj, Int_t bufsize=32000, Int_t splitlevel=1) override;
80 TBranch *Branch(const char *name, const char *classname, void *addobj, Int_t bufsize=32000, Int_t splitlevel=99) override;
81
82 TBranch *Branch(const char *name, void *address, const char *leaflist, Int_t bufsize) override;
83
84 Int_t Fill() override;
85 Int_t GetEntry(Long64_t entry=0, Int_t getall=0) override;
86 Long64_t GetEntries() const override;
87 Long64_t GetEntries(const char *sel) override { return TTree::GetEntries(sel); }
88 Long64_t GetEntriesFast()const override;
90 Long64_t LoadTree(Long64_t entry) override;
91 virtual Long64_t PrepEntry(Long64_t entry);
92 void Refresh() override;
93
94 ClassDefOverride(TTreeSQL,2); // TTree Implementation read and write to a SQL database.
95};
96
97
98#endif
long long Long64_t
Definition RtypesCore.h:69
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t sel
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:93
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:81
Collection abstract base class.
Definition TCollection.h:65
A doubly linked list.
Definition TList.h:38
Basic string class.
Definition TString.h:139
A TTree object is a list of TBranch.
Definition TTreeSQL.h:42
TBasket * CreateBasket(TBranch *br) override
Create a TBasketSQL.
Definition TTreeSQL.cxx:351
TString fDB
Definition TTreeSQL.h:46
TString ConvertTypeName(const TString &typeName)
Convert from ROOT typename to SQL typename.
Definition TTreeSQL.cxx:290
bool fBranchChecked
Definition TTreeSQL.h:53
TBranch * BranchImp(const char *branchname, const char *classname, TClass *ptrClass, void *addobj, Int_t bufsize, Int_t splitlevel) override
Not implemented yet.
Definition TTreeSQL.cxx:76
bool CheckTable(const TString &table) const
Check the table exist in the database.
Definition TTreeSQL.cxx:263
TBranch * BranchOld(const char *name, const char *classname, void *addobj, Int_t bufsize=32000, Int_t splitlevel=1) override
Not implemented yet.
Definition TTreeSQL.cxx:135
void CreateBranches()
determine leaf description string
Definition TTreeSQL.cxx:391
TSQLTableInfo * fTableInfo
Definition TTreeSQL.h:54
void Init()
Initialization routine.
Definition TTreeSQL.cxx:550
Int_t GetEntry(Long64_t entry=0, Int_t getall=0) override
Load the data for the entry from the database.
Definition TTreeSQL.cxx:729
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
Long64_t LoadTree(Long64_t entry) override
Setup the tree to the load the specified entry.
Definition TTreeSQL.cxx:738
TSQLResult * fResult
Definition TTreeSQL.h:50
TString GetTableName()
Definition TTreeSQL.h:89
virtual Long64_t PrepEntry(Long64_t entry)
Make sure the server and result set are setup for the requested entry.
Definition TTreeSQL.cxx:747
bool CreateTable(const TString &table)
Create the database table corresponding to this TTree.
Definition TTreeSQL.cxx:488
Int_t Fill() override
Copy the information from the user object to the TTree.
Definition TTreeSQL.cxx:570
TBranch * Bronch(const char *name, const char *classname, void *addobj, Int_t bufsize=32000, Int_t splitlevel=99) override
Not implemented yet.
Definition TTreeSQL.cxx:125
TString fQuery
Definition TTreeSQL.h:48
TString fTable
Definition TTreeSQL.h:49
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
Int_t fCurrentEntry
Definition TTreeSQL.h:45
TString fInsertQuery
Definition TTreeSQL.h:47
TSQLRow * fRow
Definition TTreeSQL.h:51
void ResetQuery()
Reset the internal query.
Definition TTreeSQL.cxx:808
Int_t Branch(TCollection *list, Int_t bufsize=32000, Int_t splitlevel=99, const char *name="") override
Not implemented yet.
Definition TTreeSQL.cxx:96
bool CheckBranch(TBranch *tb)
Check if the table has a column corresponding the branch and that the resultset are properly setup.
Definition TTreeSQL.cxx:215
Long64_t GetEntries() const override
Get the number of rows in the database.
Definition TTreeSQL.cxx:688
Long64_t GetEntriesFast() const override
Return the number of entries as of the last check.
Definition TTreeSQL.cxx:721
~TTreeSQL() override
Definition TTreeSQL.cxx:817
Long64_t GetEntries(const char *sel) override
Return the number of entries matching the selection.
Definition TTreeSQL.h:87
void Refresh() override
Refresh contents of this Tree and its branches from the current Tree status in the database One can c...
Definition TTreeSQL.cxx:796
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:463