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.

249 lines
4.1 KiB

  1. /*++
  2. 1998 Seagate Software, Inc. All rights reserved
  3. Module Name:
  4. wsbcltbl.cpp
  5. Abstract:
  6. Abstract classes that provide methods that allow the derived objects to
  7. be stored in collections.
  8. Author:
  9. Chuck Bardeen [cbardeen] 29-Oct-1996
  10. Revision History:
  11. --*/
  12. #include "stdafx.h"
  13. HRESULT
  14. CWsbObject::FinalConstruct(
  15. void
  16. )
  17. /*++
  18. Implements:
  19. CComObjectRoot::FinalConstruct().
  20. --*/
  21. {
  22. return(CWsbPersistStream::FinalConstruct());
  23. }
  24. void
  25. CWsbObject::FinalRelease(
  26. void
  27. )
  28. /*++
  29. Implements:
  30. CComObjectRoot::FinalRelease().
  31. --*/
  32. {
  33. CWsbPersistStream::FinalRelease();
  34. }
  35. HRESULT
  36. CWsbObject::CompareTo(
  37. IN IUnknown* pObject,
  38. OUT SHORT* pResult
  39. )
  40. /*++
  41. Implements:
  42. IWsbCollectable::Compare().
  43. --*/
  44. {
  45. HRESULT hr = S_OK;
  46. SHORT result = 0;
  47. CComPtr<IWsbCollectable> pCollectable;
  48. WsbTraceIn(OLESTR("CWsbObject::CompareTo"), OLESTR(""));
  49. try {
  50. // Did they give us a valid item to compare to?
  51. WsbAssert(pObject != NULL, E_POINTER);
  52. WsbAffirmHr(pObject->QueryInterface(IID_IWsbCollectable,
  53. (void **)&pCollectable));
  54. // Check it's values.
  55. if (pCollectable == ((IWsbCollectable*) this)) {
  56. hr = S_OK;
  57. result = 0;
  58. } else {
  59. hr = S_FALSE;
  60. result = 1;
  61. }
  62. // If they want the value back, then return it to them.
  63. if (0 != pResult) {
  64. *pResult = result;
  65. }
  66. } WsbCatch(hr);
  67. WsbTraceOut(OLESTR("CWsbObject::CompareTo"), OLESTR("hr = <%ls>, value = <%d>"), WsbHrAsString(hr), result);
  68. return(hr);
  69. }
  70. HRESULT
  71. CWsbObject::IsEqual(
  72. IUnknown* pObject
  73. )
  74. /*++
  75. Implements:
  76. IWsbCollectable::IsEqual().
  77. --*/
  78. {
  79. HRESULT hr = S_OK;
  80. WsbTraceIn(OLESTR("CWsbObject::IsEqual"), OLESTR(""));
  81. hr = CompareTo(pObject, NULL);
  82. WsbTraceOut(OLESTR("CWsbObject::IsEqual"), OLESTR("hr = <%ls>"), WsbHrAsString(hr));
  83. return(hr);
  84. }
  85. // ************* CWsbCollectable ************
  86. HRESULT
  87. CWsbCollectable::FinalConstruct(
  88. void
  89. )
  90. /*++
  91. Implements:
  92. CComObjectRoot::FinalConstruct().
  93. --*/
  94. {
  95. return(CWsbPersistable::FinalConstruct());
  96. }
  97. void
  98. CWsbCollectable::FinalRelease(
  99. void
  100. )
  101. /*++
  102. Implements:
  103. CComObjectRoot::FinalRelease().
  104. --*/
  105. {
  106. CWsbPersistable::FinalRelease();
  107. }
  108. HRESULT
  109. CWsbCollectable::CompareTo(
  110. IN IUnknown* pObject,
  111. OUT SHORT* pResult
  112. )
  113. /*++
  114. Implements:
  115. IWsbCollectable::Compare().
  116. --*/
  117. {
  118. HRESULT hr = S_OK;
  119. SHORT result = 0;
  120. CComPtr<IWsbCollectable> pCollectable;
  121. WsbTraceIn(OLESTR("CWsbCollectable::CompareTo"), OLESTR(""));
  122. try {
  123. // Did they give us a valid item to compare to?
  124. WsbAssert(pObject != NULL, E_POINTER);
  125. WsbAffirmHr(pObject->QueryInterface(IID_IWsbCollectable,
  126. (void **)&pCollectable));
  127. // Check it's values.
  128. if (pCollectable == ((IWsbCollectable*) this)) {
  129. hr = S_OK;
  130. result = 0;
  131. } else {
  132. hr = S_FALSE;
  133. // if (pCollectable > ((IWsbCollectable*) this)) {
  134. // result = -1;
  135. // } else {
  136. result = 1;
  137. // }
  138. }
  139. // If they want the value back, then return it to them.
  140. if (0 != pResult) {
  141. *pResult = result;
  142. }
  143. } WsbCatch(hr);
  144. WsbTraceOut(OLESTR("CWsbCollectable::CompareTo"), OLESTR("hr = <%ls>, value = <%d>"), WsbHrAsString(hr), result);
  145. return(hr);
  146. }
  147. HRESULT
  148. CWsbCollectable::IsEqual(
  149. IUnknown* pCollectable
  150. )
  151. /*++
  152. Implements:
  153. IWsbCollectable::IsEqual().
  154. --*/
  155. {
  156. HRESULT hr = S_OK;
  157. WsbTraceIn(OLESTR("CWsbCollectable::IsEqual"), OLESTR(""));
  158. hr = CompareTo(pCollectable, NULL);
  159. WsbTraceOut(OLESTR("CWsbCollectable::IsEqual"), OLESTR("hr = <%ls>"), WsbHrAsString(hr));
  160. return(hr);
  161. }