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.

165 lines
4.7 KiB

  1. //+--------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1992.
  5. //
  6. // File: tlsets.cxx
  7. //
  8. // Contents: Transaction level set manager implementation
  9. //
  10. // History: 20-Jan-1992 PhilipL Created
  11. //
  12. //---------------------------------------------------------------
  13. #include <dfhead.cxx>
  14. #pragma hdrstop
  15. //+--------------------------------------------------------------
  16. //
  17. // Member: CTSSet::~CTSSet, public
  18. //
  19. // Synopsis: destructor
  20. //
  21. // History: 22-Jan-1992 Philipl Created
  22. // 08-Apr-1992 DrewB Rewritten
  23. //
  24. //---------------------------------------------------------------
  25. #ifdef CODESEGMENTS
  26. #pragma code_seg(SEG_CTSSet_1CTSSet) // inline?
  27. #endif
  28. CTSSet::~CTSSet()
  29. {
  30. // Last element should be TS, but we can't check this
  31. // so allow one last element to exist, assuming it will
  32. // be the TS
  33. olAssert(_ptsmHead == NULL ||
  34. _ptsmHead->GetNext() == NULL);
  35. }
  36. //+--------------------------------------------------------------
  37. //
  38. // Member: CTSSet::FindName, public
  39. //
  40. // Synopsis: Return the element in the TS with the given name
  41. //
  42. // Arguments: [pdfn] - name
  43. // [ulLevel] - level
  44. //
  45. // Returns: Matching element or NULL
  46. //
  47. // History: 22-Jan-1992 Philipl Created
  48. // 08-Apr-1992 DrewB Rewritten
  49. // 28-Oct-1992 AlexT Convert to name
  50. //
  51. //---------------------------------------------------------------
  52. #ifdef CODESEGMENTS
  53. #pragma code_seg(SEG_CTSSet_FindName)
  54. #endif
  55. PTSetMember *CTSSet::FindName(CDfName const *pdfn, DFLUID dlTree)
  56. {
  57. PTSetMember *ptsm;
  58. olDebugOut((DEB_ITRACE, "In CTSSet::FindName(%p)\n", pdfn));
  59. olAssert(pdfn != NULL && aMsg("Can't search for Null name"));
  60. for (ptsm = BP_TO_P(PTSetMember *, _ptsmHead);
  61. ptsm; ptsm = ptsm->GetNext())
  62. {
  63. if (ptsm->GetDfName()->IsEqual(pdfn) && ptsm->GetTree() == dlTree)
  64. break;
  65. }
  66. olDebugOut((DEB_ITRACE, "Out CTSSet::FindName => %p\n", ptsm));
  67. return ptsm;
  68. }
  69. //+--------------------------------------------------------------
  70. //
  71. // Member: CTSSet::AddMember, public
  72. //
  73. // Synopsis: Add the member to the correct position in the list
  74. //
  75. // Arguments: [ptsmAdd] - Element to add
  76. //
  77. // History: 22-Jan-1992 Philipl Created
  78. // 08-Apr-1992 DrewB Rewritten
  79. //
  80. // Notes: This function inserts the provided element into the
  81. // list in its correct sorted position.
  82. //
  83. //---------------------------------------------------------------
  84. #ifdef CODESEGMENTS
  85. #pragma code_seg(SEG_CTSSet_AddMember)
  86. #endif
  87. void CTSSet::AddMember(PTSetMember *ptsmAdd)
  88. {
  89. PTSetMember *ptsm, *ptsmPrev;
  90. olDebugOut((DEB_ITRACE, "In CTSSet::AddMember(%p)\n", ptsmAdd));
  91. for (ptsm = BP_TO_P(PTSetMember *, _ptsmHead), ptsmPrev = NULL;
  92. ptsm;
  93. ptsmPrev = ptsm, ptsm = ptsm->GetNext())
  94. if (ptsm->GetLevel() >= ptsmAdd->GetLevel())
  95. break;
  96. if (ptsm == NULL)
  97. if (ptsmPrev == NULL)
  98. // Empty list
  99. _ptsmHead = P_TO_BP(CBasedTSetMemberPtr, ptsmAdd);
  100. else
  101. {
  102. // Nothing with a higher level, add to end of list
  103. ptsmPrev->SetNext(ptsmAdd);
  104. ptsmAdd->SetPrev(ptsmPrev);
  105. }
  106. else
  107. {
  108. // Add before element with higher level
  109. ptsmAdd->SetNext(ptsm);
  110. ptsmAdd->SetPrev(ptsm->GetPrev());
  111. if (ptsm->GetPrev())
  112. ptsm->GetPrev()->SetNext(ptsmAdd);
  113. else
  114. _ptsmHead = P_TO_BP(CBasedTSetMemberPtr, ptsmAdd);
  115. ptsm->SetPrev(ptsmAdd);
  116. }
  117. olDebugOut((DEB_ITRACE, "Out CTSSet::AddMember\n"));
  118. }
  119. //+--------------------------------------------------------------
  120. //
  121. // Member: CTSSet::RemoveMember, public
  122. //
  123. // Synopsis: Removes the member from the list
  124. //
  125. // Arguments: [ptsmRemove] - Element to remove
  126. //
  127. // History: 22-Jan-1992 Philipl Created
  128. // 08-Apr-1992 DrewB Rewritten
  129. //
  130. //---------------------------------------------------------------
  131. #ifdef CODESEGMENTS
  132. #pragma code_seg(SEG_CTSSet_RemoveMember)
  133. #endif
  134. void CTSSet::RemoveMember(PTSetMember *ptsmRemove)
  135. {
  136. olDebugOut((DEB_ITRACE, "In CTSSet::RemoveMember(%p)\n", ptsmRemove));
  137. PTSetMember *ptsmNext = ptsmRemove->GetNext();
  138. if (ptsmRemove->GetPrev())
  139. ptsmRemove->GetPrev()->SetNext(ptsmNext);
  140. else
  141. _ptsmHead = P_TO_BP(CBasedTSetMemberPtr, ptsmNext);
  142. if (ptsmRemove->GetNext())
  143. ptsmRemove->GetNext()->SetPrev(ptsmRemove->GetPrev());
  144. ptsmRemove->SetNext(NULL);
  145. ptsmRemove->SetPrev(NULL);
  146. olDebugOut((DEB_ITRACE, "Out CTSSet::RemoveMember\n"));
  147. }