Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

NavItr.cxx

Go to the documentation of this file.
00001 
00002 // $Id: NavItr.cxx,v 1.11 2003/03/25 07:43:40 west Exp $
00003 //
00004 // NavItr
00005 //
00006 // Package: Nav (Navigational Model).
00007 
00008 // Begin_Html<img src="../../pedestrians.gif" align=center>
00009 // <a href="../source_warning.html">Warning for beginners</a>.<br>
00010 // Also see <a href="../../root_crib/index.html">The ROOT Crib</a> and
00011 // <a href="../index.html">The MINOS Class User Guide</a>End_Html
00012 //
00013 // N. West 03/20000
00014 //
00015 //   
00016 // Purpose: 
00017 //
00018 //
00020 
00021 #include <string.h>
00022 #include "MessageService/MsgService.h"
00023 #include "LeakChecker/Lea.h"
00024 #include "Navigation/NavItr.h"
00025 #include "Navigation/NavPrimer.h"
00026 #include "Navigation/NavSet.h"
00027 #include "Lattice/Lattice.h"
00028 #include "TCollection.h"
00029 #include "TClass.h"
00030 
00031 
00032 ClassImp(NavItr)
00033 
00034 //   Definition of static data members
00035 //   *********************************
00036 
00037 CVSID("$Id: NavItr.cxx,v 1.11 2003/03/25 07:43:40 west Exp $");
00038 
00039 
00040 // Definition of member functions (alphabetical order)
00041 // ***************************************************
00042 
00043 //.....................................................................
00044 
00045 void NavItr:: Attach(const TCollection* source,  
00046                     const Text_t* classname, 
00047                     Int_t offset) {
00048 //
00049 //
00050 //  Purpose:  Attach iterator to TCollection.
00051 //
00052 //  Arguments: 
00053 //    source       in    source set for iterator.
00054 //    classname    in    Name of class associated with NavItr.
00055 //    offset       in    Pointer offset: Object adr - TObject adr
00056 //
00057 //  Return:    n/a
00058 //
00059 //  Contact:   N. West
00060 //
00061 //  Specification:-
00062 //  =============
00063 //
00064 //  o Disconnect any existing collection.
00065 //
00066 //  o Create new NavSet derived from a TCollection and attach it.
00067 
00068 
00069 //  Program Notes:-
00070 //  =============
00071 
00072 //  Can be called from ctor so long as fSet has been set to zero.
00073 
00074   Disconnect();
00075   Init();
00076 
00077 //    NavSet will check that the supplied TCollection really does 
00078 //    exist and contains the correct class.
00079 
00080   fSet = new NavSet(source, classname, offset);
00081   Connect();
00082 
00083 }
00084 
00085 //.....................................................................
00086 
00087 void NavItr::Connect() {
00088 //
00089 //
00090 //  Purpose:  Connect to current NavSet (if any)
00091 //
00092 //  Arguments: n/a
00093 //
00094 //  Return:    n/a
00095 //
00096 //  Contact:   N. West
00097 //
00098 //  Specification:-
00099 //  =============
00100 //
00101 //  o If current NavSet exists connect to it.
00102 //
00103 //  o Set up as a rank 0 iterator.
00104 
00105 
00106 //  Program Notes:-
00107 //  =============
00108 
00109 // None.
00110 
00111   if ( fSet ) fSet->Attach(this);
00112   Init(fSet);
00113 
00114 }
00115 //.....................................................................
00116 
00117 NavItr& NavItr::Copy(const NavItr& from) {
00118 //
00119 //
00120 //  Purpose:  Replace current state with from object.
00121 //
00122 //  Arguments: 
00123 //    from         in    Object whose state is to be copied.
00124 //
00125 //  Return:    
00126 //
00127 //  Contact:   N. West
00128 //
00129 //  Specification:-
00130 //  =============
00131 //
00132 //  o Detach object from current NavSet (if any).
00133 //
00134 //  o Copy state from input object and reconnect to new NavSet.
00135 
00136 //  Program Notes:-
00137 //  =============
00138 
00139 //  None.
00140 
00141   Disconnect();
00142   fSet         = from.fSet;
00143   Connect();
00144   fDefaultStep = from.fDefaultStep;
00145   fIndex       = from.fIndex;
00146   fLimLo       = from.fLimLo;
00147   fLimHi       = from.fLimHi;
00148   fRank        = from.fRank;
00149   fZoneLo      = from.fZoneLo;
00150   fZoneHi      = from.fZoneHi;
00151 
00152   return *this;
00153 
00154 }
00155 
00156 //.....................................................................
00157 
00158  Bool_t NavItr::Decrement() {
00159 //
00160 //
00161 //  Purpose:  Decrement pointer skipping unwanted objects.
00162 //
00163 //  Arguments: None.
00164 //
00165 //  Return: kTRUE if pointer is positioned on a valid object.  
00166 //
00167 //  Contact:   N. West
00168 //
00169 //  Specification:-
00170 //  =============
00171 //
00172 //  o  Decrement pointer skipping unwanted objects.
00173 
00174 //  Program Notes:-
00175 //  =============
00176 
00177 //  None.
00178 
00179    fIndex--;
00180    return IsValid();
00181 
00182 }
00183 //.....................................................................
00184 
00185 void NavItr::Disconnect() {
00186 //
00187 //
00188 //  Purpose:  Disconnect from current NavSet (if any)
00189 //
00190 //  Arguments: n/a
00191 //
00192 //  Return:    n/a
00193 //
00194 //  Contact:   N. West
00195 //
00196 //  Specification:-
00197 //  =============
00198 //
00199 //  o If connected to a NavSet, and disconnecting leave it ownerless
00200 //    then delete it.
00201 
00202 
00203 //  Program Notes:-
00204 //  =============
00205 
00206 //  A single NavSet can be shared by any number of NavItrs, hence
00207 //  this reference counting logic.
00208 
00209   if ( fSet && ! fSet->Detach(this) ) delete fSet;
00210   Init();
00211  
00212 }
00213 
00214 //.....................................................................
00215 
00216 NavKey NavItr::GetNavKey() const {
00217 //
00218 //
00219 //  Purpose:  Return associated NavKey.
00220 //
00221 //  Arguments: None.
00222 //
00223 //  Return:  Return associated NavKey or NavKey(0) if none. 
00224 //
00225 //  Contact:   N. West
00226 //
00227 //  Specification:-
00228 //  =============
00229 //
00230 //  o Return associated NavKey or NavKey(0) if none. 
00231 
00232 //  Program Notes:-
00233 //  =============
00234 
00235 //  None.
00236 
00237   return ( fSet && IsValid() ) ? fSet->GetNavKey(fIndex,fRank) : 0;
00238 
00239 }
00240 
00241 //.....................................................................
00242 
00243 void NavItr::GetZone() const {
00244 //
00245 //
00246 //  Purpose:  Get zone limits into fZoneLo, fZoneHi cache.
00247 //
00248 //  Arguments: none.
00249 //
00250 //  Return:   n/a
00251 //
00252 //  Contact:   N. West
00253 //
00254 //  Specification:-
00255 //  =============
00256 //
00257 //  o Get zone limits into fZoneLo, fZoneHi cache.
00258 
00259 //  Program Notes:-
00260 //  =============
00261 
00262 //  The zone limits is the range of indeces containing the current
00263 //  index and bounded by (fLimLo,fLimHi) within which the associated
00264 //  NavKey has a single value.  Finding zone limits is an expensive
00265 //  operation so they are cached in fZoneLo, fZoneHi and reused if
00266 //  possible.  Consequently these members are not really true state
00267 //  but just an optimisation so this const member function is allowed
00268 //  to modify them.
00269 
00270   if (    fZoneLo <= fIndex
00271        && fZoneHi >= fIndex ) return;
00272 
00273   Int_t lo = fLimLo;
00274   Int_t hi = fLimHi;
00275   if ( fSet ) fSet->GetZone(fLimLo,fLimHi,fIndex,fRank,lo,hi);
00276   
00277 // Allow write access (see Program Notes).
00278   NavItr* itr = const_cast<NavItr*>(this);
00279   itr->fZoneLo = lo;
00280   itr->fZoneHi = hi;
00281 
00282 }
00283 
00284 //.....................................................................
00285 
00286  Bool_t NavItr::Increment() {
00287 //
00288 //
00289 //  Purpose:  Increment pointer skipping unwanted objects.
00290 //
00291 //  Arguments: None.
00292 //
00293 //  Return: kTRUE if pointer is positioned on a valid object.  
00294 //
00295 //  Contact:   N. West
00296 //
00297 //  Specification:-
00298 //  =============
00299 //
00300 //  o  Increment pointer skipping unwanted objects.
00301 
00302 //  Program Notes:-
00303 //  =============
00304 
00305 //  None.
00306 
00307    fIndex++;
00308    return IsValid();
00309 
00310 }
00311 //.....................................................................
00312 
00313 void NavItr::Init(NavSet* set) {
00314 //
00315 //
00316 //  Purpose:  Initialise an empty object.
00317 //
00318 //  Arguments: 
00319 //      set      in    Associated NavSet (if any).
00320 //
00321 //  Return:    n/a
00322 //
00323 //  Contact:   N. West
00324 //
00325 //  Specification:-
00326 //  =============
00327 //
00328 //  o Initialise an empty object.
00329 
00330 //  Program Notes:-
00331 //  =============
00332 
00333 //  None.
00334 
00335   fIndex       = 0;
00336   fLimLo       = 0;
00337   if ( set ) fLimHi = fSet->GetMaxIndex();
00338   else       fLimHi = -1;
00339   fSet         = set;
00340   fRank        = 0;
00341   fZoneLo      = 0;
00342   fZoneHi      = -1;
00343   fDefaultStep = 1;
00344 }
00345 
00346 //.....................................................................
00347 
00348 Bool_t NavItr::IsValid(Int_t index) const{
00349 
00350 
00351 //  Purpose:  Check if index is valid (i.e. within selected range).
00352 //
00353 //  Arguments: 
00354 //    index        in    Index to be checked.
00355 //
00356 //  Return:    
00357 //
00358 //  Contact:   N. West
00359 //
00360 //  Specification:-
00361 //  =============
00362 //
00363 //  o Check if index is valid.
00364 
00365 //  Program Notes:-
00366 //  =============
00367 
00368 //  None.
00369 
00370   return index >= fLimLo && index <= fLimHi;
00371 
00372 }
00373 
00374 //.....................................................................
00375 
00376 void* NavItr::Map(const void* far) {
00377 
00378 
00379 //  Purpose:  Select objects associated with supplied object
00380 //            on far side of Lattice.
00381 //
00382 //  Arguments: 
00383 //    far          in    Far side object.
00384 //
00385 //  Return:   First object in the set or = 0 if none. 
00386 //
00387 //  Contact:   N. West
00388 //
00389 //  Specification:-
00390 //  =============
00391 //
00392 //  o Select the objects associated with the Lattice far object and 
00393 //    return the first of them.
00394 
00395 //  Program Notes:-
00396 //  =============
00397 
00398 //  CAUTION: This member function directly effects the associated
00399 //           NavSet and causes all its iterators to reposition at 
00400 //           start of their range.  This would be more apparent if
00401 //           the user did the longer equivalent:-
00402 //
00403 //           XxxItr* myItr;
00404 //           myItr->GetSet()->Map(far);
00405 //           Xxx* myObj = myItrPtr();
00406 
00407   fSet->Map(far);
00408   return Ptr();
00409 
00410 }
00411 
00412 //.....................................................................
00413 
00414 NavItr::NavItr(const Text_t* classname, Int_t offset) {
00415 //
00416 //
00417 //  Purpose:  Construct iterator over TCollection.
00418 //
00419 //  Arguments: 
00420 //    classname    in    Name of class associated with NavItr.
00421 //    offset       in    Pointer offset: Object adr - TObject adr
00422 //
00423 //  Return:   n/a
00424 //
00425 //  Contact:   N. West
00426 //
00427 //  Specification:-
00428 //  =============
00429 //
00430 //  o Ask NavPrimer for the default TCollection for this type of
00431 //    object.
00432 //
00433 //  o Create new NavSet derived from a TCollection and attach it.
00434 
00435 //  Program Notes:-
00436 //  =============
00437 
00438 //  None.
00439 
00440   LEA_CTOR  //Leak Checker
00441 
00442   Init();
00443 
00444   const TCollection* source = NavPrimer::Instance()->
00445                               FindTCollection(classname);
00446   if ( source ) {
00447     fSet = new NavSet(source, classname, offset);
00448     Connect();
00449   }
00450 
00451 }
00452 //.....................................................................
00453 
00454 NavItr::NavItr() {
00455 //
00456 //
00457 //  Purpose:  Default constructor.
00458 //
00459 //  Arguments: 
00460 //    None.
00461 //
00462 //  Return:   n/a
00463 //
00464 //  Contact:   N. West
00465 //
00466 //  Specification:-
00467 //  =============
00468 //
00469 //  o Default constructor.
00470 
00471 //  Program Notes:-
00472 //  =============
00473 
00474 //  None.
00475 
00476   LEA_CTOR  //Leak Checker
00477 
00478   Init();
00479 
00480 }
00481 //.....................................................................
00482 
00483 NavItr::NavItr(const NavItr& from, Bool_t subSlice) {
00484 //
00485 //
00486 //  Purpose:  Copy or sub-slice constructor.
00487 //
00488 //  Arguments: 
00489 //    from      in    Iterator to be copied from
00490 //    subSlice  in    = kFALSE (default) to make copy
00491 //                    = kTRUE to form a subslice
00492 //
00493 //  Return:   n/a
00494 //
00495 //  Contact:   N. West
00496 //
00497 //  Specification:-
00498 //  =============
00499 //
00500 //  o Copy or sub-slice constructor.
00501 
00502 //  Program Notes:-
00503 //  =============
00504 
00505 //  None.
00506 
00507   LEA_CTOR  //Leak Checker
00508 
00509   Init();
00510   if ( subSlice) SubSlice(from);
00511   else           Copy(from);
00512 
00513 }
00514 //.....................................................................
00515 
00516 NavItr::NavItr(const TIter* sourceItr,  
00517                const Text_t* classname, 
00518                Int_t offset) {
00519 //
00520 //
00521 //  Purpose:  Construct iterator over TCollection.
00522 //
00523 //  Arguments: 
00524 //    sourceItr    in    source set TIter for iterator.
00525 //    classname    in    Name of class associated with NavItr.
00526 //    offset       in    Pointer offset: Object adr - TObject adr
00527 //
00528 //  Return:    n/a
00529 //
00530 //  Contact:   N. West
00531 //
00532 //  Specification:-
00533 //  =============
00534 //
00535 //  o Create new NavSet derived from a TCollection and attach it.
00536 
00537 
00538 //  Program Notes:-
00539 //  =============
00540 
00541 //  None.
00542 
00543   LEA_CTOR  //Leak Checker
00544 
00545   Init();
00546 
00547 //    NavSet will check that the supplied TCollection really does 
00548 //    exist and contains the correct class.
00549 
00550   const TCollection* source = sourceItr->GetCollection();
00551   fSet = new NavSet(source, classname, offset);
00552   Connect();
00553 
00554 }
00555 //.....................................................................
00556 
00557 NavItr::NavItr(const TCollection* source,  
00558                const Text_t* classname, 
00559                Int_t offset) {
00560 //
00561 //
00562 //  Purpose:  Construct iterator over TCollection.
00563 //
00564 //  Arguments: 
00565 //    source       in    source set for iterator.
00566 //    classname    in    Name of class associated with NavItr.
00567 //    offset       in    Pointer offset: Object adr - TObject adr
00568 //
00569 //  Return:    n/a
00570 //
00571 //  Contact:   N. West
00572 //
00573 //  Specification:-
00574 //  =============
00575 //
00576 //  o Create new NavSet derived from a TCollection and attach it.
00577 
00578 
00579 //  Program Notes:-
00580 //  =============
00581 
00582 //  None.
00583 
00584   LEA_CTOR  //Leak Checker
00585 
00586 // Clear fSet (Attach only assumes this data member is defined)
00587   fSet = 0;
00588 
00589   Attach(source,classname,offset);
00590 
00591 }
00592 
00593 //.....................................................................
00594 
00595 NavItr::NavItr(const Text_t* classname,
00596                const Text_t* farclass,
00597                Int_t rship) {
00598 //
00599 //
00600 //  Purpose:  Construct iterator over Lattice.
00601 //
00602 //  Arguments: 
00603 //    classname    in    Name of class associated with NavItr.
00604 //    farclass     in    Name of class on far side of Lattice.
00605 //    rship        in    Relationship number or 0.
00606 //
00607 //  Return:   
00608 //
00609 //  Contact:   N. West
00610 //
00611 //  Specification:-
00612 //  =============
00613 //
00614 //  o Ask NavPrimer for the default Lattice for this type of object
00615 //    in specified relationship with farclass objects.
00616 //
00617 //  o Create new NavSet derived from one side of a Lattice and attach it.
00618 
00619 //  Program Notes:-
00620 //  =============
00621 
00622 //  None.
00623 
00624   LEA_CTOR  //Leak Checker
00625 
00626   Init();
00627 
00628   NavPrimer* primer = NavPrimer::Instance();
00629 
00630   NavSet::ESide side = NavSet::kLeft;
00631   const Lattice* source = primer
00632                           ->FindLattice(classname, farclass, rship);
00633 
00634 // If cannot find Lattice with class on left, try on right.
00635 
00636   if ( ! source ) {
00637     side = NavSet::kRight;
00638     source = primer->FindLattice(farclass, classname, rship);
00639   }
00640 
00641   if ( source ) {
00642     fSet = new NavSet(source, (NavSet::ESide) side);
00643     Connect();
00644   }
00645   else {
00646     MSG("Nav", Msg::kWarning) << "Cannot find Lattice for" 
00647        << classname << ":" << farclass << endl;
00648   }
00649 
00650 }
00651 //.....................................................................
00652 
00653 NavItr::NavItr(const Lattice* source,
00654                const Text_t* classname,
00655                ESide side){
00656 //
00657 //
00658 //  Purpose:  Construct iterator over Lattice.
00659 //
00660 //  Arguments: 
00661 //    source       in    Source relationship set
00662 //    classname    in    Name of class associated with NavItr.
00663 //    side         in    Side of reltionship (either kLeft or kRight).
00664 //
00665 //  Return:    n/a
00666 //
00667 //  Contact:   N. West
00668 //
00669 //  Specification:-
00670 //  =============
00671 //
00672 //  o Create new NavSet derived from one side of a Lattice and attach it.
00673 
00674 
00675 //  Program Notes:-
00676 //  =============
00677 
00678 //  None.
00679 
00680   LEA_CTOR  //Leak Checker
00681 
00682   MSG("Nav", Msg::kVerbose) << "Creating iterator over Lattice for" 
00683                             << classname << endl;
00684 
00685   Init();
00686 
00687   fSet = new NavSet(source, (NavSet::ESide) side);
00688   Connect();
00689 
00690 }
00691 //.....................................................................
00692 
00693 NavItr::~NavItr() {
00694 //
00695 //
00696 //  Purpose:  Destructor.
00697 //
00698 //  Arguments: 
00699 //    None.
00700 //
00701 //  Return:   n/a
00702 //
00703 //  Contact:   N. West
00704 //
00705 //  Specification:-
00706 //  =============
00707 //
00708 //  o Destructor.
00709 
00710 //  Program Notes:-
00711 //  =============
00712 
00713 //  None.
00714 
00715   LEA_DTOR  //Leak Checker
00716 
00717     Disconnect();
00718 
00719 }
00720 //.....................................................................
00721 
00722  Bool_t NavItr::NextKey() {
00723 //
00724 //
00725 //  Purpose:  Increment pointer skipping unwanted objects until
00726 //            associated NavKey changes value.
00727 //
00728 //  Arguments: None.
00729 //
00730 //  Return: kTRUE if pointer is positioned on a valid object.  
00731 //
00732 //  Contact:   N. West
00733 //
00734 //  Specification:-
00735 //  =============
00736 //
00737 //  o  Increment pointer skipping unwanted objects until
00738 //     associated NavKey changes value.
00739 
00740 //  Program Notes:-
00741 //  =============
00742 
00743 //  None.
00744 
00745   GetZone();
00746   fIndex = fZoneHi+1;
00747   return IsValid();
00748 
00749 }
00750 
00751 //.....................................................................
00752 
00753 void NavItr::NotReady(const char* mem) const {
00754 //
00755 //
00756 //  Purpose:  Warning for unimplemented member functions.
00757 //
00758 //  Arguments: 
00759 //    mem          in    Member function name.
00760 //
00761 //  Return:    
00762 //
00763 //  Contact:   N. West
00764 //
00765 //  Specification:-
00766 //  =============
00767 //
00768 //  o Display error message giving name of unimplemented member
00769 //    function.
00770 
00771 //  Program Notes:-
00772 //  =============
00773 
00774 //  None.
00775 
00776   MSG("Nav", Msg::kError) << "Sorry, member function NavItr:::" << mem
00777                           << " is not yet ready" << endl;
00778 
00779 }
00780 //.....................................................................
00781 
00782 void* NavItr::operator*() const {
00783 //
00784 //
00785 //  Purpose:  Return object pointer at current index if valid.
00786 //
00787 //  Arguments: None
00788 //
00789 //  Return:    Object pointer, or 0 if current index invalid.
00790 //
00791 //  Contact:   N. West
00792 //
00793 //  Specification:-
00794 //  =============
00795 //
00796 //  o 
00797 
00798 //  Program Notes:-
00799 //  =============
00800 
00801 //  None.
00802 
00803   return ( IsValid() ) ? fSet->At(fIndex) : 0;
00804 
00805 }
00806 //.....................................................................
00807 
00808  Bool_t NavItr::PrevKey() {
00809 //
00810 //
00811 //  Purpose:  Decrement pointer skipping unwanted objects until
00812 //            associated NavKey changes value.
00813 //
00814 //  Arguments: None.
00815 //
00816 //  Return: kTRUE if pointer is positioned on a valid object.  
00817 //
00818 //  Contact:   N. West
00819 //
00820 //  Specification:-
00821 //  =============
00822 //
00823 //  o  Decrement pointer skipping unwanted objects until
00824 //     associated NavKey changes value.
00825 
00826 //  Program Notes:-
00827 //  =============
00828 
00829 //  None.
00830 
00831   GetZone();
00832   fIndex = fZoneLo-1;
00833   return IsValid();
00834 
00835 }
00836 
00837 //.....................................................................
00838 
00839 void* NavItr::Ptr(Bool_t warnIfNull) const {
00840 //
00841 //
00842 //  Purpose:  Return pointer to object at current index.
00843 //
00844 //  Arguments: 
00845 //    warnIfNull   in    = kTRUE to give warning if null.
00846 //
00847 //  Return:    Object pointer, or 0 if current index invalid.
00848 //
00849 //  Contact:   N. West
00850 //
00851 //  Specification:-
00852 //  =============
00853 //
00854 //  o Return pointer to object at current index.  If required issue
00855 //    warning if pointer is null.
00856 
00857 //  Program Notes:-
00858 //  =============
00859 
00860 //  None.
00861 
00862   void* ptr = ( IsValid() ) ? fSet->At(fIndex) : 0;
00863 
00864   if ( ! ptr && warnIfNull )
00865     MSG("Nav", Msg::kError) << "There is no object at index: " 
00866        << fIndex << "! The code will attempt to create an object." 
00867        << endl
00868        << "At the very least this will be a memory leak!" << endl;
00869   return ptr;
00870 
00871 }
00872 //.....................................................................
00873 
00874 void NavItr::Reset() {
00875 //
00876 //
00877 //  Purpose: Set to first valid entry in the default direction. 
00878 //
00879 //  Arguments: None.
00880 //
00881 //  Return:    n/a
00882 //
00883 //  Contact:   N. West
00884 //
00885 //  Specification:-
00886 //  =============
00887 //
00888 //  o Move to first valid entry.
00889 
00890 //  Program Notes:-
00891 //  =============
00892 
00893 //  None.
00894 
00895   if ( fDefaultStep > 0 ) ResetFirst();
00896   else                    ResetLast();
00897  
00898 }
00899 //.....................................................................
00900 
00901 void NavItr::ResetFirst() {
00902 //
00903 //
00904 //  Purpose: Set to first valid entry and set default direction to 
00905 //           forwards. 
00906 //
00907 //  Arguments: None.
00908 //
00909 //  Return:    n/a
00910 //
00911 //  Contact:   N. West
00912 //
00913 //  Specification:-
00914 //  =============
00915 //
00916 //  o Move to last valid entry or to 0 if none.
00917 
00918 //  Program Notes:-
00919 //  =============
00920 
00921 //  None.
00922 
00923   fIndex = fLimLo;
00924   fDefaultStep = +1;
00925 
00926 }
00927 //.....................................................................
00928 
00929 void NavItr::ResetLast() {
00930 //
00931 //
00932 //  Purpose: Set to last valid entry and set default direction to 
00933 //           backwards. 
00934 //
00935 //  Arguments: None.
00936 //
00937 //  Return:    n/a
00938 //
00939 //  Contact:   N. West
00940 //
00941 //  Specification:-
00942 //  =============
00943 
00944 //  o Move to last valid entry or to 0 if none.
00945 
00946 //  Program Notes:-
00947 //  =============
00948 
00949 //  None.
00950 
00951   fIndex = fLimHi;
00952   fDefaultStep = -1;
00953 
00954 }
00956 
00957 void NavItr::ResetSet() {
00958 //
00959 //
00960 //  Purpose: Reset after change in underlying set.
00961 //
00962 //  Arguments: None.
00963 //
00964 //  Return:    n/a
00965 //
00966 //  Contact:   N. West
00967 //
00968 //  Specification:-
00969 //  =============
00970 
00971 //  Reset after change in underlying set.
00972 
00973 //  Program Notes:-
00974 //  =============
00975 
00976 //  None.
00977 
00978   Init(fSet);
00979 
00980 }
00981 //.....................................................................
00982 
00983 void NavItr::SetDirection(Int_t dir) {
00984 //
00985 //
00986 //  Purpose:  Set default direction.
00987 //
00988 //  Arguments: 
00989 //    dir          in    Direction: > 0 Forwards 
00990 //                                  < 0 Backwards
00991 //                                  = 0 Leave default direction.
00992 //
00993 //  Return:   
00994 //
00995 //  Contact:   N. West
00996 //
00997 //  Specification:-
00998 //  =============
00999 //
01000 //  o Set default direction.
01001 
01002 //  Program Notes:-
01003 //  =============
01004 
01005 //  None.
01006 
01007   if ( dir >  0 ) fDefaultStep =  1;
01008   if ( dir <  0 ) fDefaultStep = -1;
01009 
01010 }
01011 
01012 //.....................................................................
01013 
01014 Bool_t NavItr::SetIndex( Int_t index){
01015 //
01016 //
01017 //  Purpose:  Set index if valid.
01018 //
01019 //  Arguments: 
01020 //    index        in    Required position.
01021 //
01022 //  Return:    kTRUE if index is valid.
01023 //
01024 //  Contact:   N. West
01025 //
01026 //  Specification:-
01027 //  =============
01028 //
01029 //  o If new index valid update iterator, otherwise leave where it is
01030 //    even if this is also invalid.
01031 
01032 
01033 //  Program Notes:-
01034 //  =============
01035 
01036 //  None.
01037 
01038   if ( IsValid(index) ) {
01039     fIndex = index;
01040     return kTRUE;
01041   }
01042 
01043   return kFALSE;
01044 
01045 }
01046 //.....................................................................
01047 
01048 UInt_t NavItr::Size() const {
01049 //
01050 //
01051 //  Purpose:  Return current size of set.
01052 //
01053 //  Arguments: None.
01054 //
01055 //  Return:  Current size of set  
01056 //
01057 //  Contact:   N. West
01058 //
01059 //  Specification:-
01060 //  =============
01061 //
01062 //  o Return current size of set.
01063 
01064 //  Program Notes:-
01065 //  =============
01066 
01067 //  None.
01068 
01069    return ( fSet ) ? fSet->Size() : 0;
01070 
01071 }
01072 //.....................................................................
01073 
01074 UInt_t NavItr::SizeSelect() const {
01075 //
01076 //
01077 //  Purpose:  Return current size of selected set.
01078 //
01079 //  Arguments: None.
01080 //
01081 //  Return:  Current size of selected set  
01082 //
01083 //  Contact:   N. West
01084 //
01085 //  Specification:-
01086 //  =============
01087 //
01088 //  o Return current size of selected set.
01089 
01090 //  Program Notes:-
01091 //  =============
01092 
01093 //  None.
01094 
01095    return ( fSet ) ? fSet->SizeSelect() : 0;
01096 
01097 }
01098 //.....................................................................
01099 
01100 void* NavItr::Step(Int_t dir/*=0*/) {
01101 //
01102 //
01103 //  Purpose:  Step iterator in required direction and return object pointed
01104 //            before the step.
01105 //
01106 //  Arguments: 
01107 //    dir          in    Direction: > 0 Forwards 
01108 //                                  < 0 Backwards
01109 //                                  = 0 Default direction.
01110 //
01111 //  Return:   
01112 //
01113 //  Contact:   N. West
01114 //
01115 //  Specification:-
01116 //  =============
01117 //
01118 //  o Step iterator in required direction and return object pointed
01119 //    before the step.
01120 
01121 //  Program Notes:-
01122 //  =============
01123 
01124 //  Returning the object in the old position allows this access
01125 //  method to be handled consistantly with the Ptr() and
01126 //  Obj() methods.  In all cases Reset() can move to the first valid.
01127 
01128 
01129   void* old = Ptr();
01130 
01131   if ( dir >  0 ) Increment();
01132   if ( dir <  0 ) Decrement();
01133   if ( dir == 0 && IsValid() ) fIndex += fDefaultStep;
01134 
01135   return old;
01136 
01137 }
01138 
01139 //.....................................................................
01140 
01141 void NavItr::SubSlice(const NavItr& parent) {
01142 //
01143 //
01144 //  Purpose: Set up iterator over sub-slice of supplied parent iterator.
01145 //
01146 //  Arguments: 
01147 //    parent        in    The parent iterator defining the sub-slice.
01148 //
01149 //  Return:   n/a
01150 //
01151 //  Contact:   N. West
01152 //
01153 //  Specification:-
01154 //  =============
01155 //
01156 //  o Set up iterator to be one rank higher than the supplied parent 
01157 //    and set its range to be the current parent zone.
01158 
01159 //  Program Notes:-
01160 //  =============
01161 
01162 //  By setting the this iterator's range to be the current zone of its 
01163 //  parent  means that this iterator is limits to the range in which 
01164 //  the parent has a constant NavKey value.
01165 
01166   Disconnect();
01167   fSet         = parent.fSet;
01168   Connect();
01169   fDefaultStep = parent.fDefaultStep;
01170   parent.GetZone(fLimLo,fLimHi);
01171   fIndex       = (fDefaultStep > 0 ) ? fLimLo : fLimHi;
01172   fRank        = parent.fRank+1;
01173   fZoneLo      = 0;
01174   fZoneHi      = -1;
01175   
01176 }
01177 
01178 
01179 /*    Template for New Member Function
01180 
01181 //.....................................................................
01182 
01183 NavItr:: {
01184 //
01185 //
01186 //  Purpose:  
01187 //
01188 //  Arguments: 
01189 //    xxxxx        in    xxxxxxxxxxxxxxxxxx
01190 //
01191 //  Return:   
01192 //
01193 //  Contact:   N. West
01194 //
01195 //  Specification:-
01196 //  =============
01197 //
01198 //  o 
01199 
01200 //  Program Notes:-
01201 //  =============
01202 
01203 //  None.
01204 
01205 
01206 }
01207 
01208 */
01209 

Generated on Mon Feb 15 11:07:02 2010 for loon by  doxygen 1.3.9.1