Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

TGo4Iter.cxx

Go to the documentation of this file.
00001 //-------------------------------------------------------------
00002 //        Go4 Release Package v3.04-01 (build 30401)
00003 //                      28-November-2008
00004 //---------------------------------------------------------------
00005 //   The GSI Online Offline Object Oriented (Go4) Project
00006 //   Experiment Data Processing at EE department, GSI
00007 //---------------------------------------------------------------
00008 //
00009 //Copyright (C) 2000- Gesellschaft f. Schwerionenforschung, GSI
00010 //                    Planckstr. 1, 64291 Darmstadt, Germany
00011 //Contact:            http://go4.gsi.de
00012 //----------------------------------------------------------------
00013 //This software can be used under the license agreements as stated
00014 //in Go4License.txt file which is part of the distribution.
00015 //----------------------------------------------------------------
00016 #include "TGo4Iter.h"
00017       
00018 #include "TGo4Slot.h"
00019 #include "TGo4Proxy.h"
00020 
00021 TGo4Iter::TGo4Iter() :
00022     TGo4AccessWrapper(),
00023     fSlot(0),
00024     fLevels(),
00025     fStatus(-1),
00026     fFullName(),
00027     fLevelChange(0)
00028 {
00029 }
00030 
00031 TGo4Iter::TGo4Iter(TGo4Slot* slot, Bool_t onlyslots) :
00032    TGo4AccessWrapper(),
00033    fSlot(slot),
00034    fOnlySlots(onlyslots),
00035    fLevels(),
00036    fStatus(-1),
00037    fFullName(),
00038    fLevelChange(0)
00039 {
00040 }
00041 
00042 TGo4Iter::~TGo4Iter()
00043 {
00044    fLevels.Delete();
00045 }
00046 
00047 Bool_t TGo4Iter::next(Bool_t goesinto)
00048 {
00049    fLevelChange = 0;
00050    
00051    if (fStatus==1) return kFALSE;
00052    
00053    Int_t lastlevel = level();
00054 
00055    TGo4LevelIter* iter = 0;
00056    
00057    Bool_t wasfolder = kFALSE;
00058 
00059    if (fStatus==-1) {
00060       iter = (fSlot==0) ? 0 : fSlot->MakeLevelIter();
00061       if (iter!=0) fLevels.Add(iter);
00062    } else {
00063      iter = (TGo4LevelIter*) fLevels.Last();
00064      
00065      wasfolder = fOnlySlots ? iter->isslotsfolder() : iter->isfolder();
00066      
00067      if ((iter!=0) && wasfolder && goesinto) {
00068        TGo4LevelIter* subiter = iter->subiterator();
00069        if (subiter!=0) {
00070           fLevels.Add(subiter);
00071           iter = subiter;
00072        }
00073      }
00074    }
00075    
00076   while ((iter!=0) && !iter->next()) {
00077     fLevels.Remove(iter);
00078     delete iter;
00079     iter = (TGo4LevelIter*) fLevels.Last();
00080   }
00081   
00082   fFullName="";
00083   
00084   if (iter!=0) 
00085     for(int n=0;n<=fLevels.GetLast();n++) {
00086       TGo4LevelIter* it = (TGo4LevelIter*) fLevels.At(n);
00087       if (n>0) fFullName.Append("/");
00088       fFullName.Append(it->name());
00089     }
00090     
00091   fStatus = (iter!=0) ? 0 : 1;  
00092   
00093   fLevelChange = level() - lastlevel;
00094   
00095   Bool_t isfolder = kFALSE;
00096   if (iter!=0) isfolder = fOnlySlots ? iter->isslotsfolder() : iter->isfolder();
00097   
00098 //  if (isfolder && wasfolder) fLevelChange--;
00099   if (wasfolder) fLevelChange--;
00100     
00101   return (fStatus==0);
00102 }
00103 
00104 Bool_t TGo4Iter::nextobj()
00105 {
00106    while (next()) 
00107       if (!isfolder()) return kTRUE;
00108    return kFALSE;
00109 }
00110       
00111 Bool_t TGo4Iter::isfolder()
00112 {
00113   TGo4LevelIter* iter = currentiter(); 
00114   return (iter==0) ? kFALSE : (fOnlySlots ? iter->isslotsfolder() : iter->isfolder());
00115 }
00116 
00117 const char* TGo4Iter::getname()
00118 {
00119    TGo4LevelIter* iter = currentiter(); 
00120    return iter==0 ? 0 : iter->name();
00121 }
00122 
00123 const char* TGo4Iter::getinfo()
00124 {
00125    TGo4LevelIter* iter = currentiter(); 
00126    return iter==0 ? 0 : iter->info();
00127 }
00128 
00129 Int_t TGo4Iter::getsizeinfo()
00130 {
00131    TGo4LevelIter* iter = currentiter(); 
00132    return iter==0 ? 0 : iter->sizeinfo();
00133 }
00134 
00135 Int_t TGo4Iter::getflag(const char* flagname) 
00136 {
00137    TGo4LevelIter* iter = currentiter(); 
00138    return ((iter==0) || (flagname==0)) ? -1 : iter->getflag(flagname);
00139 }
00140 
00141 Int_t TGo4Iter::getkindofitem()
00142 {
00143    TGo4LevelIter* iter = currentiter(); 
00144    return iter==0 ? -1 : iter->GetKind();
00145 }
00146 
00147 const char* TGo4Iter::getclassname()
00148 {
00149    TGo4LevelIter* iter = currentiter(); 
00150    return iter==0 ? 0 : iter->GetClassName();
00151 }
00152 
00153 
00154 const char* TGo4Iter::getfullname()
00155 {
00156    return (fStatus!=0) ? 0 : fFullName.Data();
00157 }
00158 
00159 Int_t TGo4Iter::level() const
00160 {
00161    return (fStatus!=0) ? -1 : fLevels.GetLast();
00162 }
00163 
00164 TGo4Access* TGo4Iter::ProvideAccess(const char* name)
00165 {
00166    return (fStatus!=0) ? 0 : fSlot->ProvideSlotAccess(fFullName.Data());
00167 }
00168 
00169 TGo4Slot* TGo4Iter::getslot() const
00170 {
00171    if (fStatus!=0) return 0;
00172    TGo4LevelIter* iter = (TGo4LevelIter*) fLevels.Last();
00173    return iter==0 ? 0 : iter->getslot();
00174 }
00175 
00176 //----------------------------END OF GO4 SOURCE FILE ---------------------

Generated on Fri Nov 28 12:59:26 2008 for Go4-v3.04-1 by  doxygen 1.4.2