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.

309 lines
6.1 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. WsbAffirmHr(WsbPrintfToStream(pStream, OLESTR(" BagId = %ls"),
  135. WsbGuidAsString(m_BagId)));
  136. WsbAffirmHr(WsbPrintfToStream(pStream, OLESTR(", StartLoc = %ls"),
  137. WsbLonglongAsString(m_SegStartLoc)));
  138. WsbAffirmHr(WsbPrintfToStream(pStream, OLESTR(", SegLen = %ls"),
  139. WsbLonglongAsString(m_SegLen)));
  140. WsbAffirmHr(WsbPrintfToStream(pStream, OLESTR(" new VolId = %ls"),
  141. WsbGuidAsString(m_VolId)));
  142. WsbAffirmHr(CWsbDbEntity::Print(pStream));
  143. } WsbCatch(hr);
  144. WsbTraceOut(OLESTR("CVolAssign::Print"), OLESTR("hr = <%ls>"), WsbHrAsString(hr));
  145. return(hr);
  146. }
  147. HRESULT CVolAssign::Save
  148. (
  149. IN IStream* pStream,
  150. IN BOOL clearDirty
  151. )
  152. /*++
  153. Implements:
  154. IPersistStream::Save().
  155. --*/
  156. {
  157. HRESULT hr = S_OK;
  158. WsbTraceIn(OLESTR("CVolAssign::Save"), OLESTR("clearDirty = <%ls>"), WsbBoolAsString(clearDirty));
  159. try {
  160. WsbAssert(0 != pStream, E_POINTER);
  161. WsbAffirmHr(WsbSaveToStream(pStream, m_BagId));
  162. WsbAffirmHr(WsbSaveToStream(pStream, m_SegStartLoc));
  163. WsbAffirmHr(WsbSaveToStream(pStream, m_SegLen));
  164. WsbAffirmHr(WsbSaveToStream(pStream, m_VolId));
  165. // If we got it saved and we were asked to clear the dirty bit, then
  166. // do so now.
  167. if (clearDirty) {
  168. m_isDirty = FALSE;
  169. }
  170. } WsbCatch(hr);
  171. WsbTraceOut(OLESTR("CVolAssign::Save"), OLESTR("hr = <%ls>"), WsbHrAsString(hr));
  172. return(hr);
  173. }
  174. HRESULT
  175. CVolAssign::SetVolAssign
  176. (
  177. IN GUID BagId,
  178. IN LONGLONG SegStartLoc,
  179. IN LONGLONG SegLen,
  180. IN GUID VolId
  181. )
  182. /*++
  183. Implements:
  184. IVolAssign::SetVolAssign().
  185. --*/
  186. {
  187. WsbTraceIn(OLESTR("CVolAssign::SetVolAssign"),
  188. OLESTR("BagId = <%ls>, SegStartLoc = <%ls>, SegLen = <%ls>, VolId = <%ls>"),
  189. WsbGuidAsString(BagId),
  190. WsbStringCopy(WsbLonglongAsString(SegStartLoc)),
  191. WsbStringCopy(WsbLonglongAsString(SegLen)),
  192. WsbStringCopy(WsbGuidAsString(VolId)));
  193. m_isDirty = TRUE;
  194. m_BagId = BagId;
  195. m_SegStartLoc = SegStartLoc;
  196. m_SegLen = SegLen;
  197. m_VolId = VolId;
  198. WsbTraceOut(OLESTR("CVolAssign::SetVolAssign"), OLESTR("hr = <%ls>"),WsbHrAsString(S_OK));
  199. return(S_OK);
  200. }
  201. HRESULT
  202. CVolAssign::UpdateKey(
  203. IWsbDbKey *pKey
  204. )
  205. /*++
  206. Implements:
  207. IWsbDbEntity::UpdateKey
  208. --*/
  209. {
  210. HRESULT hr = S_OK;
  211. try {
  212. WsbAffirmHr(pKey->SetToGuid(m_BagId));
  213. WsbAffirmHr(pKey->AppendLonglong(m_SegStartLoc));
  214. } WsbCatch(hr);
  215. return(hr);
  216. }