ROOT logo
// @(#)root/table:$Id: TDataSetIter.h 21571 2008-01-03 09:21:42Z brun $
// Author: Valery Fine(fine@mail.cern.ch)   03/07/98

/*************************************************************************
 * Copyright (C) 1995-2006, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOT_TDataSetIter
#define ROOT_TDataSetIter


//////////////////////////////////////////////////////////////////////////
//                                                                      //
//                                                                      //
// TDataSetIter                                                         //
//                                                                      //
// Iterator of TDataSet lists.                                          //
//                                                                      //
// Provides "standard" features of the TIter class for TDataSet object  //
//                             and                                      //
// allows navigating TDataSet structure using the custom "directory"    //
//    notation (see TDataSet::Find(const Char *path) method)            //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#include "TList.h"
#include "TNamed.h"

#include "TDataSet.h"

class TDataSetIter : public TObject{
protected:
   TIter           *fNext;            // "standard" ROOT iterator for containers
   TIter           *fNextSet[100];    // the list of the TList iterators to bypass the whole dataset
   Int_t            fDepth;           // the current depth of the passing
   Int_t            fMaxDepth;        // the max depth of the passing (=1 by default)

   TDataSet        *fDataSet;          // Pointer to the last selected TDataSet
   TDataSet        *fRootDataSet;      // Pointer to the root TDataSet
   TDataSet        *fWorkingDataSet;   // Pointer to the working TDataSet
   TDataSet        *NextDataSet(TIter &next);
   TDataSet        *NextDataSet(Int_t nDataSet);
   TDataSet        *GetNullSet();      // return a fake pointer == -1 casted to (TDataSet *)

   static TDataSet *fgNullDataSet;
public:
   TDataSetIter(TDataSet *l=0, Int_t depth=1, Bool_t dir=kIterForward);
   TDataSetIter(TDataSet *l, Bool_t dir);
   virtual         ~TDataSetIter();

   virtual TDataSet    *Add(TDataSet *set){return Add(set,(TDataSet *)0);}
   virtual TDataSet    *Add(TDataSet *set, const Char_t *path);
   virtual TDataSet    *Add(TDataSet *set, TDataSet *dataset);

   virtual TDataSet    *Cd(const Char_t *dirname);
   virtual TDataSet    *Cd(TDataSet *ds);
   virtual TDataSet    *operator()( TDataSet::EDataSetPass mode=TDataSet::kContinue ) {return  Next(mode);}
   virtual TDataSet    *operator()(const Char_t *path) { return Find(path); }
   virtual TDataSet    *operator[](const Char_t *path);
   virtual Int_t        GetDepth() const {return fDepth;}
   virtual TDataSet    *Cwd() const {return fWorkingDataSet;}
   virtual TDataSet    *Dir(Char_t *dirname);
   virtual Int_t        Du() const;            // summarize dataset usage
   virtual Int_t        Df() const {return 0;} // report number of free "table" blocks.

   virtual TDataSet    *Find(const Char_t *path, TDataSet *rootset=0,Bool_t mkdir=kFALSE,Bool_t titleFlag=kFALSE);
   virtual TDataSet    *FindByPath(const Char_t *path, TDataSet *rootset=0,Bool_t mkdir=kFALSE);
   virtual TDataSet    *FindDataSet(const Char_t *name,const Char_t *path="",Option_t *opt="");
   virtual TDataSet    *FindByName(const Char_t *name,const Char_t *path="",Option_t *opt="");
   virtual TDataSet    *FindByTitle(const Char_t *title,const Char_t *path="",Option_t *opt="");
   virtual TDataSet    *FindDataSet(TDataSet *set,const Char_t *path,Option_t *opt="");
   virtual TDataSet    *FindByPointer(TDataSet *set,const Char_t *path=0,Option_t *opt="");
   virtual TObject     *FindObject(const Char_t *name) const;
   virtual TObject     *FindObject(const TObject *obj) const;

   virtual Int_t        Flag(UInt_t flag=TDataSet::kMark,TDataSet::EBitOpt reset=TDataSet::kSet){return Flag((TDataSet *)0,flag,reset);}
   virtual Int_t        Flag(const Char_t *path,UInt_t flag=TDataSet::kMark,TDataSet::EBitOpt reset=TDataSet::kSet);
   virtual Int_t        Flag(TDataSet *dataset,UInt_t flag=TDataSet::kMark,TDataSet::EBitOpt reset=TDataSet::kSet);

   virtual TDataSet    *Ls(const Char_t *dirname="",Option_t *opt="") const;
   virtual TDataSet    *Ls(const Char_t *dirname,Int_t depth) const;
   virtual void         ls(Option_t *dirname="") const { Ls(dirname,"");}
   virtual TDataSet    *ls(TString dirname,Option_t *opt="") const  {return Ls(dirname.Data(),opt);}
   virtual TDataSet    *ls(const Char_t *dirname,Int_t depth) const {return Ls(dirname,depth);}
   virtual TDataSet    *Mkdir(const Char_t *dirname);
   virtual TDataSet    *Md(const Char_t *dirname)                       {return Mkdir(dirname);}
   virtual TString      Path(const Char_t *path)                        {TDataSet *set = Find(path); return set ? set->Path():TString ("");}
   virtual TString      Path() {return fWorkingDataSet ?  fWorkingDataSet->Path() : TString ("");}
   virtual TDataSet    *Pwd(Option_t *opt="") const                     {if (Cwd()) Cwd()->ls(opt); return Cwd();}
   virtual TDataSet    *Rmdir(TDataSet *dataset,Option_t *option="");
   virtual TDataSet    *Rmdir(const Char_t *dirname,Option_t *option=""){return Rmdir(Find(dirname),option);}
   virtual TDataSet    *Rd(const Char_t *dirname,Option_t *option="")   {return Rmdir(Find(dirname),option);}

   virtual TDataSet    *Shunt(TDataSet *set){return Shunt(set,(TDataSet *)0);}
   virtual TDataSet    *Shunt(TDataSet *set, const Char_t *path);
   virtual TDataSet    *Shunt(TDataSet *set, TDataSet *dataset);

   virtual TDataSet    *Next( TDataSet::EDataSetPass mode=TDataSet::kContinue);
   virtual TDataSet    *Next(const Char_t *path, TDataSet *rootset=0,Bool_t mkdir=kFALSE){return Find(path,rootset,mkdir);}
   virtual Bool_t       Notify() { return TObject::Notify();}
   virtual void         Notify(TDataSet *dataset);
   const  Option_t    *GetOption() const                                { return fNext ? fNext->GetOption():0; }
   virtual void         Reset(TDataSet *l=0,Int_t depth=0);
   virtual TDataSet    *operator *() const ;
   
   ClassDef(TDataSetIter,0) // class-iterator to navigate TDataSet structure
};

#endif

 TDataSetIter.h:1
 TDataSetIter.h:2
 TDataSetIter.h:3
 TDataSetIter.h:4
 TDataSetIter.h:5
 TDataSetIter.h:6
 TDataSetIter.h:7
 TDataSetIter.h:8
 TDataSetIter.h:9
 TDataSetIter.h:10
 TDataSetIter.h:11
 TDataSetIter.h:12
 TDataSetIter.h:13
 TDataSetIter.h:14
 TDataSetIter.h:15
 TDataSetIter.h:16
 TDataSetIter.h:17
 TDataSetIter.h:18
 TDataSetIter.h:19
 TDataSetIter.h:20
 TDataSetIter.h:21
 TDataSetIter.h:22
 TDataSetIter.h:23
 TDataSetIter.h:24
 TDataSetIter.h:25
 TDataSetIter.h:26
 TDataSetIter.h:27
 TDataSetIter.h:28
 TDataSetIter.h:29
 TDataSetIter.h:30
 TDataSetIter.h:31
 TDataSetIter.h:32
 TDataSetIter.h:33
 TDataSetIter.h:34
 TDataSetIter.h:35
 TDataSetIter.h:36
 TDataSetIter.h:37
 TDataSetIter.h:38
 TDataSetIter.h:39
 TDataSetIter.h:40
 TDataSetIter.h:41
 TDataSetIter.h:42
 TDataSetIter.h:43
 TDataSetIter.h:44
 TDataSetIter.h:45
 TDataSetIter.h:46
 TDataSetIter.h:47
 TDataSetIter.h:48
 TDataSetIter.h:49
 TDataSetIter.h:50
 TDataSetIter.h:51
 TDataSetIter.h:52
 TDataSetIter.h:53
 TDataSetIter.h:54
 TDataSetIter.h:55
 TDataSetIter.h:56
 TDataSetIter.h:57
 TDataSetIter.h:58
 TDataSetIter.h:59
 TDataSetIter.h:60
 TDataSetIter.h:61
 TDataSetIter.h:62
 TDataSetIter.h:63
 TDataSetIter.h:64
 TDataSetIter.h:65
 TDataSetIter.h:66
 TDataSetIter.h:67
 TDataSetIter.h:68
 TDataSetIter.h:69
 TDataSetIter.h:70
 TDataSetIter.h:71
 TDataSetIter.h:72
 TDataSetIter.h:73
 TDataSetIter.h:74
 TDataSetIter.h:75
 TDataSetIter.h:76
 TDataSetIter.h:77
 TDataSetIter.h:78
 TDataSetIter.h:79
 TDataSetIter.h:80
 TDataSetIter.h:81
 TDataSetIter.h:82
 TDataSetIter.h:83
 TDataSetIter.h:84
 TDataSetIter.h:85
 TDataSetIter.h:86
 TDataSetIter.h:87
 TDataSetIter.h:88
 TDataSetIter.h:89
 TDataSetIter.h:90
 TDataSetIter.h:91
 TDataSetIter.h:92
 TDataSetIter.h:93
 TDataSetIter.h:94
 TDataSetIter.h:95
 TDataSetIter.h:96
 TDataSetIter.h:97
 TDataSetIter.h:98
 TDataSetIter.h:99
 TDataSetIter.h:100
 TDataSetIter.h:101
 TDataSetIter.h:102
 TDataSetIter.h:103
 TDataSetIter.h:104
 TDataSetIter.h:105
 TDataSetIter.h:106
 TDataSetIter.h:107
 TDataSetIter.h:108
 TDataSetIter.h:109
 TDataSetIter.h:110
 TDataSetIter.h:111
 TDataSetIter.h:112
 TDataSetIter.h:113
 TDataSetIter.h:114