Logo ROOT   6.08/07
Reference Guide
Go to the documentation of this file.
1 // @(#)root/table:$Id$
2 // Author: Valery Fine(fine@mail.cern.ch) 03/07/98
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  *************************************************************************/
12 #ifndef ROOT_TDataSet
13 #define ROOT_TDataSet
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TDataSet //
19 // //
20 // TDataSet class is a base class to implement the directory-like //
21 // data structures and maintain it via TDataSetIter class iterator //
22 // //
23 //////////////////////////////////////////////////////////////////////////
25 #include "TList.h"
26 #include "TObjArray.h"
28 #include "TNamed.h"
29 #include "TNode.h"
31 class TDataSetIter;
32 class TBrowser;
34 class TDataSet : public TNamed
35 {
36 friend class TDataSetIter;
37 public:
38  // The control codes to navigate the TDataSet structure via TDataSet::Pass method
40  typedef enum {
41  kContinue, // continue passing
42  kPrune, // stop passing of the current branch but continue with the next one if any
43  kStop, // break passing
44  kUp, // break passing, return to the previous level, then continue
45  kStruct, // work with structural links only
46  kAll, // work with all links
47  kRefs, // work with refs links only
48  kMarked // work with marked links only
49  } EDataSetPass;
51 private:
52  void operator=(const TDataSet &){}
53 // -- Int_t IncCnt(){ fCnt++; return fCnt;}
54 // -- Int_t DecCnt(){ fCnt--; return fCnt;}
55 // -- Int_t Cnt() { return fCnt;}
56 protected:
57  static TDataSet *fgMainSet; // pointer the main dataset;
58  TDataSet *fParent; // pointer to mother of the directory
59  TSeqCollection *fList; // List of the the the objects included into this dataset
60 // -- Int_t fCnt; // reference counter.
61  virtual void SetMother(TObject *mother) {SetParent((TDataSet*)mother);}
62  TDataSet(const char *name,const char *title):
63  TNamed(name,title),fParent(0),fList(0){} // to support TDictionary
64  void AddMain(TDataSet *set);
65  static EDataSetPass SortIt(TDataSet *ds);
66  static EDataSetPass SortIt(TDataSet *ds,void *user);
68  void MakeCollection();
71 public:
73  //----- dataset flags
74  enum ESetBits {
75  kMark = BIT(22) // if object is marked
76  ,kArray = BIT(20) // if object has TObjArray inside
77  };
79  enum EBitOpt {
82  };
84  TDataSet(const char *name="", TDataSet *parent=0, Bool_t arrayFlag = kFALSE);
85  TDataSet(const TDataSet &src,EDataSetPass iopt=kAll);
86  TDataSet(TNode &src);
87  virtual ~TDataSet();
88  virtual void Add(TDataSet *dataset);
89  virtual void AddAt(TDataSet *dataset,Int_t idx=0);
90  virtual void AddAtAndExpand(TDataSet *dataset, Int_t idx=0);
91  virtual void AddFirst(TDataSet *dataset);
92  virtual void AddLast(TDataSet *dataset);
93  TDataSet *At(Int_t idx) const;
94  virtual void Browse(TBrowser *b);
95  virtual TObject *Clone(const char *newname="") const;
96  virtual void Delete(Option_t *opt="");
97  virtual TDataSet *Find(const char *path) const;
98  virtual TDataSet *FindByName(const char *name,const char *path="",Option_t *opt="") const;
99  virtual TDataSet *FindByPath(const char *path) const;
100  virtual TDataSet *FindByTitle(const char *title,const char *path="",Option_t *opt="") const;
101  TObject *FindObject(const char *name) const {return FindByName(name);}
102  TObject *FindObject(const TObject *o) const { return TObject::FindObject(o);}
103  virtual TDataSet *First() const;
104  TObjArray *GetObjArray() const { return (TObjArray *)fList; }
105  virtual TSeqCollection *GetCollection() const { return (TSeqCollection *)fList; }
106  TList *GetList() const { return (TList *)fList; }
107  virtual Int_t GetListSize() const;
108  static TDataSet *GetMainSet();
109  TObject *GetMother() const { return (TObject*)GetParent();}
110  virtual TObject *GetObject() const;
111  virtual TDataSet *GetParent() const { return fParent;}
112  virtual Long_t HasData() const {return 0;} // Check whether this dataset has extra "data-members"
113  virtual TDataSet *Instance() const;
114  static TDataSet *instance();
115  virtual TString Path() const; // return the "full" path of this dataset
116  virtual EDataSetPass Pass(EDataSetPass ( *callback)(TDataSet *),Int_t depth=0);
117  virtual EDataSetPass Pass(EDataSetPass ( *callback)(TDataSet *,void*),void *user,Int_t depth=0);
118  virtual void PrintContents(Option_t *opt="") const;
119  virtual Int_t Purge(Option_t *opt="");
120  virtual void Remove(TDataSet *set);
121  virtual TDataSet *RemoveAt(Int_t idx);
122  virtual void SetMother(TDataSet *parent=0){SetParent(parent);};
123  virtual void SetObject(TObject *obj);
124  virtual void SetParent(TDataSet *parent=0);
125  virtual void SetWrite();
126  virtual void Shunt(TDataSet *newParent=0);
127  virtual void Sort(); //Sort objects in lexical order
128  virtual Bool_t IsEmpty() const;
129  virtual Bool_t IsFolder() const {return kTRUE;}
130  virtual Bool_t IsMarked() const ;
131  virtual Bool_t IsThisDir(const char *dirname,int len=-1,int ignorecase=0) const ;
132  virtual TDataSet *Last() const;
133  virtual void ls(Option_t *option="") const; // Option "*" means print all levels
134  virtual void ls(Int_t depth) const; // Print the "depth" levels of this datatset
135  void Mark(); // *MENU*
136  void UnMark(); // *MENU*
137  void MarkAll(); // *MENU*
138  void UnMarkAll(); // *MENU*
139  void InvertAllMarks(); // *MENU*
140  void Mark(UInt_t flag,EBitOpt reset=kSet);
141  virtual TDataSet *Next() const;
142  virtual TDataSet *Prev() const;
143  virtual void Update(); // Update dataset
144  virtual void Update(TDataSet *set,UInt_t opt=0);// Update this dataset with the new one
145  virtual Int_t Write(const char *name=0, Int_t option=0, Int_t bufsize=0);
146  virtual Int_t Write(const char *name=0, Int_t option=0, Int_t bufsize=0) const;
147  ClassDef(TDataSet,1) // The base class to create the hierarchical data structures
148 };
150 inline void TDataSet::Add(TDataSet *dataset){ AddLast(dataset); }
151 inline TDataSet *TDataSet::At(Int_t idx) const {return fList ? (TDataSet *)fList->At(idx) : 0; }
152 inline Int_t TDataSet::GetListSize() const {return (fList) ? fList->GetSize():0;}
153 inline TDataSet *TDataSet::instance() { return new TDataSet();}
154 inline Bool_t TDataSet::IsMarked() const { return TestBit(kMark); }
155 inline void TDataSet::Mark(UInt_t flag,EBitOpt reset){ SetBit(flag,reset); }
156 inline void TDataSet::Mark() { Mark(kMark,kSet); }
157 inline void TDataSet::UnMark() { Mark(kMark,kReset); }
160 #endif
virtual Bool_t IsMarked() const
Definition: TDataSet.h:154
void UnMark()
Definition: TDataSet.h:157
virtual void Add(TDataSet *dataset)
Definition: TDataSet.h:150
An array of TObjects.
Definition: TObjArray.h:39
void MarkAll()
Mark all members of this dataset.
Definition: TDataSet.cxx:571
TDataSet(const char *name, const char *title)
Definition: TDataSet.h:62
virtual TObject * Clone(const char *newname="") const
the custom implementation fo the TObject::Clone
Definition: TDataSet.cxx:308
static TDataSet * GetMainSet()
return pointer to the main dataset
Definition: TDataSet.cxx:420
const char Option_t
Definition: RtypesCore.h:62
virtual void ls(Option_t *option="") const
// ls(Option_t <em>option) // // option - defines the path to be listed // = "</em>" - means print al...
Definition: TDataSet.cxx:495
virtual EDataSetPass Pass(EDataSetPass(*callback)(TDataSet *), Int_t depth=0)
// Pass (callback,depth) // // Calls callback(this) for all datasets those recursively // // Paramete...
Definition: TDataSet.cxx:689
Bool_t TestBit(UInt_t f) const
Definition: TObject.h:157
#define BIT(n)
Definition: Rtypes.h:120
TNode description.
Definition: TNode.h:43
virtual TDataSet * Last() const
Return the last object in the list. Returns 0 when list is empty.
Definition: TDataSet.cxx:437
Basic string class.
Definition: TString.h:137
virtual TDataSet * First() const
Return the first object in the list. Returns 0 when list is empty.
Definition: TDataSet.cxx:403
virtual Bool_t IsEmpty() const
return kTRUE if the "internal" collection has no member
Definition: TDataSet.cxx:608
virtual void AddAtAndExpand(TDataSet *dataset, Int_t idx=0)
!!!! Under construction !!!!! Add TDataSet object at the "idx" position in ds or at the end of the da...
Definition: TDataSet.cxx:254
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
virtual void Delete(Option_t *opt="")
Delete - deletes the list of the TDataSet objects and all "Structural Members" as well This method do...
Definition: TDataSet.cxx:320
const Bool_t kFALSE
Definition: Rtypes.h:92
virtual void Remove(TDataSet *set)
Remiove the "set" from this TDataSet.
Definition: TDataSet.cxx:641
TDataSet * GetRealParent()
return real parent
Definition: TDataSet.cxx:166
virtual void Browse(TBrowser *b)
Browse this dataset (called by TBrowser).
Definition: TDataSet.cxx:297
virtual void SetObject(TObject *obj)
The depricated method (left here for the sake of the backward compatibility)
Definition: TDataSet.cxx:480
TDataSet * fParent
Definition: TDataSet.h:58
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition: TObject.cxx:739
virtual TDataSet * FindByName(const char *name, const char *path="", Option_t *opt="") const
Full description see: TDataSetIter::Find.
Definition: TDataSet.cxx:378
virtual TDataSet * Instance() const
apply the class default ctor to instantiate a new object of the same kind.
Definition: TDataSet.cxx:546
Sequenceable collection abstract base class.
void InvertAllMarks()
Invert mark bit for all members of this dataset.
Definition: TDataSet.cxx:593
#define ClassDef(name, id)
Definition: Rtypes.h:254
virtual Int_t Write(const char *name=0, Int_t option=0, Int_t bufsize=0)
To Write object first we should temporary break the the backward fParent pointer (otherwise ROOT foll...
Definition: TDataSet.cxx:893
static EDataSetPass SortIt(TDataSet *ds)
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:33
virtual TDataSet * Next() const
Return the object next to this one in the parent structure This convinient but time-consuming.
Definition: TDataSet.cxx:447
TObject * FindObject(const char *name) const
Must be redefined in derived classes.
Definition: TDataSet.h:101
TDataSet * At(Int_t idx) const
Definition: TDataSet.h:151
Definition: TDataSet.h:40
virtual Bool_t IsThisDir(const char *dirname, int len=-1, int ignorecase=0) const
Compare the name of the TDataSet with "dirname" ignorercase flags indicates whether the comparision i...
Definition: TDataSet.cxx:555
TSeqCollection * fList
Definition: TDataSet.h:59
virtual Bool_t IsFolder() const
Returns kTRUE in case object contains browsable objects (like containers or lists of other objects)...
Definition: TDataSet.h:129
A doubly linked list.
Definition: TList.h:47
Using a TBrowser one can browse all ROOT objects.
Definition: TBrowser.h:41
virtual void SetWrite()
One should not use this method but TDataSet::Write instead This method os left here for the sake of t...
Definition: TDataSet.cxx:797
virtual TObject * FindObject(const char *name) const
Must be redefined in derived classes.
Definition: TObject.cxx:380
virtual TObject * GetObject() const
The depricated method (left here for the sake of the backward compatibility)
Definition: TDataSet.cxx:428
TList * GetList() const
Definition: TDataSet.h:106
static TDataSet * fgMainSet
Definition: TDataSet.h:57
virtual void AddLast(TDataSet *dataset)
Add TDataSet object at the end of the dataset list of this dataset.
Definition: TDataSet.cxx:269
TObjArray * GetObjArray() const
Definition: TDataSet.h:104
unsigned int UInt_t
Definition: RtypesCore.h:42
virtual TDataSet * Find(const char *path) const
Full description see: TDataSetIter::Find.
Definition: TDataSet.cxx:362
static TDataSet * instance()
Definition: TDataSet.h:153
virtual TString Path() const
return the full path of this data set
Definition: TDataSet.cxx:626
virtual TDataSet * FindByTitle(const char *title, const char *path="", Option_t *opt="") const
Full description see: TDataSetIter::Find.
Definition: TDataSet.cxx:394
long Long_t
Definition: RtypesCore.h:50
virtual ~TDataSet()
std::cout << "Default destructor for " << GetName() << " - " << GetTitle() << std::endl; ...
Definition: TDataSet.cxx:213
virtual TDataSet * FindByPath(const char *path) const
Aliase for TDataSet::Find(const Char_t *path) method.
Definition: TDataSet.cxx:347
virtual void AddFirst(TDataSet *dataset)
Add TDataSet object at the beginning of the dataset list of this dataset.
Definition: TDataSet.cxx:283
virtual void SetMother(TDataSet *parent=0)
Definition: TDataSet.h:122
virtual void AddAt(TDataSet *dataset, Int_t idx=0)
Add TDataSet object at the "idx" position in ds or at the end of the dataset The final result is defi...
Definition: TDataSet.cxx:235
virtual Int_t Purge(Option_t *opt="")
Purge - deletes all "dummy" "Structural Members" those are not ended up with some dataset with data i...
Definition: TDataSet.cxx:758
TObject * GetMother() const
Definition: TDataSet.h:109
virtual void Shunt(TDataSet *newParent=0)
Remove the object from the original and add it to dataset TDataSet dataset != 0 - Make this object th...
Definition: TDataSet.cxx:810
virtual void Sort()
Sort recursively all members of the TDataSet with TList::Sort method.
Definition: TDataSet.cxx:874
virtual TObject * At(Int_t idx) const =0
Mother of all ROOT objects.
Definition: TObject.h:37
virtual TDataSet * Prev() const
Return the object that is previous to this one in the parent structure This convinient but time-consu...
Definition: TDataSet.cxx:464
TObject * FindObject(const TObject *o) const
Must be redefined in derived classes.
Definition: TDataSet.h:102
virtual void SetParent(TDataSet *parent=0)
Break the "parent" relationship with the current object parent if present parent != 0 Makes this obje...
Definition: TDataSet.cxx:784
virtual void Update()
Definition: TDataSet.cxx:864
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
Definition: TRolke.cxx:630
void operator=(const TDataSet &)
Definition: TDataSet.h:52
void Mark()
Definition: TDataSet.h:156
virtual Long_t HasData() const
Definition: TDataSet.h:112
virtual Int_t GetSize() const
Definition: TCollection.h:95
const Bool_t kTRUE
Definition: Rtypes.h:91
void UnMarkAll()
UnMark all members of this dataset.
Definition: TDataSet.cxx:582
virtual void PrintContents(Option_t *opt="") const
Callback method to complete ls() method recursive loop This is to allow to sepoarate navigation and t...
Definition: TDataSet.cxx:618
char name[80]
Definition: TGX11.cxx:109
virtual TSeqCollection * GetCollection() const
Definition: TDataSet.h:105
void AddMain(TDataSet *set)
add data set to main data set
Definition: TDataSet.cxx:412
void MakeCollection()
Create the internal container at once if any.
Definition: TDataSet.cxx:221
virtual TDataSet * RemoveAt(Int_t idx)
Remove object from the "idx" cell of this set and return the pointer to the removed object if any...
Definition: TDataSet.cxx:656
virtual TDataSet * GetParent() const
Definition: TDataSet.h:111
virtual Int_t GetListSize() const
Definition: TDataSet.h:152
virtual void SetMother(TObject *mother)
Definition: TDataSet.h:61