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.

134 lines
2.5 KiB

  1. #ifndef __CCOOKIE__H__
  2. #define __CCOOKIE_H__
  3. /*++
  4. Copyright (C) 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. //
  28. // Delete the subtree
  29. //
  30. if (m_pChild) {
  31. delete m_pChild;
  32. }
  33. if (m_pSibling) {
  34. delete m_pSibling;
  35. }
  36. }
  37. void SetScopeItem(CScopeItem* pScopeItem)
  38. {
  39. //
  40. // Can only set it onece or memory leak could occur
  41. //
  42. ASSERT(NULL == m_pScopeItem);
  43. m_pScopeItem = pScopeItem;
  44. }
  45. void SetResultItem(CResultItem* pResultItem)
  46. {
  47. //
  48. // Can only set once or memory leak could occur
  49. //
  50. ASSERT(NULL == m_pResultItem);
  51. m_pResultItem = pResultItem;
  52. }
  53. COOKIE_TYPE GetType()
  54. {
  55. return m_Type;
  56. }
  57. CScopeItem* GetScopeItem()
  58. {
  59. return m_pScopeItem;
  60. }
  61. CResultItem* GetResultItem()
  62. {
  63. return m_pResultItem;
  64. }
  65. CCookie* GetChild()
  66. {
  67. return m_pChild;
  68. }
  69. CCookie* GetSibling()
  70. {
  71. return m_pSibling;
  72. }
  73. CCookie* GetParent()
  74. {
  75. return m_pParent;
  76. }
  77. void SetChild(CCookie* pCookie)
  78. {
  79. m_pChild = pCookie;
  80. }
  81. void SetSibling(CCookie* pCookie)
  82. {
  83. m_pSibling = pCookie;
  84. }
  85. void SetParent(CCookie* pCookie)
  86. {
  87. m_pParent = pCookie;
  88. }
  89. BOOL IsScopeItem()
  90. {
  91. return (!m_pResultItem && m_pScopeItem);
  92. }
  93. DWORD IsFlagsOn(DWORD Flags)
  94. {
  95. return (m_Flags & Flags);
  96. }
  97. void TurnOnFlags(DWORD Flags)
  98. {
  99. m_Flags |= Flags;
  100. }
  101. void TurnOffFlags(DWORD Flags)
  102. {
  103. m_Flags &= ~Flags;
  104. }
  105. LPARAM m_lParam;
  106. private:
  107. COOKIE_TYPE m_Type;
  108. CScopeItem* m_pScopeItem;
  109. CResultItem* m_pResultItem;
  110. CCookie* m_pParent;
  111. CCookie* m_pSibling;
  112. CCookie* m_pChild;
  113. DWORD m_Flags;
  114. };
  115. #endif // __CCOOKIE_H__