Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

83 lines
2.2 KiB

  1. /***************************************************************************\
  2. *
  3. * File: TreeNode.h
  4. *
  5. * Description:
  6. * TreeNode describes a low-level tree designed to be used to maintain a
  7. * window hierarchy. Specific classes that use this tree should be derived
  8. * from TreeNodeT to safely cast the pointers to its specific type.
  9. *
  10. *
  11. * History:
  12. * 1/05/2000: JStall: Created
  13. *
  14. * Copyright (C) 2000 by Microsoft Corporation. All rights reserved.
  15. *
  16. \***************************************************************************/
  17. #if !defined(BASE__TreeNode_h__INCLUDED)
  18. #define BASE__TreeNode_h__INCLUDED
  19. #pragma once
  20. //------------------------------------------------------------------------------
  21. class TreeNode
  22. {
  23. // Implementation
  24. protected:
  25. enum ELinkType
  26. {
  27. ltAny = 0,
  28. ltBefore = 1,
  29. ltBehind = 2,
  30. ltTop = 3,
  31. ltBottom = 4,
  32. };
  33. };
  34. //------------------------------------------------------------------------------
  35. template <class T>
  36. class TreeNodeT : public TreeNode
  37. {
  38. // Construction
  39. public:
  40. TreeNodeT();
  41. ~TreeNodeT();
  42. // Operations
  43. public:
  44. inline T * GetParent() const;
  45. inline T * GetPrev() const;
  46. inline T * GetNext() const;
  47. inline T * GetTopSibling() const;
  48. inline T * GetBottomSibling() const;
  49. inline T * GetTopChild() const;
  50. inline T * GetBottomChild() const;
  51. // Implementation
  52. protected:
  53. void DoLink(T * ptnParent, T * ptnSibling = NULL, ELinkType lt = ltAny);
  54. void DoUnlink();
  55. #if DBG
  56. public:
  57. inline BOOL DEBUG_IsChild(const TreeNodeT<T> * pChild) const;
  58. virtual void DEBUG_AssertValid() const;
  59. #endif // DBG
  60. // Data
  61. protected:
  62. //
  63. // NOTE: This data members are declared in order of importance to help with
  64. // cache alignment.
  65. //
  66. TreeNodeT<T> * m_ptnParent;
  67. TreeNodeT<T> * m_ptnChild;
  68. TreeNodeT<T> * m_ptnNext;
  69. TreeNodeT<T> * m_ptnPrev;
  70. };
  71. #include "TreeNode.inl"
  72. #endif // BASE__TreeNode_h__INCLUDED