Source code of Windows XP (NT5)
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.

126 lines
2.2 KiB

  1. #ifndef __CCOOKIE__H__
  2. #define __CCOOKIE_H__
  3. /*++
  4. Copyright (C) 1997-1999 Microsoft Corporation
  5. Module Name:
  6. ccookie.h
  7. Abstract:
  8. definition and implementation for CCookie class
  9. Author:
  10. William Hsieh (williamh) created
  11. Revision History:
  12. --*/
  13. class CCookie;
  14. class CResultItem;
  15. class CScopeItem;
  16. class CCookie
  17. {
  18. public:
  19. CCookie(COOKIE_TYPE ct)
  20. : m_pScopeItem(NULL), m_pResultItem(NULL), m_Type(ct),
  21. m_pChild(NULL), m_pSibling(NULL), m_pParent(NULL),
  22. m_Flags(0), m_lParam(0)
  23. {
  24. }
  25. ~CCookie()
  26. {
  27. // delete the subtree
  28. if (m_pChild)
  29. delete m_pChild;
  30. if (m_pSibling)
  31. delete m_pSibling;
  32. }
  33. void SetScopeItem(CScopeItem* pScopeItem)
  34. {
  35. // can only set it onece or memory leak could occur
  36. ASSERT(NULL == m_pScopeItem);
  37. m_pScopeItem = pScopeItem;
  38. }
  39. void SetResultItem(CResultItem* pResultItem)
  40. {
  41. // can only set once or memory leak could occur
  42. ASSERT(NULL == m_pResultItem);
  43. m_pResultItem = pResultItem;
  44. }
  45. COOKIE_TYPE GetType()
  46. {
  47. return m_Type;
  48. }
  49. CScopeItem* GetScopeItem()
  50. {
  51. return m_pScopeItem;
  52. }
  53. CResultItem* GetResultItem()
  54. {
  55. return m_pResultItem;
  56. }
  57. CCookie* GetChild()
  58. {
  59. return m_pChild;
  60. }
  61. CCookie* GetSibling()
  62. {
  63. return m_pSibling;
  64. }
  65. CCookie* GetParent()
  66. {
  67. return m_pParent;
  68. }
  69. void SetChild(CCookie* pCookie)
  70. {
  71. m_pChild = pCookie;
  72. }
  73. void SetSibling(CCookie* pCookie)
  74. {
  75. m_pSibling = pCookie;
  76. }
  77. void SetParent(CCookie* pCookie)
  78. {
  79. m_pParent = pCookie;
  80. }
  81. BOOL IsScopeItem()
  82. {
  83. return (!m_pResultItem && m_pScopeItem);
  84. }
  85. DWORD IsFlagsOn(DWORD Flags)
  86. {
  87. return (m_Flags & Flags);
  88. }
  89. void TurnOnFlags(DWORD Flags)
  90. {
  91. m_Flags |= Flags;
  92. }
  93. void TurnOffFlags(DWORD Flags)
  94. {
  95. m_Flags &= ~Flags;
  96. }
  97. LPARAM m_lParam;
  98. private:
  99. COOKIE_TYPE m_Type;
  100. CScopeItem* m_pScopeItem;
  101. CResultItem* m_pResultItem;
  102. CCookie* m_pParent;
  103. CCookie* m_pSibling;
  104. CCookie* m_pChild;
  105. DWORD m_Flags;
  106. };
  107. #endif // __CCOOKIE_H__