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.

209 lines
5.3 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1991 - 2000.
  5. //
  6. // File: WrapStor.cxx
  7. //
  8. // Contents: Persistent property store (external to docfile)
  9. //
  10. // Classes: CPropertyIterWrapper
  11. //
  12. // History: 09-Apr-97 KrishnaN Created
  13. // 22-Apr-97 KrishnaN Modified to work with propstoremgr.
  14. //
  15. //----------------------------------------------------------------------------
  16. #include <pch.cxx>
  17. #pragma hdrstop
  18. #include <wrapiter.hxx>
  19. //+---------------------------------------------------------------------------
  20. //
  21. // Member: CPropertyIterWrapper::CPropertyIterWrapper, public
  22. //
  23. // Arguments: [propstore] - Reference to the property store to iterate.
  24. //
  25. // Returns: Nothing.
  26. //
  27. // History: 09-Apr-97 KrishnaN Created.
  28. //
  29. //----------------------------------------------------------------------------
  30. CPropertyIterWrapper::CPropertyIterWrapper ( CPropStoreManager & propstoremgr ) :
  31. _lRefCount( 1 ),
  32. _pPropStoreWids( 0 )
  33. {
  34. _pPropStoreWids = new CPropertyStoreWids( propstoremgr );
  35. }
  36. //+---------------------------------------------------------------------------
  37. //
  38. // Member: CPropertyIterWrapper::~CPropertyIterWrapper, public
  39. //
  40. // Arguments: None
  41. //
  42. // Returns: Nothing
  43. //
  44. // History: 09-Apr-97 KrishnaN Created.
  45. //
  46. //----------------------------------------------------------------------------
  47. CPropertyIterWrapper::~CPropertyIterWrapper ()
  48. {
  49. delete _pPropStoreWids;
  50. }
  51. //+---------------------------------------------------------------------------
  52. //
  53. // Member: CPropertyIterWrapper::Reset, public
  54. //
  55. // Arguments: None
  56. //
  57. // Returns:
  58. //
  59. // History: 09-Apr-97 KrishnaN Created.
  60. //
  61. // To implement this, go to propiter.cxx and do the following
  62. // in a new method, Reset()
  63. // get a lock; release the buffer; set the _wid to 1
  64. //----------------------------------------------------------------------------
  65. //+---------------------------------------------------------------------------
  66. //
  67. // Member: CPropertyIterWrapper::AddRef, public
  68. //
  69. // Returns: Reference count on object.
  70. //
  71. // History: 09-Apr-97 KrishnaN Created.
  72. //
  73. //----------------------------------------------------------------------------
  74. ULONG CPropertyIterWrapper::AddRef()
  75. {
  76. return InterlockedIncrement(&_lRefCount);
  77. }
  78. //+---------------------------------------------------------------------------
  79. //
  80. // Member: CPropertyIterWrapper::Release, public
  81. //
  82. // Returns: Reference count on object.
  83. //
  84. // History: 09-Apr-97 KrishnaN Created.
  85. //
  86. //----------------------------------------------------------------------------
  87. ULONG CPropertyIterWrapper::Release()
  88. {
  89. LONG lRef;
  90. lRef = InterlockedDecrement(&_lRefCount);
  91. if ( lRef <= 0 )
  92. delete this;
  93. return lRef;
  94. }
  95. //+---------------------------------------------------------------------------
  96. //
  97. // Member: CPropertyIterWrapper::WorkId, public
  98. //
  99. // Returns: Current workid, or widInvalid if at end.
  100. //
  101. // History: 08-Apr-97 KrishnaN Created.
  102. //
  103. //----------------------------------------------------------------------------
  104. SCODE CPropertyIterWrapper::GetWorkId(WORKID &wid)
  105. {
  106. SCODE sc = S_OK;
  107. TRY
  108. {
  109. wid = _pPropStoreWids->WorkId();
  110. }
  111. CATCH(CException, e)
  112. {
  113. sc = e.GetErrorCode();
  114. wid = widInvalid;
  115. ciDebugOut((DEB_ERROR, "CPropertyIterWrapper::GetNextWorkId caught exception 0x%X\n", sc));
  116. }
  117. END_CATCH
  118. return sc;
  119. }
  120. //+---------------------------------------------------------------------------
  121. //
  122. // Member: CPropertyIterWrapper::GetNextWorkId, public
  123. //
  124. // Arguments:
  125. //
  126. // Returns: Next work id.
  127. //
  128. // History: 09-Apr-97 KrishnaN Created.
  129. //
  130. //----------------------------------------------------------------------------
  131. SCODE CPropertyIterWrapper::GetNextWorkId (WORKID &wid)
  132. {
  133. SCODE sc = S_OK;
  134. TRY
  135. {
  136. wid = _pPropStoreWids->NextWorkId();
  137. }
  138. CATCH(CException, e)
  139. {
  140. sc = e.GetErrorCode();
  141. ciDebugOut((DEB_ERROR, "CPropertyIterWrapper::GetNextWorkId caught exception 0x%X\n", sc));
  142. wid = widInvalid;
  143. }
  144. END_CATCH
  145. return sc;
  146. }
  147. //+---------------------------------------------------------------------------
  148. //
  149. // Member: CreateWrapStor, public
  150. //
  151. // Arguments: [pPropStore] is the property store to iterate
  152. // [ppPropStoreIter] receives the created iterator
  153. //
  154. // Returns: PPropertyStorage object
  155. //
  156. // History: 08-Apr-97 KrishnaN Created.
  157. //
  158. //----------------------------------------------------------------------------
  159. SCODE CreatePropertyStoreIter( PPropertyStore * pPropStore,
  160. PPropertyStoreIter ** ppPropStoreIter )
  161. {
  162. if (0 == pPropStore || 0 == ppPropStoreIter)
  163. return E_INVALIDARG;
  164. *ppPropStoreIter = 0;
  165. SCODE sc = S_OK;
  166. TRY
  167. {
  168. CPropStoreManager *pcps = ((CPropertyStoreWrapper *)pPropStore)->_GetCPropertyStore();
  169. *ppPropStoreIter = new CPropertyIterWrapper (*pcps);
  170. }
  171. CATCH( CException, e)
  172. {
  173. sc = e.GetErrorCode();
  174. ciDebugOut((DEB_ERROR, "CreatePropertyStoreIter caught exception 0x%X\n", sc));
  175. }
  176. END_CATCH
  177. return sc;
  178. }