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.

230 lines
4.0 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1997 - 1997
  6. //
  7. // File: gnodera.cxx
  8. //
  9. //--------------------------------------------------------------------------
  10. #include "gnodera.hxx"
  11. GNODERA::GNODERA()
  12. {
  13. }
  14. GNODERA::~GNODERA()
  15. {
  16. _vpnodeChild.erase(_vpnodeChild.begin(), _vpnodeChild.end());
  17. _vpnodeParent.erase(_vpnodeParent.begin(), _vpnodeParent.end());
  18. }
  19. // Override on most GNODE virtual accessors
  20. // should throw an exception... for now, random
  21. // access nodes do not handle linear access calls.
  22. //
  23. // To save some typing, I've defined the following
  24. // macro to throw the appropriate exception for all
  25. // of the calls.
  26. #define THROW_RA_EXCEPTION() \
  27. throw GMException(EC_NYI, "Linear access accessor called on random access graph")
  28. GEDGE*& GNODERA::PedgeSource()
  29. {
  30. THROW_RA_EXCEPTION();
  31. return _glkArcs.PlnkSource();
  32. }
  33. GEDGE*& GNODERA::PedgeSink()
  34. {
  35. THROW_RA_EXCEPTION();
  36. return _glkArcs.PlnkSink();
  37. }
  38. GEDGE* GNODERA::PedgeSource() const
  39. {
  40. THROW_RA_EXCEPTION();
  41. return _glkArcs.PlnkSource();
  42. }
  43. GEDGE* GNODERA::PedgeSink() const
  44. {
  45. THROW_RA_EXCEPTION();
  46. return _glkArcs.PlnkSink();
  47. }
  48. GEDGE* GNODERA::PedgeOrdering(GEDGE* pgedge, BOOL bSource)
  49. {
  50. THROW_RA_EXCEPTION();
  51. return pgedge;
  52. }
  53. VOID GNODERA::ArcDeath(GEDGE* pgedge, BOOL bSource)
  54. {
  55. THROW_RA_EXCEPTION();
  56. }
  57. UINT GNODERA::CSourceArc() const
  58. {
  59. THROW_RA_EXCEPTION();
  60. return 0;
  61. }
  62. UINT GNODERA::CSinkArc() const
  63. {
  64. THROW_RA_EXCEPTION();
  65. return 0;
  66. }
  67. UINT GNODERA::CnodeChild()
  68. {
  69. return _vpnodeChild.size();
  70. }
  71. UINT GNODERA::CnodeParent()
  72. {
  73. return _vpnodeParent.size();
  74. }
  75. VOID GNODERA::InsertChild(GNODE* pnodeChild)
  76. {
  77. _vpnodeChild.push_back(pnodeChild);
  78. }
  79. VOID GNODERA::InsertParent(GNODE* pnodeParent)
  80. {
  81. _vpnodeParent.push_back(pnodeParent);
  82. }
  83. VOID GNODERA::InsertChild(UINT inodeChild, GNODE* pnodeChild)
  84. {
  85. assert(inodeChild <= _vpnodeChild.size());
  86. _vpnodeChild.insert(&_vpnodeChild[inodeChild], pnodeChild);
  87. }
  88. VOID GNODERA::InsertParent(UINT inodeParent, GNODE* pnodeParent)
  89. {
  90. assert(inodeParent <= _vpnodeParent.size());
  91. _vpnodeParent.insert(&_vpnodeParent[inodeParent]);
  92. }
  93. VOID GNODERA::DeleteChild(UINT inodeChild)
  94. {
  95. assert(inodeChild < _vpnodeChild.size());
  96. _vpnodeChild.erase(&_vpnodeChild[inodeChild]);
  97. }
  98. VOID GNODERA::DeleteParent(UINT inodeParent)
  99. {
  100. assert(inodeParent < _vpnodeParent.size());
  101. _vpnodeParent.erase(&_vpnodeParent[inodeParent]);
  102. }
  103. BOOL GNODERA::BParent(GNODE* pnode)
  104. {
  105. /* for (UINT inodeParent = 0; inodeParent < CnodeParent(); inodeParent++)
  106. {
  107. if (PnodeParent(inodeParent) == pnode)
  108. return true;
  109. }
  110. return false;*/
  111. if (InodeParent(pnode) == (UINT) -1)
  112. return false;
  113. else
  114. return true;
  115. }
  116. UINT GNODERA::InodeParent(GNODE* pnode)
  117. {
  118. for (UINT inodeParent = 0; inodeParent < CnodeParent(); inodeParent++)
  119. {
  120. if (PnodeParent(inodeParent) == pnode)
  121. return inodeParent;
  122. }
  123. return (UINT) -1;
  124. }
  125. BOOL GNODERA::BChild(GNODE* pnode)
  126. {
  127. /*for (UINT inodeChild = 0; inodeChild < CnodeChild(); inodeChild++)
  128. {
  129. if (PnodeChild(inodeChild) == pnode)
  130. return true;
  131. }
  132. return false;*/
  133. if (InodeChild(pnode) == (UINT) -1)
  134. return false;
  135. else
  136. return true;
  137. }
  138. UINT GNODERA::InodeChild(GNODE* pnode)
  139. {
  140. for (UINT inodeChild = 0; inodeChild < CnodeChild(); inodeChild++)
  141. {
  142. if (PnodeChild(inodeChild) == pnode)
  143. return inodeChild;
  144. }
  145. return (UINT) -1;
  146. }
  147. GNODE* GNODERA::PnodeParent(UINT inodeParent)
  148. {
  149. assert(inodeParent < _vpnodeParent.size());
  150. return _vpnodeParent[inodeParent];
  151. }
  152. GNODERA* GNODERA::PnoderaParent(UINT inodeParent)
  153. {
  154. return (GNODERA*) PnodeParent(inodeParent);
  155. }
  156. GNODE* GNODERA::PnodeChild(UINT inodeChild)
  157. {
  158. assert(inodeChild < _vpnodeChild.size());
  159. return _vpnodeChild[inodeChild];
  160. }
  161. GNODERA* GNODERA::PnoderaChild(UINT inodeChild)
  162. {
  163. return (GNODERA*) PnodeChild(inodeChild);
  164. }