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.

312 lines
6.5 KiB

  1. /*++
  2. 1998 Seagate Software, Inc. All rights reserved.
  3. Module Name:
  4. VolAssign.cpp
  5. Abstract:
  6. This component is an object representation of the HSM Metadata
  7. Volume Assignement record.
  8. Author:
  9. Ron White [ronw] 3-Jun-1997
  10. Revision History:
  11. --*/
  12. #include "stdafx.h"
  13. #include "metaint.h"
  14. #include "metalib.h"
  15. #include "VolAsgn.h"
  16. #undef WSB_TRACE_IS
  17. #define WSB_TRACE_IS WSB_TRACE_BIT_META
  18. HRESULT
  19. CVolAssign::GetVolAssign(
  20. OUT GUID *pBagId,
  21. OUT LONGLONG *pSegStartLoc,
  22. OUT LONGLONG *pSegLen,
  23. OUT GUID *pVolId
  24. )
  25. /*++
  26. Implements:
  27. IVolAssign::GetVolAssign
  28. --*/
  29. {
  30. HRESULT hr = S_OK;
  31. WsbTraceIn(OLESTR("CVolAssign::GetVolAssign"),OLESTR(""));
  32. try {
  33. //Make sure we can provide data memebers
  34. WsbAssert(0 != pBagId, E_POINTER);
  35. WsbAssert(0 != pSegStartLoc, E_POINTER);
  36. WsbAssert(0 != pSegLen, E_POINTER);
  37. WsbAssert(0 != pVolId, E_POINTER);
  38. //Provide the data members
  39. *pBagId = m_BagId;
  40. *pSegStartLoc = m_SegStartLoc;
  41. *pSegLen = m_SegLen;
  42. *pVolId = m_VolId;
  43. } WsbCatch(hr);
  44. WsbTraceOut(OLESTR("CVolAssign::GetVolAssign"),
  45. OLESTR("BagId = <%ls>, SegStartLoc = <%ls>, SegLen = <%ls>, VolId = <%ls>"),
  46. WsbPtrToGuidAsString(pBagId),
  47. WsbStringCopy(WsbPtrToLonglongAsString(pSegStartLoc)),
  48. WsbStringCopy(WsbPtrToLonglongAsString(pSegLen)),
  49. WsbStringCopy(WsbPtrToGuidAsString(pVolId)));
  50. return(hr);
  51. }
  52. HRESULT
  53. CVolAssign::FinalConstruct(
  54. void
  55. )
  56. /*++
  57. Routine Description:
  58. This method does some initialization of the object that is necessary
  59. after construction.
  60. Arguments:
  61. None.
  62. Return Value:
  63. S_OK
  64. Anything returned by CWsbDbEntity::FinalConstruct().
  65. --*/
  66. {
  67. HRESULT hr = S_OK;
  68. try {
  69. WsbAssertHr(CWsbDbEntity::FinalConstruct());
  70. m_BagId = GUID_NULL;
  71. m_SegStartLoc = 0;
  72. m_SegLen = 0;
  73. m_VolId = GUID_NULL;
  74. } WsbCatch(hr);
  75. return(hr);
  76. }
  77. HRESULT CVolAssign::GetClassID
  78. (
  79. OUT LPCLSID pclsid
  80. )
  81. /*++
  82. Implements:
  83. IPerist::GetClassID()
  84. --*/
  85. {
  86. HRESULT hr = S_OK;
  87. WsbTraceIn(OLESTR("CVolAssign::GetClassID"), OLESTR(""));
  88. try {
  89. WsbAssert(0 != pclsid, E_POINTER);
  90. *pclsid = CLSID_CVolAssign;
  91. } WsbCatch(hr);
  92. WsbTraceOut(OLESTR("CVolAssign::GetClassID"), OLESTR("hr = <%ls>, CLSID = <%ls>"), WsbHrAsString(hr), WsbGuidAsString(*pclsid));
  93. return(hr);
  94. }
  95. HRESULT CVolAssign::Load
  96. (
  97. IN IStream* pStream
  98. )
  99. /*++
  100. Implements:
  101. IPersistStream::Load().
  102. --*/
  103. {
  104. HRESULT hr = S_OK;
  105. WsbTraceIn(OLESTR("CVolAssign::Load"), OLESTR(""));
  106. try {
  107. WsbAssert(0 != pStream, E_POINTER);
  108. WsbAffirmHr(WsbLoadFromStream(pStream, &m_BagId));
  109. WsbAffirmHr(WsbLoadFromStream(pStream, &m_SegStartLoc));
  110. WsbAffirmHr(WsbLoadFromStream(pStream, &m_SegLen));
  111. WsbAffirmHr(WsbLoadFromStream(pStream, &m_VolId));
  112. } WsbCatch(hr);
  113. WsbTraceOut(OLESTR("CVolAssign::Load"),
  114. OLESTR("hr = <%ls>, GUID = <%ls>, SegStartLoc = <%ls>, SegLen = <%ls>, VolId = <%ls>"),
  115. WsbHrAsString(hr), WsbGuidAsString(m_BagId),
  116. WsbStringCopy(WsbLonglongAsString(m_SegStartLoc)),
  117. WsbStringCopy(WsbLonglongAsString(m_SegLen)),
  118. WsbStringCopy(WsbGuidAsString(m_VolId)));
  119. return(hr);
  120. }
  121. HRESULT CVolAssign::Print
  122. (
  123. IN IStream* pStream
  124. )
  125. /*++
  126. Implements:
  127. IWsbDbEntity::Print
  128. --*/
  129. {
  130. HRESULT hr = S_OK;
  131. WsbTraceIn(OLESTR("CVolAssign::Print"), OLESTR(""));
  132. try {
  133. WsbAssert(0 != pStream, E_POINTER);
  134. CWsbStringPtr strGuid;
  135. WsbAffirmHr(WsbSafeGuidAsString(m_BagId, strGuid));
  136. WsbAffirmHr(WsbPrintfToStream(pStream, OLESTR(" BagId = %ls"),
  137. (WCHAR *)strGuid));
  138. WsbAffirmHr(WsbPrintfToStream(pStream, OLESTR(", StartLoc = %ls"),
  139. WsbLonglongAsString(m_SegStartLoc)));
  140. WsbAffirmHr(WsbPrintfToStream(pStream, OLESTR(", SegLen = %ls"),
  141. WsbLonglongAsString(m_SegLen)));
  142. WsbAffirmHr(WsbSafeGuidAsString(m_VolId, strGuid));
  143. WsbAffirmHr(WsbPrintfToStream(pStream, OLESTR(" new VolId = %ls"),
  144. (WCHAR *)strGuid));
  145. WsbAffirmHr(CWsbDbEntity::Print(pStream));
  146. } WsbCatch(hr);
  147. WsbTraceOut(OLESTR("CVolAssign::Print"), OLESTR("hr = <%ls>"), WsbHrAsString(hr));
  148. return(hr);
  149. }
  150. HRESULT CVolAssign::Save
  151. (
  152. IN IStream* pStream,
  153. IN BOOL clearDirty
  154. )
  155. /*++
  156. Implements:
  157. IPersistStream::Save().
  158. --*/
  159. {
  160. HRESULT hr = S_OK;
  161. WsbTraceIn(OLESTR("CVolAssign::Save"), OLESTR("clearDirty = <%ls>"), WsbBoolAsString(clearDirty));
  162. try {
  163. WsbAssert(0 != pStream, E_POINTER);
  164. WsbAffirmHr(WsbSaveToStream(pStream, m_BagId));
  165. WsbAffirmHr(WsbSaveToStream(pStream, m_SegStartLoc));
  166. WsbAffirmHr(WsbSaveToStream(pStream, m_SegLen));
  167. WsbAffirmHr(WsbSaveToStream(pStream, m_VolId));
  168. // If we got it saved and we were asked to clear the dirty bit, then
  169. // do so now.
  170. if (clearDirty) {
  171. m_isDirty = FALSE;
  172. }
  173. } WsbCatch(hr);
  174. WsbTraceOut(OLESTR("CVolAssign::Save"), OLESTR("hr = <%ls>"), WsbHrAsString(hr));
  175. return(hr);
  176. }
  177. HRESULT
  178. CVolAssign::SetVolAssign
  179. (
  180. IN GUID BagId,
  181. IN LONGLONG SegStartLoc,
  182. IN LONGLONG SegLen,
  183. IN GUID VolId
  184. )
  185. /*++
  186. Implements:
  187. IVolAssign::SetVolAssign().
  188. --*/
  189. {
  190. WsbTraceIn(OLESTR("CVolAssign::SetVolAssign"),
  191. OLESTR("BagId = <%ls>, SegStartLoc = <%ls>, SegLen = <%ls>, VolId = <%ls>"),
  192. WsbGuidAsString(BagId),
  193. WsbStringCopy(WsbLonglongAsString(SegStartLoc)),
  194. WsbStringCopy(WsbLonglongAsString(SegLen)),
  195. WsbStringCopy(WsbGuidAsString(VolId)));
  196. m_isDirty = TRUE;
  197. m_BagId = BagId;
  198. m_SegStartLoc = SegStartLoc;
  199. m_SegLen = SegLen;
  200. m_VolId = VolId;
  201. WsbTraceOut(OLESTR("CVolAssign::SetVolAssign"), OLESTR("hr = <%ls>"),WsbHrAsString(S_OK));
  202. return(S_OK);
  203. }
  204. HRESULT
  205. CVolAssign::UpdateKey(
  206. IWsbDbKey *pKey
  207. )
  208. /*++
  209. Implements:
  210. IWsbDbEntity::UpdateKey
  211. --*/
  212. {
  213. HRESULT hr = S_OK;
  214. try {
  215. WsbAffirmHr(pKey->SetToGuid(m_BagId));
  216. WsbAffirmHr(pKey->AppendLonglong(m_SegStartLoc));
  217. } WsbCatch(hr);
  218. return(hr);
  219. }