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.

212 lines
3.7 KiB

  1. // (C) 1999-2001 Microsoft Corporation
  2. #ifndef WMI_TREE
  3. #define WMI_TREE
  4. /******************************************************************************
  5. *
  6. * Name:
  7. *
  8. *
  9. * Description:
  10. *
  11. *
  12. *****************************************************************************/
  13. typedef DWORD TypeId_TreeNode ;
  14. /******************************************************************************
  15. *
  16. * Name:
  17. *
  18. *
  19. * Description:
  20. *
  21. *
  22. *****************************************************************************/
  23. class WmiTreeNode
  24. {
  25. bool m_valid;
  26. protected:
  27. TypeId_TreeNode m_Type ;
  28. void *m_Data ;
  29. WmiTreeNode *m_Left ;
  30. WmiTreeNode *m_Right ;
  31. WmiTreeNode *m_Parent ;
  32. public:
  33. WmiTreeNode (
  34. WmiTreeNode *a_Node
  35. )
  36. {
  37. m_Type = a_Node->m_Type ;
  38. m_Data = a_Node->m_Data ;
  39. m_Left = a_Node->m_Left ;
  40. m_Right = a_Node->m_Right ;
  41. m_Parent = a_Node->m_Parent ;
  42. m_valid = a_Node->m_valid;
  43. }
  44. WmiTreeNode (
  45. TypeId_TreeNode a_Type = 0 ,
  46. void *a_Data = NULL ,
  47. WmiTreeNode *a_Left = NULL ,
  48. WmiTreeNode *a_Right = NULL ,
  49. WmiTreeNode *a_Parent = NULL
  50. ) : m_valid(true)
  51. {
  52. m_Type = a_Type ;
  53. m_Parent = a_Parent ;
  54. m_Data = a_Data ;
  55. m_Left = a_Left ;
  56. m_Right = a_Right ;
  57. if ( m_Left )
  58. m_Left->SetParent ( this ) ;
  59. if ( m_Right )
  60. m_Right->SetParent ( this ) ;
  61. }
  62. virtual ~WmiTreeNode () {}
  63. bool IsValid() { return m_valid;}
  64. void SetValid(bool valid) { m_valid = valid;}
  65. TypeId_TreeNode GetType ()
  66. {
  67. return m_Type ;
  68. }
  69. void *GetData ()
  70. {
  71. return m_Data ;
  72. }
  73. WmiTreeNode *GetLeft ()
  74. {
  75. return m_Left ;
  76. }
  77. WmiTreeNode *GetRight ()
  78. {
  79. return m_Right ;
  80. }
  81. WmiTreeNode *GetParent ()
  82. {
  83. return m_Parent ;
  84. }
  85. void GetData ( void **a_Data )
  86. {
  87. *a_Data = & m_Data ;
  88. }
  89. void GetLeft ( WmiTreeNode **&a_Left )
  90. {
  91. a_Left = &m_Left ;
  92. }
  93. void GetRight ( WmiTreeNode **&a_Right )
  94. {
  95. a_Right = &m_Right ;
  96. }
  97. void GetParent ( WmiTreeNode **&a_Parent )
  98. {
  99. a_Parent = &m_Parent ;
  100. }
  101. void SetType ( TypeId_TreeNode a_Type )
  102. {
  103. m_Type = a_Type ;
  104. }
  105. void *SetData ( void *a_Data )
  106. {
  107. void *t_Data = m_Data ;
  108. m_Data = a_Data ;
  109. return t_Data ;
  110. }
  111. WmiTreeNode *SetLeft ( WmiTreeNode *a_Left )
  112. {
  113. WmiTreeNode *t_Left = m_Left ;
  114. m_Left = a_Left ;
  115. return t_Left ;
  116. }
  117. WmiTreeNode *SetRight ( WmiTreeNode *a_Right )
  118. {
  119. WmiTreeNode *t_Right = m_Right ;
  120. m_Right = a_Right ;
  121. return t_Right ;
  122. }
  123. WmiTreeNode *SetParent ( WmiTreeNode *a_Parent )
  124. {
  125. WmiTreeNode *t_Parent = m_Parent ;
  126. m_Parent = a_Parent ;
  127. return t_Parent ;
  128. }
  129. virtual WmiTreeNode *Copy () ; // Copy node, not allocating copies of data and allocating copies of sub tree
  130. virtual WmiTreeNode *CopyNode () ; // Copy node, not allocating copies of data and subtree
  131. virtual void Print () {} ;
  132. } ;
  133. class WmiTreeNodeIterator
  134. {
  135. protected:
  136. WmiTreeNode *m_Iterator ;
  137. public:
  138. WmiTreeNodeIterator ( WmiTreeNodeIterator *a_WmiTreeNodeIterator )
  139. {
  140. m_Iterator = a_WmiTreeNodeIterator->m_Iterator ;
  141. }
  142. WmiTreeNodeIterator ( WmiTreeNode *a_Root )
  143. {
  144. m_Iterator = a_Root ;
  145. }
  146. virtual ~WmiTreeNodeIterator () {}
  147. WmiTreeNode *GetIterator ()
  148. {
  149. return m_Iterator ;
  150. }
  151. WmiTreeNode *SetIterator ( WmiTreeNode *a_Iterator )
  152. {
  153. WmiTreeNode *t_Iterator = m_Iterator ;
  154. m_Iterator = a_Iterator ;
  155. return t_Iterator ;
  156. }
  157. virtual WmiTreeNodeIterator *Copy ()
  158. {
  159. WmiTreeNodeIterator *t_Iterator = new WmiTreeNodeIterator ( m_Iterator ) ;
  160. return t_Iterator ;
  161. }
  162. void InOrder () ;
  163. void PreOrder () ;
  164. void PostOrder () ;
  165. } ;
  166. #endif // WMI_TREE