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.

216 lines
4.2 KiB

  1. /*++
  2. Copyright (c) 1992-2000 Microsoft Corporation
  3. Module Name:
  4. digraph.hxx
  5. Abstract:
  6. This class implements a directed graph.
  7. Author:
  8. Norbert P. Kusters (norbertk) 17-Mar-92
  9. --*/
  10. #if !defined(DIGRAPH_DEFN)
  11. #define DIGRAPH_DEFN
  12. #include "membmgr.hxx"
  13. #include "membmgr2.hxx"
  14. #if defined ( _AUTOCHECK_ )
  15. #define IFSUTIL_EXPORT
  16. #elif defined ( _IFSUTIL_MEMBER_ )
  17. #define IFSUTIL_EXPORT __declspec(dllexport)
  18. #else
  19. #define IFSUTIL_EXPORT __declspec(dllimport)
  20. #endif
  21. DECLARE_CLASS( NUMBER_SET );
  22. DECLARE_CLASS( BITVECTOR );
  23. DECLARE_CLASS( INTSTACK );
  24. DECLARE_CLASS( CONTAINER );
  25. DECLARE_CLASS( DIGRAPH_EDGE );
  26. class DIGRAPH_EDGE : public OBJECT {
  27. public:
  28. IFSUTIL_EXPORT
  29. DECLARE_CONSTRUCTOR( DIGRAPH_EDGE );
  30. ULONG Parent;
  31. ULONG Child;
  32. };
  33. struct CHILD_ENTRY {
  34. CHILD_ENTRY* Next;
  35. ULONG Child; // first child described this node
  36. ULONG ChildBits[1]; // 0 bit is same as "Child"
  37. };
  38. DEFINE_POINTER_TYPES(CHILD_ENTRY);
  39. #define BITS_PER_CHILD_ENTRY (32) // 1 * (bits per ulong)
  40. struct PARENT_ENTRY {
  41. PARENT_ENTRY* Next;
  42. ULONG Parent;
  43. RTL_GENERIC_TABLE Children;
  44. };
  45. DEFINE_POINTER_TYPES(PARENT_ENTRY);
  46. DECLARE_CLASS( DIGRAPH );
  47. class DIGRAPH : public OBJECT {
  48. public:
  49. IFSUTIL_EXPORT
  50. DECLARE_CONSTRUCTOR( DIGRAPH );
  51. IFSUTIL_EXPORT
  52. VIRTUAL
  53. ~DIGRAPH(
  54. );
  55. NONVIRTUAL
  56. IFSUTIL_EXPORT
  57. BOOLEAN
  58. Initialize(
  59. IN ULONG NumberOfNodes
  60. );
  61. NONVIRTUAL
  62. IFSUTIL_EXPORT
  63. BOOLEAN
  64. AddEdge(
  65. IN ULONG Parent,
  66. IN ULONG Child
  67. );
  68. NONVIRTUAL
  69. IFSUTIL_EXPORT
  70. BOOLEAN
  71. RemoveEdge(
  72. IN ULONG Parent,
  73. IN ULONG Child
  74. );
  75. NONVIRTUAL
  76. ULONG
  77. QueryNumChildren(
  78. IN ULONG Parent
  79. ) CONST;
  80. NONVIRTUAL
  81. ULONG
  82. QueryNumParents(
  83. IN ULONG Child
  84. ) CONST;
  85. NONVIRTUAL
  86. IFSUTIL_EXPORT
  87. BOOLEAN
  88. QueryChildren(
  89. IN ULONG Parent,
  90. OUT PNUMBER_SET Children
  91. ) CONST;
  92. NONVIRTUAL
  93. IFSUTIL_EXPORT
  94. BOOLEAN
  95. QueryParents(
  96. IN ULONG Child,
  97. OUT PNUMBER_SET Parents
  98. ) CONST;
  99. NONVIRTUAL
  100. IFSUTIL_EXPORT
  101. BOOLEAN
  102. QueryParentsWithChildren(
  103. OUT PNUMBER_SET Parents,
  104. IN ULONG MinimumNumberOfChildren DEFAULT 1
  105. ) CONST;
  106. NONVIRTUAL
  107. IFSUTIL_EXPORT
  108. BOOLEAN
  109. EliminateCycles(
  110. IN OUT PCONTAINER RemovedEdges,
  111. OUT PBOOLEAN CompletionStatus
  112. );
  113. INLINE
  114. PVOID
  115. AllocChild(
  116. IN ULONG Size
  117. );
  118. INLINE
  119. VOID
  120. FreeChild(
  121. IN PVOID Buffer
  122. );
  123. private:
  124. NONVIRTUAL
  125. PPARENT_ENTRY
  126. GetParentEntry(
  127. IN ULONG Parent
  128. ) CONST;
  129. NONVIRTUAL
  130. BOOLEAN
  131. DescendDigraph(
  132. IN ULONG CurrentNode,
  133. IN OUT PBITVECTOR Visited,
  134. IN OUT PINTSTACK Ancestors,
  135. IN OUT PCONTAINER RemovedEdges
  136. );
  137. NONVIRTUAL
  138. VOID
  139. Construct (
  140. );
  141. NONVIRTUAL
  142. VOID
  143. Destroy(
  144. );
  145. PPARENT_ENTRY* _parent_head;
  146. ULONG _num_nodes;
  147. MEM_BLOCK_MGR _parent_mgr;
  148. MEM_ALLOCATOR _element_mgr;
  149. BOOLEAN _all_cycles_detected;
  150. };
  151. PVOID
  152. DIGRAPH::AllocChild(
  153. IN ULONG Size
  154. )
  155. {
  156. return _element_mgr.Allocate(Size);
  157. }
  158. VOID
  159. DIGRAPH::FreeChild(
  160. IN PVOID Buffer
  161. )
  162. {
  163. return;
  164. }
  165. #endif // DIGRAPH_DEFN