12 #include "Riostream.h"
14 #include "TDataSetIter.h"
143 TDataSet *TDataSet::fgMainSet = &mainSet;
150 TDataSet::TDataSet(
const Char_t *name,
TDataSet *parent, Bool_t arrayFlag)
151 : TNamed(name,
"TDataSet"),fParent(0),fList(0)
153 if (name && strchr(name,
'/')) {
154 Error(
"TDataSet::TDataSet",
"dataset name (%s) cannot contain a slash", name);
158 if (arrayFlag) SetBit(kArray);
159 if (parent) parent->Add(
this);
169 if (fgMainSet && p == fgMainSet) p = 0;
188 TDataSet::TDataSet(
const TDataSet &pattern,EDataSetPass iopt):TNamed(pattern.GetName(),pattern.GetTitle()),
193 Bool_t optsel = (iopt == kStruct);
194 Bool_t optall = (iopt == kAll);
195 while ((set = next())) {
197 TDataSet *parent = set->GetParent();
198 if ( optall || (optsel && parent ==
this) )
206 TDataSet::TDataSet(TNode &)
224 fList = TestBit(kArray) ? (TSeqCollection *)
new TObjArray : (TSeqCollection *)
new TList;
237 if (!dataset)
return;
243 fList->AddAt(dataset,idx);
256 if (!dataset)
return;
262 if (TestBit(kArray)) ((TObjArray *) fList)->AddAtAndExpand(dataset,idx);
263 else fList->AddAt(dataset,idx);
271 if (!dataset)
return;
277 fList->AddLast(dataset);
285 if (!dataset)
return;
291 fList->AddFirst(dataset);
302 while ((obj = next())) b->Add(obj,obj->GetName());
325 TSeqCollection *thisList = GetCollection();
326 if (!thisList)
return;
328 TIter next(thisList);
331 while ((son = (
TDataSet *)next())) {
332 if ( (!son->TObject::IsOnHeap()) || (
this != son->TDataSet::GetParent()) )
continue;
334 son->TDataSet::SetParent(0);
335 if (son->TDataSet::Last()) { son->TDataSet::Delete(); }
336 son->TObject::SetBit(kCanDelete);
340 thisList->Clear(
"nodelete");
365 return next.
Find(path);
405 if (fList)
return (
TDataSet *)(fList->First());
414 if (fgMainSet && set) fgMainSet->
AddFirst(set);
430 Print(
"***DUMMY GetObject***\n");
439 if (fList)
return (
TDataSet *)(fList->Last());
452 TIter next(parent->GetCollection());
454 while ( (set = (
TDataSet *)next()) && (set !=
this) ){}
470 TIter next(parent->GetCollection());
472 while ( (set = (
TDataSet *)next()) && (set !=
this) ){prev = set;}
482 Print(
"***DUMMY PutObject***\n");
497 if (option && !strcmp(option,
"*"))
ls(Int_t(0));
500 if (option && strlen(option) > 0) {
505 if (set) set->
ls(Int_t(1));
507 if (option) Warning(
"ls",
"Dataset <%s> not found",option);
530 if (!fList || depth == 1 )
return;
531 if (!depth) depth = 99999;
536 TROOT::IncreaseDirLevel();
538 TROOT::DecreaseDirLevel();
558 if (len<0) {
return !strcmp (GetName(),dirname);
559 }
else {
return !strncmp(GetName(),dirname,len);}
561 const char *name = GetName();
562 if (len==-1) len = strlen(dirname);
563 for (
int i=0;i<len;i++) {
if ( tolower(name[i])!=tolower(dirname[i]))
return 0;}
576 while ( (set = nextMark()) ) set->Mark();
587 while ( (set = nextMark()) ) set->Mark(kMark,kReset);
595 if (IsMarked()) Mark(kMark,kReset);
599 while (( set = nextMark()) ) {
600 if (set->IsMarked()) set->Mark(kMark,kReset);
610 return First() ? kFALSE : kTRUE ;
620 Printf(
"%3d - %s\t%s\n",TROOT::GetDirLevel(),(
const char*)
Path(),(
char*)GetTitle());
631 str = parent->
Path();
644 if (set->GetParent() ==
this) set->
SetParent(0);
661 fList->RemoveAt(idx);
662 if (set && (set->GetParent() ==
this) ) set->
SetParent(0);
691 if (!callback)
return kStop;
693 EDataSetPass condition = callback(
this);
695 if (condition == kContinue){
696 if (fList && depth != 1 ) {
699 while ( (d = (
TDataSet *)next()) ) {
700 condition = d->
Pass(callback, depth == 0 ? 0 : --depth);
701 if (condition == kStop || condition == kUp)
break;
705 return condition==kUp ? kContinue:condition;
732 if (!callback)
return kStop;
734 EDataSetPass condition = callback(
this,user);
736 if (condition == kContinue){
737 if (fList && depth != 1 ) {
741 condition = d->
Pass(callback, user, depth == 0 ? 0 : --depth);
742 if (condition == kStop)
break;
743 if (condition == kUp )
break;
747 return (condition==kUp) ? kContinue:condition;
760 if (!fList)
return 0;
765 while ((son = (
TDataSet *)next())) {
766 if (
this == son->GetParent())
continue;
769 if (son->HasData() || son->GetListSize())
continue;
812 if (fParent) fParent->
Remove(
this);
813 if (newParent) newParent->Add(
this);
830 SetTitle(set->GetTitle());
833 while((newset = nextnew())) {
834 Bool_t found = kFALSE;
837 TIter nextold(fList);
838 const Char_t *newname = newset->GetName();
840 while ( ((oldset = (
TDataSet *)nextold())!=0) && !found) {
844 if ( (oldset != newset) && oldset->
IsThisDir(newname) ) {
852 if (!found) newset->
Shunt(
this);
868 while(( set = next())) set->
Update();
879 while ((ds=next())) {
880 list = ds->GetList();
882 list->Sort(); ds->
Sort();
897 Int_t nbytes = TObject::Write(name,option, bufsize);
898 fParent = saveParent;
912 const_cast<TDataSet*
>(
this)->fParent = 0;
913 Int_t nbytes = TObject::Write(name,option, bufsize);
914 const_cast<TDataSet*
>(
this)->fParent = saveParent;
virtual Bool_t IsThisDir(const char *dirname, int len=-1, int ignorecase=0) const
virtual TDataSet * First() const
Return the first object in the list. Returns 0 when list is empty.
void MarkAll()
Mark all members of this dataset.
virtual TDataSet * FindByTitle(const Char_t *title, const Char_t *path="", Option_t *opt="")
to be documented
static TDataSet * GetMainSet()
return pointer to the main dataset
virtual TDataSet * Instance() const
virtual TDataSet * FindByTitle(const char *title, const char *path="", Option_t *opt="") const
virtual TDataSet * FindByPath(const char *path) const
Aliase for TDataSet::Find(const Char_t *path) method.
virtual EDataSetPass Pass(EDataSetPass(*callback)(TDataSet *), Int_t depth=0)
virtual void PrintContents(Option_t *opt="") const
virtual void AddAtAndExpand(TDataSet *dataset, Int_t idx=0)
virtual void Delete(Option_t *opt="")
virtual void Remove(TDataSet *set)
Remiove the "set" from this TDataSet.
virtual TDataSet * Last() const
Return the last object in the list. Returns 0 when list is empty.
TDataSet * GetRealParent()
return real parent
virtual void Browse(TBrowser *b)
Browse this dataset (called by TBrowser).
virtual void SetObject(TObject *obj)
The depricated method (left here for the sake of the backward compatibility)
virtual TObject * Clone(const char *newname="") const
the custom implementation fo the TObject::Clone
void InvertAllMarks()
Invert mark bit for all members of this dataset.
virtual Int_t Write(const char *name=0, Int_t option=0, Int_t bufsize=0)
virtual TDataSet * Prev() const
virtual void ls(Option_t *option="") const
virtual void AddLast(TDataSet *dataset)
Add TDataSet object at the end of the dataset list of this dataset.
virtual TDataSet * FindByName(const Char_t *name, const Char_t *path="", Option_t *opt="")
to be documented
virtual Bool_t IsEmpty() const
return kTRUE if the "internal" collection has no member
virtual TDataSet * Next() const
virtual TObject * GetObject() const
The depricated method (left here for the sake of the backward compatibility)
virtual ~TDataSet()
std::cout << "Default destructor for " << GetName() << " - " << GetTitle() << std::endl; ...
virtual void AddFirst(TDataSet *dataset)
Add TDataSet object at the beginning of the dataset list of this dataset.
virtual void AddAt(TDataSet *dataset, Int_t idx=0)
virtual Int_t Purge(Option_t *opt="")
virtual void Shunt(TDataSet *newParent=0)
virtual void Sort()
Sort recursively all members of the TDataSet with TList::Sort method.
virtual TDataSet * FindByName(const char *name, const char *path="", Option_t *opt="") const
virtual void SetParent(TDataSet *parent=0)
virtual TDataSet * Find(const Char_t *path, TDataSet *rootset=0, Bool_t mkdir=kFALSE, Bool_t titleFlag=kFALSE)
virtual TString Path() const
return the full path of this data set
void UnMarkAll()
UnMark all members of this dataset.
void AddMain(TDataSet *set)
add data set to main data set
void MakeCollection()
Create the internal container at once if any.
virtual TDataSet * Find(const char *path) const
virtual TDataSet * RemoveAt(Int_t idx)