Logo ROOT   6.12/07
Reference Guide
TDataSetIter.cxx
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-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 #include "Riostream.h"
13 
14 #include "TDataSetIter.h"
15 #include "TBrowser.h"
16 #include "TSystem.h"
17 
18 #ifndef WIN32
19 # ifndef HASSTRCASE
20 # define HASSTRCASE
21 # endif
22 #endif
23 
24 #ifndef HASSTRCASE
25 # define strcasecmp(arg1,arg2) stricmp(arg1,arg2)
26 #endif
27 
29 
31 
32 //////////////////////////////////////////////////////////////////////////
33 // //
34 // TDataSetIter //
35 // //
36 // TDataSetIter is a class iterator to navigate TDataSet objects //
37 // via 4 internal pointers : //
38 // //
39 // 1. fRootDataSet - "root" dataset //
40 // 2. fWorkingDataSet - Working dataset //
41 // 3. fDataSet - the last selected TDataSet //
42 // 4. fNext - TIter for the the list of the "root" dataset //
43 // //
44 //////////////////////////////////////////////////////////////////////////
45 
46 ////////////////////////////////////////////////////////////////////////////////
47 ///to be documented
48 
50 {
52  fMaxDepth = fDepth =1;
54  fNext = link ? new TIter(link->GetCollection() ,dir):0;
55  for(UInt_t i = 0; i < sizeof(fNextSet) / sizeof(TIter*); ++i) {
56  fNextSet[i] = (TIter*)0;
57  }
58 }
59 
60 ////////////////////////////////////////////////////////////////////////////////
61 ///to be documented
62 
64 {
66  fMaxDepth = depth;
67  fDepth = 1;
69  fNext = (link)? new TIter(link->GetCollection() ,dir):0;
70 
71  // Create a DataSet iterator to pass all nodes of the
72  // "depth" levels
73  // of TDataSet *link
74 
75  for(UInt_t i = 0; i < sizeof(fNextSet) / sizeof(TIter*); ++i) {
76  fNextSet[i] = (TIter*)0;
77  }
78  if (fMaxDepth != 1) {
79  fNextSet[0] = fNext;
80  if (fMaxDepth > 100) fMaxDepth = 100;
81  fDepth = 0;
82  }
83 }
84 
85 ////////////////////////////////////////////////////////////////////////////////
86 ///to be documented
87 
89 {
90  if (fMaxDepth != 1) {
91  Int_t level = fDepth;
92  if (level) level--;
93  for (Int_t i = level;i>=0;i--) {
94  TIter *s = fNextSet[i];
95  if (s) delete s;
96  }
97  }
98  else
100  fDepth = 0;
101 }
102 
103 
104 ////////////////////////////////////////////////////////////////////////////////
105 ///operator *
106 
108 {
110 }
111 
112 ////////////////////////////////////////////////////////////////////////////////
113 /// return a fake pointer == -1 casted to (TDataSet *)
114 
116 {
117  return (TDataSet *)fgNullDataSet;
118 }
119 
120 ////////////////////////////////////////////////////////////////////////////////
121 ////////////////////////////////////////////////////////////////////////////////
122 /// //
123 /// Add - adds the set to the dataset defined with the second parameters //
124 /// //
125 /// TDataSet dataset != 0 - Add the set to the TDataSet *dataset //
126 /// //
127 /// = 0 - (by default) to the current TDataSet defined //
128 /// with fWorkingDataSet data member //
129 /// //
130 /// returns the pointer to set is success or ZERO poiner //
131 /// ======= //
132 /// //
133 /// Note: If this TDataSetIter is empty (i.e. Cwd() returns 0), the "set" //
134 /// becomes the "root" dataset of this iterator // //
135 ////////////////////////////////////////////////////////////////////////////////
136 
138 {
139  if (!set) return 0;
140  TDataSet *s = dataset;
141  if (!s) s = Cwd();
142  if (s) {
143  s->Add(set);
144  s = set;
145  }
146  else {
147  // make the coming dataset the current one for the iterator
148  s = set;
149  fRootDataSet = s;
150  fWorkingDataSet = s;
151  if (fNext) {
152  Error("Add","TDataSetIter.has been corrupted ;-!");
153  delete fNext;
154  fNext = 0;
155  }
156  fNext = new TIter(s->GetCollection() );
157  }
158  return s;
159 }
160 
161 ////////////////////////////////////////////////////////////////////////////////
162 ////////////////////////////////////////////////////////////////////////////////
163 /// //
164 /// Add //
165 /// //
166 /// Char_t path != 0 - Add a TDataSet dataset to the TDataSet dataset //
167 /// defined with "path" //
168 /// = 0 - (by default) to the current TDataSet defined //
169 /// with fWorkingDataSet data member //
170 /// //
171 /// returns the dataset is success or ZERO pointer //
172 /// ======= //
173 /// //
174 ////////////////////////////////////////////////////////////////////////////////
175 
176 TDataSet *TDataSetIter::Add(TDataSet *dataset, const Char_t *path)
177 {
178  if (!dataset) return 0;
179  TDataSet *set = 0;
180  if (path && strlen(path)) set = Find(path);
181  return Add(dataset,set);
182 }
183 
184 ////////////////////////////////////////////////////////////////////////////////
185 //////////////////////////////////////////////////////////////////////
186 /// //
187 /// TDataSet *TDataSetIter::Cd(const Char_t *dirname) //
188 /// //
189 /// Change the current working directory to dirname //
190 /// //
191 /// Returns the pointer to the new "working" TDataSet //
192 /// ======= 0, if the new directory doesn't exist. //
193 /// //
194 /// Remark: The name = ".." has a special meaning. //
195 /// ------ TDataSetIter::Cd("..") returns the parent set //
196 /// But one still can not use ".." as a legal part //
197 /// of the full path //
198 //////////////////////////////////////////////////////////////////////
199 
201  TDataSet *set = 0;
202  if (strcmp(dirname,".."))
203  set = Find(dirname);
204  else
205  set = fWorkingDataSet->GetParent();
206  if (set) fWorkingDataSet = set;
207  return set;
208 }
209 
210 ////////////////////////////////////////////////////////////////////////////////
211 //////////////////////////////////////////////////////////////////////
212 /// //
213 /// TDataSet *TDataSetIter::Cd(const TDataSet *ds) //
214 /// //
215 /// Make: Cwd() = ds; //
216 /// Look for the first occurence of the "ds" pointer for the current//
217 /// TDataSet in respect of the Cwd() if any //
218 /// //
219 /// Change the current working directory to ds if present //
220 /// //
221 /// Returns the pointer to the new "working" TDataSet (i.e. ds) //
222 /// ======= 0, if the new directory doesn't exist. //
223 /// //
224 //////////////////////////////////////////////////////////////////////
225 
227 {
228  TDataSet *nextSet = 0;
229  if (Cwd()) {
230  TDataSetIter next(Cwd(),0);
231  while ( (nextSet = next()) )
232  if (ds == nextSet) {fWorkingDataSet = ds; break;}
233  }
234  return nextSet;
235 }
236 
237 ////////////////////////////////////////////////////////////////////////////////
238 ///
239 /// Print the names of the TDataSet objects for the datatset named with "dirname"
240 /// apart of TDataSet::Ls() this method prints one level only
241 ///
242 
244 {
246  if (dirname) set = Find(dirname);
247  if (set) set->ls();
248  return set;
249 }
250 
251 ////////////////////////////////////////////////////////////////////////////////
252 /// summarize dataset usage by Herb Ward proposal
253 
255  if (!fWorkingDataSet) return 0;
257  TDataSet *nextset = 0;
258  Int_t count = 0;
259  while((nextset = (count) ? next():fWorkingDataSet)) {
260  count++;
261  if (nextset->IsFolder()) std::cout << std::endl;
262  TString path = nextset->Path();
263  std::cout << std::setw(2) << next.GetDepth() << ". ";
264  std::cout << path << std::setw(TMath::Max(Int_t(60-strlen(path.Data())),Int_t(0))) << "...";
265  const Char_t *type = nextset->IsFolder() ? "directory" : "table" ;
266  std::cout << std::setw(10) << type;
267  std::cout << " : " << std::setw(10) << nextset->GetTitle();
268  std::cout << std::endl;
269  }
270  return count;
271 }
272 
273 ////////////////////////////////////////////////////////////////////////////////
274 ///to be documented
275 
277 {
278  return FindDataSet(name,path,opt);
279 }
280 
281 ////////////////////////////////////////////////////////////////////////////////
282 ///to be documented
283 
284 TDataSet *TDataSetIter::FindByTitle(const Char_t *title,const Char_t *path,Option_t *opt)
285 {
286  TString optt = "-t";
287  optt += opt;
288  return FindDataSet(title,path,optt.Data());
289 }
290 
291 ////////////////////////////////////////////////////////////////////////////////
292 ///
293 /// FindDataSet looks for the object with the name supplied across dataset.
294 ///
295 /// name - the "base" name title (with no path) of the TDataSet (see: opt = -t)
296 /// path - path to start the search from (the current dataset "by default")
297 /// opt = "-i" - case insensitive search
298 /// "-t" - first <name> parameter defines the object "title" rather the object "name"
299 ///
300 /// Note: If the name provided is not unique
301 /// the first found is returned.
302 ///
303 
305 {
306  if (!name || !name[0]) return 0;
307  if (strchr(name,'/')) {
308  Error("FindDataSet","The name of the object <%s> can not contain any \"/\"",name);
309  return 0;
310  }
311 
312  Bool_t opti = opt ? strcasecmp(opt,"-i") == 0 : kFALSE;
313  Bool_t optt = opt ? strcasecmp(opt,"-t") == 0 : kFALSE;
314 
315  TDataSet *startset = 0;
316  if (path && strlen(path)) startset = Find(path);
317  else startset = fWorkingDataSet;
318  if (!startset) return 0;
319 
320  TDataSet *set = startset;
321  if ( !((opti && strcasecmp( optt ? set->GetTitle() : set->GetName(),name) == 0 ) ||
322  (strcmp(optt ? set->GetTitle() : set->GetName(),name) == 0)) )
323  {
324  TDataSetIter next(startset,0);
325  while ((set = next()))
326  if ( (opti && strcasecmp(optt ? set->GetTitle() : set->GetName(),name) == 0 ) ||
327  (strcmp(optt ? set->GetTitle() : set->GetName(),name) == 0) ) break;
328  }
329 
330  return set;
331 }
332 
333 ////////////////////////////////////////////////////////////////////////////////
334 ///
335 /// Check whether the object does belong the TDataSet defined with "path"
336 /// opt = "-l" - check the "reference" links only
337 /// "-s" - check the "structural" links only
338 /// = "by default" - checks all links
339 ///
340 
342 {
343  if (!set) return 0;
344  if (opt) {/* no used */}
345 
346  TDataSet *startset = 0;
347  if (path) startset = Find(path);
348  else startset = fWorkingDataSet;
349  if (!startset) return 0;
350 
351  TDataSetIter next(startset);
352  TDataSet *nextSet = 0;
353  while ( (nextSet = next()) )
354  if (set == nextSet) break;
355 
356  return nextSet;
357 }
358 ////////////////////////////////////////////////////////////////////////////////
359 /// This method is not recommended.
360 /// It is done to back TObject::FindObject method only.
361 /// One is recommnened to use FindByName method instead.
362 
364 {
365  return ((TDataSetIter *)this)->FindByName(name);
366 }
367 
368 ////////////////////////////////////////////////////////////////////////////////
369 /// This method is not recommended.
370 /// It is done to back TObject::FindObject method only.
371 /// One is recommended to use FindByName method instead.
372 
374 {
375  return ((TDataSetIter *)this)->FindByPointer((TDataSet *)dataset);
376 }
377 ////////////////////////////////////////////////////////////////////////////////
378 ///
379 /// Check whether the object does belong the TDataSet defined with "path"
380 /// opt = "-l" - check the "reference" links only
381 /// "-s" - check the "structural" links only
382 /// = "by default" - checks all links
383 ///
384 
386 {
387  if (!set) return 0;
388 
389  TDataSet *startset = 0;
390  if (path && path[0]) startset = Find(path);
391  else startset = fWorkingDataSet;
392  if (!startset) return 0;
393 
394  TDataSetIter next(startset);
395  TDataSet *nextSet = 0;
396  while ( (nextSet = next()) )
397  if (set == nextSet) break;
398 
399  return nextSet;
400 }
401 
402 ////////////////////////////////////////////////////////////////////////////////
403 ///to be documented
404 
406 {
407  TDataSet *set = Find(path);
408  if (set) set->SetBit(flag,reset);
409  return 0;
410 }
411 ////////////////////////////////////////////////////////////////////////////////
412 ///to be documented
413 
415 {
416  if (dataset) dataset->SetBit(flag,reset);
417  return 0;
418 }
419 
420 ////////////////////////////////////////////////////////////////////////////////
421 ///
422 /// Ls(const Char_t *dirname,Option_t)
423 ///
424 /// Prints the list of the TDataSet defined with dirname
425 ///
426 /// dirname = 0 - prints the current dataset
427 /// dirname[0] = '/' - print TDataSet defined with dirname
428 /// dirname[0] != '/' - prints DataSet with respect of the current class
429 ///
430 
431 TDataSet *TDataSetIter::Ls(const Char_t *dirname,Option_t *opt) const {
432  TDataSet *set= 0;
433  if (dirname && strlen(dirname)) set = ((TDataSetIter*)this)->Find(dirname);
434  if (!set && dirname==0) set=Cwd();
435  if (set) set->ls(opt);
436  return set;
437 }
438 
439 ////////////////////////////////////////////////////////////////////////////////
440 ///
441 /// Ls(const Char_t *dirname,Int_t depth)
442 ///
443 /// Prints the list of the TDataSet defined with dirname
444 /// Returns the dataset defined by "path" or Cwd();
445 ///
446 /// dirname = 0 - prints the current dataset
447 /// dirname[0] = '/' - print TDataSet defined with dirname
448 /// dirname[0] != '/' - prints DataSet with respect of the current class
449 ///
450 /// depth = 0 - print all level of the TDataSet defined with dirname
451 /// > 0 - print depth levels at most of the dirname TDataSet
452 ///
453 
454 TDataSet *TDataSetIter::Ls(const Char_t *dirname,Int_t depth) const {
456  if (dirname && strlen(dirname)) set= ((TDataSetIter*)this)->Find(dirname);
457  if (set) set->ls(depth);
458  return set;
459 }
460 
461 ////////////////////////////////////////////////////////////////////////////////
462 ///to be documented
463 
465 {
466  TDataSet *set = 0;
467  set = Find(dirname,0,kTRUE);
468  if (!fNext) Reset(); // Create a new iterator
469  // If this dataset is first one then make it the root and working
470  if (!fRootDataSet ) fRootDataSet = set;
472  return set;
473 }
474 
475 ////////////////////////////////////////////////////////////////////////////////
476 ///
477 /// Notify(TDataSet *dataset)
478 ///
479 /// This dummy method is called when TDataSetIter::Find dives in "dataset"
480 /// to look for thew next level of the dataset's
481 /// printf("void TDataSetIter::Notify(TDataSet *) level: %d %s\n",fDepth,ds->GetName());
482 ///
483 
485 {
486 }
487 
488 ////////////////////////////////////////////////////////////////////////////////
489 ///
490 /// Remove the TDataSet *dataset from the current dataset
491 /// If the current dataset is the deleted dataset the its parent
492 /// becomes the "current dataset" or 0 if this dataset has no parent.
493 ///
494 /// returns: the "current dataset" pointer
495 ///
496 ///
497 
499 {
500  TDataSet *set = dataset;
501  if (set) {
502  if (set == fWorkingDataSet) {
503  fWorkingDataSet = set->GetParent();
504  }
505  if (set == fRootDataSet) {
506  fRootDataSet = 0;
507  }
508  delete set;
509  }
510  return Cwd();
511 }
512 
513 ////////////////////////////////////////////////////////////////////////////////
514 /////////////////////////////////////////////////////////////////////////////////
515 ///
516 /// returns the pointer the "next" TDataSet object
517 /// = 0 if all objects have been returned.
518 ///
519 /// mode = kContinue - default normal mode
520 /// kPrune - stop passing of the current branch but continue with the next one if any
521 /// kUp - break passing, return to the previous level, then continue
522 /// all other - are treated as "kContinue"
523 ///
524 /////////////////////////////////////////////////////////////////////////////////
525 
527 {
528  if (fMaxDepth==1) fDataSet = fNext ? NextDataSet(*fNext) :0;
529  else {
530  // Check the whether the next level does exist
531  if (fDepth==0) fDepth = 1;
532  if (fDataSet && fDataSet != fgNullDataSet &&
533  (fDepth < fMaxDepth || fMaxDepth ==0) && mode == TDataSet::kContinue )
534  {
535  // create the next level iterator, go deeper
537  // Look for the next level
538  if (list && list->GetSize() ) {
539  fDepth++;
540  if (fDepth >= 100) {
541  Error("Next()"
542  ," too many (%d) nested levels of your TDataSet has been detected",fDepth);
543  return 0;
544  }
545  fNextSet[fDepth-1] = new TIter(list);
546  }
547  }
548 
549  // Pick the next object of the current level
550  TIter *next = fNextSet[fDepth-1];
551  if (next) {
552  fDataSet = 0;
553  if (mode != TDataSet::kUp) fDataSet = NextDataSet(*next);
554 
555  // Go upstair if the current one has been escaped
556  if (!fDataSet) {
557  // go backwards direction
558  while (!fDataSet && fDepth > 1) {
559  fDepth--;
560  delete next;
561  next = fNextSet[fDepth-1];
562  TDataSet *set = NextDataSet(*next);
563  if (set)
564  fDataSet = set;
565  }
566  }
567  }
568  }
569  return (TDataSet *)fDataSet;
570 }
571 ////////////////////////////////////////////////////////////////////////////////
572 ///to be documented
573 
575 {
576  TDataSet *ds = (TDataSet *)next();
577  if (ds) Notify(ds);
578  return ds;
579 }
580 
581 ////////////////////////////////////////////////////////////////////////////////
582 /// Pick the next object of the level provided
583 
585 {
586  TIter *next = fNextSet[nDataSet];
587  if (next) return NextDataSet(*next);
588  return 0;
589 }
590 ////////////////////////////////////////////////////////////////////////////////
591 ///to be documented
592 
594 {
595  return Find(path,rootset,mkdir);
596 }
597 
598 ////////////////////////////////////////////////////////////////////////////////
599 /////////////////////////////////////////////////////////////////////////////////
600 /// //
601 /// titleFlag = kFALSE; use object name as key (by default) //
602 /// kTRUE; use object title as key and ignore mkdirFlag //
603 /// //
604 /// "path" ::= <relative path> | <absolute path> | <empty> //
605 /// //
606 /// "relative path" ::= <dataset name> | <dataset name>/<dataset name> //
607 /// //
608 /// "absolute path" ::= /<relative path> //
609 /// "empty" ::= zero pointer | pointer to zero length string //
610 /// //
611 /// "relative path": the search is done against of fWorkingDataSet data mem //
612 /// "absolute path": the search is done against of fRootDataSet data mem //
613 /// "empty path" : no search is done just next TDataSet is returned if any //
614 /// //
615 /// Remark: This version can not treat any "special name" like "..", ".", etc //
616 /// ------ //
617 /////////////////////////////////////////////////////////////////////////////////
618 
620  Bool_t mkdirflag,Bool_t titleFlag)
621 {
622  TDataSet *dataset=0,*dsnext=0,*ds=0;
623  Int_t len=0,nextlen=0,yes=0,anywhere=0,rootdir=0;
624  const Char_t *name=0,*nextname=0;
625  TSeqCollection *tl=0;
626 
627  name = path;
628  if (!name) return rootset;
629  dataset = rootset;
630  if (!dataset) {// Starting point
631  rootdir = 1999;
632  dataset = (path[0]=='/') ? fRootDataSet:fWorkingDataSet;}
633 
634  if (name[0] == '/') name++;
635 
636  if (!strncmp(name,".*/",3)) {anywhere=1998; name +=3;}
637 
638  len = strcspn(name," /");
639  if (!len) return dataset;
640 
641  if (!dataset) goto NOTFOUND;
642 
643  // Check name of root directory
644  if (rootdir)
645  {
646  nextname = titleFlag ? dataset->GetTitle() : dataset->GetName();
647  nextlen = strlen(nextname);
648  if (nextlen==len && !strncmp(name,nextname,len))
649  return Find(name+len,dataset,mkdirflag,titleFlag);
650  }
651 
652  tl = dataset->GetCollection();
653  if (tl) {
654  TIter next(tl);
655  while ( (dsnext = NextDataSet(next)) )
656  { //horisontal loop
657  nextname = titleFlag ? dataset->GetTitle() : dsnext->GetName();
658  if (!nextname) continue;
659  yes = name[0]=='*'; // wildcard test
660  if (!yes) { // real test
661  nextlen = strlen(nextname);
662  yes = (len == nextlen);
663  if (yes)
664  yes = !strncmp(name,nextname,len);
665  }
666 
667  if (yes)
668  {//go down
669  if (fDepth == 0) fDepth = 1;
670  Notify(dsnext);
671  fDepth++;
672  ds = Find(name+len,dsnext,mkdirflag,titleFlag);
673  fDepth--;
674  if (ds)
675  return ds;
676  }
677 
678  if (!anywhere) continue; // next horizontal
679  ds = Find(name,dsnext,mkdirflag,titleFlag);
680  if (ds)
681  return ds;
682  } // end of while
683  }
684 
685 NOTFOUND:
686  if (mkdirflag && !titleFlag)
687  {
688  // create dir the same type as the type of the fRootDataSet if present
689  // Create TDataSet by default.
690  char buf[512];buf[0]=0; strncat(buf,name,len);
691  if (!fRootDataSet)
692  ds = new TDataSet(buf);
693  else {
694  ds = fRootDataSet->Instance();
695  ds->SetName(buf);
696  }
697 
698  if (!fRootDataSet) fRootDataSet = ds;
699  if (!fWorkingDataSet) fWorkingDataSet = ds;
700  if (dataset)
701  dataset->Add(ds);
702  else {
703  dataset = ds;
704  name +=len;
705  }
706 
707  return Find(name,dataset,mkdirflag);
708  }
709 
710  return 0;
711 }
712 ////////////////////////////////////////////////////////////////////////////////
713 ///
714 /// TDataSet *l != 0 means the new start pointer
715 /// depth != 0 means the new value for the depth
716 /// otherwise the privious one is used;
717 ///
718 
719 void TDataSetIter::Reset(TDataSet *l, int depth)
720 {
722  if (fMaxDepth != 1) {
723  // clean all interators
724  Int_t level = fDepth;
725  if (level) level--;
726  for (int i = level;i>=0;i--) {
727  TIter *s = fNextSet[i];
728  if (s) delete s;
729  }
730  fNext = 0; // this iterator has been deleted in the loop above
731  }
732 
733  fDepth = 0;
734 
735  if (l) {
736  fRootDataSet = l;
737  fWorkingDataSet = l;
738  SafeDelete(fNext);
739  if (fRootDataSet->GetCollection() )
741  }
742  else {
744  if (fNext)
745  fNext->Reset();
746  else if (fRootDataSet && fRootDataSet->GetCollection() )
748  }
749  // set the new value of the maximum depth to bypass
750  if (depth) fMaxDepth = depth;
751 }
752 ////////////////////////////////////////////////////////////////////////////////
753 ////////////////////////////////////////////////////////////////////////////////
754 /// //
755 /// Shunt - moves the set to the dataset defined with the second parameters //
756 /// //
757 /// TDataSet dataset != 0 - Add the set to the TDataSet *dataset //
758 /// //
759 /// = 0 - (by default) to the current TDataSet defined //
760 /// with fWorkingDataSet data member //
761 /// //
762 /// returns the pointer to set if successful or ZERO pointer //
763 /// ======= //
764 /// //
765 /// Note: If this TDataSetIter is empty (i.e. Cwd() returns 0), the "set" //
766 /// becomes the "root" dataset of this iterator // //
767 ////////////////////////////////////////////////////////////////////////////////
768 
770 {
771  if (!set) return 0;
772  TDataSet *s = dataset;
773  if (!s) s = Cwd();
774  if (s) {
775  s->Shunt(set);
776  s = set;
777  }
778  else {
779  // make the coming dataset the current one for the iterator
780  s = set;
781  fRootDataSet = s;
782  fWorkingDataSet = s;
783  if (fNext) {
784  Error("Shunt","TDataSetIter.has been corrupted ;-!");
785  delete fNext;
786  fNext = 0;
787  }
788  fNext = new TIter(s->GetCollection() );
789  }
790  return s;
791 }
792 
793 ////////////////////////////////////////////////////////////////////////////////
794 ////////////////////////////////////////////////////////////////////////////////
795 /// //
796 /// Shunt //
797 /// //
798 /// Char_t path != 0 - Move a TDataSet dataset from its parent to //
799 /// the TDataSet dataset //
800 /// defined with "path" //
801 /// = 0 - (by default) to the current TDataSet defined //
802 /// with fWorkingDataSet data member //
803 /// //
804 /// returns the dataset is success or ZERO pointer //
805 /// ======= //
806 /// //
807 ////////////////////////////////////////////////////////////////////////////////
808 
810 {
811  if (!dataset) return 0;
812  TDataSet *set = 0;
813  if (path && strlen(path)) set = Find(path);
814  return Shunt(dataset,set);
815 }
816 
817 ////////////////////////////////////////////////////////////////////////////////
818 ///
819 /// operator [] returns the pointer to the TDataSet if it does contain
820 /// any data (TTable for example)
821 ///
822 /// Input:
823 /// path = The path to the dataset to find
824 ///
825 /// Output:
826 /// pointer to the dataset if it found and
827 /// its TDataSet::HasData() method returns non-zero
828 /// (see for example TTable::HasData() )
829 
831 {
832  TDataSet *dataSet = Find(path);
833  if (dataSet && dataSet->HasData()) return dataSet;
834  return 0;
835 }
virtual Bool_t Notify()
This method must be overridden to handle object notification.
Definition: TDataSetIter.h:110
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
virtual Int_t GetDepth() const
Definition: TDataSetIter.h:70
virtual void Add(TDataSet *dataset)
Definition: TDataSet.h:150
TDataSet(const char *name, const char *title)
Definition: TDataSet.h:62
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
virtual TDataSet * Shunt(TDataSet *set)
Definition: TDataSetIter.h:104
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 void SetName(const char *name)
Set the name of the TNamed.
Definition: TNamed.cxx:140
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:125
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
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...
void Reset()
Definition: TCollection.h:250
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition: TObject.cxx:694
TDataSet * NextDataSet(TIter &next)
to be documented
TDataSet * fWorkingDataSet
Definition: TDataSetIter.h:44
virtual TDataSet * Instance() const
apply the class default ctor to instantiate a new object of the same kind.
Definition: TDataSet.cxx:546
#define SafeDelete(p)
Definition: RConfig.h:509
Sequenceable collection abstract base class.
EDataSetPass
Definition: TDataSet.h:40
Int_t fMaxDepth
Definition: TDataSetIter.h:40
static TDataSet * fgNullDataSet
Definition: TDataSetIter.h:49
virtual Bool_t IsFolder() const
Returns kTRUE in case object contains browsable objects (like containers or lists of other objects)...
Definition: TDataSet.h:129
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 Int_t Du() const
summarize dataset usage by Herb Ward proposal
virtual ~TDataSetIter()
to be documented
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 void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:880
virtual TDataSet * Find(const char *path) const
Full description see: TDataSetIter::Find.
Definition: TDataSet.cxx:362
TDataSet * fRootDataSet
Definition: TDataSetIter.h:43
virtual TString Path() const
return the full path of this data set
Definition: TDataSet.cxx:626
const Bool_t kFALSE
Definition: RtypesCore.h:88
TDataSet * fDataSet
Definition: TDataSetIter.h:42
#define ClassImp(name)
Definition: Rtypes.h:359
int type
Definition: TGX11.cxx:120
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...
static constexpr double s
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 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 TDataSet * Add(TDataSet *set)
Definition: TDataSetIter.h:61
Mother of all ROOT objects.
Definition: TObject.h:37
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...
auto * l
Definition: textangle.C:4
Short_t Max(Short_t a, Short_t b)
Definition: TMathBase.h:200
virtual TDataSet * Ls(const Char_t *dirname="", Option_t *opt="") const
Ls(const Char_t *dirname,Option_t)
virtual Long_t HasData() const
Definition: TDataSet.h:112
virtual Int_t GetSize() const
Definition: TCollection.h:180
const char rootdir[]
const Bool_t kTRUE
Definition: RtypesCore.h:87
virtual TDataSet * Cwd() const
Definition: TDataSetIter.h:71
virtual TObject * FindObject(const Char_t *name) const
This method is not recommended.
char name[80]
Definition: TGX11.cxx:109
virtual TSeqCollection * GetCollection() const
Definition: TDataSet.h:105
virtual TDataSet * operator*() const
operator *
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:48
virtual TDataSet * GetParent() const
Definition: TDataSet.h:111
const char * Data() const
Definition: TString.h:345