ROOT  6.06/09
Reference Guide
TDataSetIter.h
Go to the documentation of this file.
1 // @(#)root/table:$Id$
2 // Author: Valery Fine(fine@mail.cern.ch) 03/07/98
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2006, 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_TDataSetIter
13 #define ROOT_TDataSetIter
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // //
19 // TDataSetIter //
20 // //
21 // Iterator of TDataSet lists. //
22 // //
23 // Provides "standard" features of the TIter class for TDataSet object //
24 // and //
25 // allows navigating TDataSet structure using the custom "directory" //
26 // notation (see TDataSet::Find(const Char *path) method) //
27 // //
28 //////////////////////////////////////////////////////////////////////////
29 
30 #include "TList.h"
31 #include "TNamed.h"
32 
33 #include "TDataSet.h"
34 
35 class TDataSetIter : public TObject{
36 protected:
37  TIter *fNext; // "standard" ROOT iterator for containers
38  TIter *fNextSet[100]; // the list of the TList iterators to bypass the whole dataset
39  Int_t fDepth; // the current depth of the passing
40  Int_t fMaxDepth; // the max depth of the passing (=1 by default)
41 
42  TDataSet *fDataSet; // Pointer to the last selected TDataSet
43  TDataSet *fRootDataSet; // Pointer to the root TDataSet
44  TDataSet *fWorkingDataSet; // Pointer to the working TDataSet
46  TDataSet *NextDataSet(Int_t nDataSet);
47  TDataSet *GetNullSet(); // return a fake pointer == -1 casted to (TDataSet *)
48 
50 
51 private:
52 
53  TDataSetIter(const TDataSetIter&); // Not implemented.
54  TDataSetIter &operator=(const TDataSetIter&); // Not implemented.
55 
56 public:
57  TDataSetIter(TDataSet *l=0, Int_t depth=1, Bool_t dir=kIterForward);
59  virtual ~TDataSetIter();
60 
61  virtual TDataSet *Add(TDataSet *set){return Add(set,(TDataSet *)0);}
62  virtual TDataSet *Add(TDataSet *set, const Char_t *path);
63  virtual TDataSet *Add(TDataSet *set, TDataSet *dataset);
64 
65  virtual TDataSet *Cd(const Char_t *dirname);
66  virtual TDataSet *Cd(TDataSet *ds);
68  virtual TDataSet *operator()(const Char_t *path) { return Find(path); }
69  virtual TDataSet *operator[](const Char_t *path);
70  virtual Int_t GetDepth() const {return fDepth;}
71  virtual TDataSet *Cwd() const {return fWorkingDataSet;}
72  virtual TDataSet *Dir(Char_t *dirname);
73  virtual Int_t Du() const; // summarize dataset usage
74  virtual Int_t Df() const {return 0;} // report number of free "table" blocks.
75 
76  virtual TDataSet *Find(const Char_t *path, TDataSet *rootset=0,Bool_t mkdir=kFALSE,Bool_t titleFlag=kFALSE);
77  virtual TDataSet *FindByPath(const Char_t *path, TDataSet *rootset=0,Bool_t mkdir=kFALSE);
78  virtual TDataSet *FindDataSet(const Char_t *name,const Char_t *path="",Option_t *opt="");
79  virtual TDataSet *FindByName(const Char_t *name,const Char_t *path="",Option_t *opt="");
80  virtual TDataSet *FindByTitle(const Char_t *title,const Char_t *path="",Option_t *opt="");
81  virtual TDataSet *FindDataSet(TDataSet *set,const Char_t *path,Option_t *opt="");
82  virtual TDataSet *FindByPointer(TDataSet *set,const Char_t *path=0,Option_t *opt="");
83  virtual TObject *FindObject(const Char_t *name) const;
84  virtual TObject *FindObject(const TObject *obj) const;
85 
86  virtual Int_t Flag(UInt_t flag=TDataSet::kMark,TDataSet::EBitOpt reset=TDataSet::kSet){return Flag((TDataSet *)0,flag,reset);}
87  virtual Int_t Flag(const Char_t *path,UInt_t flag=TDataSet::kMark,TDataSet::EBitOpt reset=TDataSet::kSet);
89 
90  virtual TDataSet *Ls(const Char_t *dirname="",Option_t *opt="") const;
91  virtual TDataSet *Ls(const Char_t *dirname,Int_t depth) const;
92  virtual void ls(Option_t *dirname="") const { Ls(dirname,"");}
93  virtual TDataSet *ls(TString dirname,Option_t *opt="") const {return Ls(dirname.Data(),opt);}
94  virtual TDataSet *ls(const Char_t *dirname,Int_t depth) const {return Ls(dirname,depth);}
95  virtual TDataSet *Mkdir(const Char_t *dirname);
96  virtual TDataSet *Md(const Char_t *dirname) {return Mkdir(dirname);}
97  virtual TString Path(const Char_t *path) {TDataSet *set = Find(path); return set ? set->Path():TString ("");}
98  virtual TString Path() {return fWorkingDataSet ? fWorkingDataSet->Path() : TString ("");}
99  virtual TDataSet *Pwd(Option_t *opt="") const {if (Cwd()) Cwd()->ls(opt); return Cwd();}
100  virtual TDataSet *Rmdir(TDataSet *dataset,Option_t *option="");
101  virtual TDataSet *Rmdir(const Char_t *dirname,Option_t *option=""){return Rmdir(Find(dirname),option);}
102  virtual TDataSet *Rd(const Char_t *dirname,Option_t *option="") {return Rmdir(Find(dirname),option);}
103 
104  virtual TDataSet *Shunt(TDataSet *set){return Shunt(set,(TDataSet *)0);}
105  virtual TDataSet *Shunt(TDataSet *set, const Char_t *path);
106  virtual TDataSet *Shunt(TDataSet *set, TDataSet *dataset);
107 
109  virtual TDataSet *Next(const Char_t *path, TDataSet *rootset=0,Bool_t mkdir=kFALSE){return Find(path,rootset,mkdir);}
110  virtual Bool_t Notify() { return TObject::Notify();}
111  virtual void Notify(TDataSet *dataset);
112  const Option_t *GetOption() const { return fNext ? fNext->GetOption():0; }
113  virtual void Reset(TDataSet *l=0,Int_t depth=0);
114  virtual TDataSet *operator *() const ;
115 
116  ClassDef(TDataSetIter,0) // class-iterator to navigate TDataSet structure
117 };
118 
119 #endif
120 
virtual Bool_t Notify()
This method must be overridden to handle object notification.
Definition: TDataSetIter.h:110
virtual Int_t Du() const
summarize dataset usage by Herb Ward proposal
TIter * fNextSet[100]
Definition: TDataSetIter.h:38
virtual TDataSet * Mkdir(const Char_t *dirname)
to be documented
TDataSetIter(const TDataSetIter &)
virtual TDataSet * FindByTitle(const Char_t *title, const Char_t *path="", Option_t *opt="")
to be documented
virtual Int_t Flag(UInt_t flag=TDataSet::kMark, TDataSet::EBitOpt reset=TDataSet::kSet)
Definition: TDataSetIter.h:86
ClassImp(TSeqCollection) Int_t TSeqCollection TIter next(this)
Return index of object in collection.
virtual TDataSet * Shunt(TDataSet *set)
Definition: TDataSetIter.h:104
const char Option_t
Definition: RtypesCore.h:62
virtual TDataSet * Cd(const Char_t *dirname)
// TDataSet *TDataSetIter::Cd(const Char_t *dirname) // // Change the current working directory to di...
TIter * fNext
Definition: TDataSetIter.h:37
virtual TDataSet * Next(TDataSet::EDataSetPass mode=TDataSet::kContinue)
returns the pointer the "next" TDataSet object = 0 if all objects have been returned.
Basic string class.
Definition: TString.h:137
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
virtual TDataSet * FindByPath(const Char_t *path, TDataSet *rootset=0, Bool_t mkdir=kFALSE)
to be documented
virtual TDataSet * Dir(Char_t *dirname)
Print the names of the TDataSet objects for the datatset named with "dirname" apart of TDataSet::Ls()...
virtual TDataSet * FindByPointer(TDataSet *set, const Char_t *path=0, Option_t *opt="")
Check whether the object does belong the TDataSet defined with "path" opt = "-l" - check the "referen...
virtual TDataSet * Cwd() const
Definition: TDataSetIter.h:71
TDataSet * NextDataSet(TIter &next)
to be documented
TDataSet * fWorkingDataSet
Definition: TDataSetIter.h:44
const char * Data() const
Definition: TString.h:349
virtual TDataSet * operator()(TDataSet::EDataSetPass mode=TDataSet::kContinue)
Definition: TDataSetIter.h:67
#define ClassDef(name, id)
Definition: Rtypes.h:254
virtual TDataSet * Ls(const Char_t *dirname="", Option_t *opt="") const
Ls(const Char_t *dirname,Option_t)
virtual Bool_t Notify()
This method must be overridden to handle object notification.
Definition: TObject.cxx:550
virtual TString Path(const Char_t *path)
Definition: TDataSetIter.h:97
EDataSetPass
Definition: TDataSet.h:40
const Bool_t kIterForward
Definition: TCollection.h:43
virtual TObject * FindObject(const Char_t *name) const
This method is not recommended.
Int_t fMaxDepth
Definition: TDataSetIter.h:40
static TDataSet * fgNullDataSet
Definition: TDataSetIter.h:49
virtual TDataSet * Rd(const Char_t *dirname, Option_t *option="")
Definition: TDataSetIter.h:102
virtual TString Path()
Definition: TDataSetIter.h:98
virtual TDataSet * operator[](const Char_t *path)
operator [] returns the pointer to the TDataSet if it does contain any data (TTable for example) ...
virtual void Reset(TDataSet *l=0, Int_t depth=0)
TDataSet *l != 0 means the new start pointer depth != 0 means the new value for the depth otherwise t...
virtual TDataSet * Next(const Char_t *path, TDataSet *rootset=0, Bool_t mkdir=kFALSE)
Definition: TDataSetIter.h:109
virtual TDataSet * ls(TString dirname, Option_t *opt="") const
Definition: TDataSetIter.h:93
virtual TDataSet * operator()(const Char_t *path)
Definition: TDataSetIter.h:68
const Option_t * GetOption() const
Definition: TDataSetIter.h:112
virtual ~TDataSetIter()
to be documented
virtual void ls(Option_t *option="") const
// ls(Option_t option) // // option - defines the path to be listed // = "" - means print al...
Definition: TDataSet.cxx:495
virtual TDataSet * FindByName(const Char_t *name, const Char_t *path="", Option_t *opt="")
to be documented
unsigned int UInt_t
Definition: RtypesCore.h:42
virtual TDataSet * Md(const Char_t *dirname)
Definition: TDataSetIter.h:96
TDataSet * fRootDataSet
Definition: TDataSetIter.h:43
TLine * l
Definition: textangle.C:4
virtual Int_t Df() const
Definition: TDataSetIter.h:74
Option_t * GetOption() const
Definition: TCollection.h:160
virtual TDataSet * Pwd(Option_t *opt="") const
Definition: TDataSetIter.h:99
TDataSet * fDataSet
Definition: TDataSetIter.h:42
TDataSet * GetNullSet()
return a fake pointer == -1 casted to (TDataSet *)
virtual TDataSet * Rmdir(TDataSet *dataset, Option_t *option="")
Remove the TDataSet *dataset from the current dataset If the current dataset is the deleted dataset t...
virtual TDataSet * FindDataSet(const Char_t *name, const Char_t *path="", Option_t *opt="")
FindDataSet looks for the object with the name supplied across dataset.
virtual TDataSet * Add(TDataSet *set)
Definition: TDataSetIter.h:61
#define name(a, b)
Definition: linkTestLib0.cpp:5
Mother of all ROOT objects.
Definition: TObject.h:58
char Char_t
Definition: RtypesCore.h:29
virtual TDataSet * Find(const Char_t *path, TDataSet *rootset=0, Bool_t mkdir=kFALSE, Bool_t titleFlag=kFALSE)
// titleFlag = kFALSE; use object name as key (by default) // kTRUE; use object title as key and igno...
virtual void ls(Option_t *dirname="") const
The ls function lists the contents of a class on stdout.
Definition: TDataSetIter.h:92
virtual TString Path() const
return the full path of this data set
Definition: TDataSet.cxx:626
virtual TDataSet * Rmdir(const Char_t *dirname, Option_t *option="")
Definition: TDataSetIter.h:101
TObject * obj
virtual TDataSet * ls(const Char_t *dirname, Int_t depth) const
Definition: TDataSetIter.h:94
TDataSetIter & operator=(const TDataSetIter &)
virtual Int_t GetDepth() const
Definition: TDataSetIter.h:70
virtual TDataSet * operator*() const
operator *