home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / warphead.zip / H / NODE.H < prev    next >
C/C++ Source or Header  |  1997-02-28  |  4KB  |  143 lines

  1. //====START_GENERATED_PROLOG======================================
  2. //
  3. //
  4. //   COMPONENT_NAME: odutils
  5. //
  6. //   CLASSES:   Node
  7. //        NodeTraverser
  8. //
  9. //   ORIGINS: 82,27
  10. //
  11. //
  12. //   (C) COPYRIGHT International Business Machines Corp. 1995,1996
  13. //   All Rights Reserved
  14. //   Licensed Materials - Property of IBM
  15. //   US Government Users Restricted Rights - Use, duplication or
  16. //   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  17. //       
  18. //   IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  19. //   ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  20. //   PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  21. //   CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
  22. //   USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  23. //   OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
  24. //   OR PERFORMANCE OF THIS SOFTWARE.
  25. //
  26. //====END_GENERATED_PROLOG========================================
  27. //
  28. // @(#) 1.4 com/src/utils/include/Node.h, odutils, od96os2, odos29646d 7/15/96 18:00:47 [ 11/15/96 15:29:33 ]
  29. /*
  30.     File:        Node.h
  31.  
  32.     Contains:    Tree node class
  33.  
  34.     Owned by:    Richard Rodseth
  35.  
  36.     Copyright:    ⌐ 1993 - 1995 by Apple Computer, Inc., all rights reserved.
  37.  
  38.     
  39.     In Progress:
  40. */
  41.  
  42. #ifndef _NODE_
  43. #define _NODE_
  44.  
  45. #ifndef _ODTYPES_
  46. #include "ODTypes.h"
  47. #endif
  48.  
  49. #ifndef _LINKLIST_
  50. #include "LinkList.h"
  51. #endif
  52.  
  53. //=====================================================================================
  54. // Classes defined in this interface
  55. //=====================================================================================
  56.  
  57. class Node;
  58. class NodeTraverser;
  59.  
  60. //=====================================================================================
  61. // Classes used by this interface
  62. //=====================================================================================
  63.  
  64. class Link;
  65. class LinkedList;
  66.  
  67. //=====================================================================================
  68. // Class Node
  69. //=====================================================================================
  70.  
  71. class  Node : private Link, private LinkedList
  72. {
  73.     public:
  74.         Node();
  75.         ~Node();
  76.  
  77.         ODULong Size();
  78.         
  79.         Node* GetParent();
  80.         Node* GetFirstChild();
  81.         Node* GetLastChild();
  82.         Node* GetNextSibling();
  83.         Node* GetPreviousSibling();
  84.             
  85.         void SetParent(Node* parent);
  86.         
  87.         void AddChildFirst(Node* node);
  88.         void AddChildLast(Node* node);
  89.         void AddChildBefore(Node& existing, Node* node);
  90.         void AddChildAfter(Node& existing, Node* node);
  91.         void RemoveChild(Node& node);
  92.         Node* GetChildAfter(Node* node);
  93.         Node* GetChildBefore(Node* node);
  94.  
  95.         Node* FirstTopDown();
  96.         Node* NextTopDown(ODSiblingOrder siblingOrder);
  97.         Node* GetNextAunt(ODSiblingOrder siblingOrder);
  98.         
  99. #ifndef OD_BUG  // Method doesn't work, and no one in DR4 uses it.
  100.         Node* FirstBottomUp(ODSiblingOrder siblingOrder);
  101.         Node* NextBottomUp(ODSiblingOrder siblingOrder);
  102. #endif
  103.  
  104.     private:
  105.         Node*        fParent;
  106. };
  107.  
  108. //=====================================================================================
  109. // Class NodeTraverser
  110. //=====================================================================================
  111.  
  112.  
  113. class NodeTraverser 
  114. {
  115. public:
  116.  
  117.     NodeTraverser(Node* root, 
  118.                   ODTraversalType traversalType, 
  119.                   ODSiblingOrder siblingOrder);
  120.     ~NodeTraverser();
  121.  
  122.     Node*                First();
  123.     Node*                Next();
  124.     void                SkipChildren();
  125.     ODBoolean            IsNotComplete();
  126.  
  127. protected:    
  128.  
  129.     Node* FirstTopDown(Node* node);
  130.     Node* NextTopDown(Node* node, ODSiblingOrder siblingOrder);
  131.     Node* GetNextAunt(Node* node, ODSiblingOrder siblingOrder);
  132.     Node* FirstBottomUp(Node* node, ODSiblingOrder siblingOrder);
  133.     Node* NextBottomUp(Node* node, ODSiblingOrder siblingOrder);
  134.     
  135. private:
  136.       Node*             fRoot;
  137.      Node*             fCurrent;
  138.      ODTraversalType fTraversalType;
  139.      ODSiblingOrder  fSiblingOrder;
  140. };
  141.  
  142. #endif // _NODE_
  143.