home *** CD-ROM | disk | FTP | other *** search
/ Xentax forum attachments archive / xentax.7z / 8090 / ModelEdit.7z / ltwintreeitemiter.h < prev    next >
Encoding:
C/C++ Source or Header  |  2006-03-08  |  1.7 KB  |  61 lines

  1. ////////////////////////////////////////////////////////////////
  2. //
  3. // ltwintreeitemiter.h
  4. //
  5. // This is the iterator class for the CLTWinTreeItem items. 
  6. // This iterates through all siblings of an item, and then those
  7. // items can then be used to iterate through children, etc, 
  8. // allowing for tree navigation. The iterators can only be cloned
  9. // not created by users, to avoid invalid iterators. For info
  10. // on the purpose and how to use iterators, refer to the Design
  11. // Patterns book section on iterators.
  12. //
  13. // Author: John O'Rorke
  14. // Created: 7/21/00
  15. // Modification History:
  16. //
  17. ////////////////////////////////////////////////////////////////
  18. #ifndef __LTWINTREEITEMITER_H__
  19. #define __LTWINTREEITEMITER_H__
  20.  
  21. #include "stdafx.h"
  22.  
  23. class CLTWinTreeItem;
  24.  
  25. class CLTWinTreeItemIter
  26. {
  27. public:
  28.  
  29.     //allow the copying of iterators so that positions can be saved
  30.     CLTWinTreeItemIter(const CLTWinTreeItemIter& rhs);
  31.  
  32.     //allow the copying of iterators so that positions can be saved
  33.     const CLTWinTreeItemIter& operator=(const CLTWinTreeItemIter& rhs);
  34.  
  35.     //gets the item the iterator is currently on
  36.     CLTWinTreeItem*    Current();
  37.  
  38.     //gets the next item in the list, and advances the iterator
  39.     CLTWinTreeItem* Next();
  40.  
  41.     //determines if there are any more items to iterate through
  42.     BOOL IsMore() const;
  43.  
  44. private:
  45.  
  46.     //make the items a friend so that they can create
  47.     //these iterators
  48.     friend class CLTWinTreeItem;
  49.  
  50.     //make the constructor private so that only items
  51.     //can create iterators, this prevents invalid iterators
  52.     CLTWinTreeItemIter(CLTWinTreeItem* pStart);
  53.  
  54.     //the current item we are iterating through
  55.     CLTWinTreeItem* m_pCurrent;
  56.  
  57. };
  58.  
  59. #endif
  60.  
  61.