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