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.

305 lines
6.8 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 2000-2001 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // EvictServices.h
  7. //
  8. // Description:
  9. // EvictServices implementation.
  10. //
  11. // Maintained By:
  12. // David Potter (DavidP) 14-JUN-2001
  13. // Geoffrey Pease (GPease) 15-JUN-2000
  14. //
  15. //////////////////////////////////////////////////////////////////////////////
  16. #include "Pch.h"
  17. #include "GroupHandle.h"
  18. #include "ResourceEntry.h"
  19. #include "IPrivatePostCfgResource.h"
  20. #include "EvictServices.h"
  21. DEFINE_THISCLASS("CEvictServices")
  22. // ************************************************************************
  23. //
  24. // Constructor / Destructor
  25. //
  26. // ************************************************************************
  27. //////////////////////////////////////////////////////////////////////////////
  28. //
  29. // HRESULT
  30. // CEvictServices::S_HrCreateInstance(
  31. // IUnknown ** ppunkOut
  32. // )
  33. //
  34. //////////////////////////////////////////////////////////////////////////////
  35. HRESULT
  36. CEvictServices::S_HrCreateInstance(
  37. IUnknown ** ppunkOut
  38. )
  39. {
  40. TraceFunc( "" );
  41. HRESULT hr = S_OK;
  42. CEvictServices * pes = NULL;
  43. Assert( ppunkOut != NULL );
  44. if ( ppunkOut == NULL )
  45. {
  46. hr = THR( E_POINTER );
  47. goto Cleanup;
  48. }
  49. pes = new CEvictServices;
  50. if ( pes == NULL )
  51. {
  52. hr = E_OUTOFMEMORY );
  53. goto Cleanup;
  54. }
  55. hr = THR( pes->HrInit() );
  56. if ( FAILED( hr ) )
  57. {
  58. goto Cleanup;
  59. hr = THR( pes->TypeSafeQI( IUnknown, ppunkOut ) );
  60. if ( FAILED( hr ) )
  61. {
  62. goto Cleanup;
  63. }
  64. Cleanup:
  65. if ( pes != NULL )
  66. {
  67. pes->Release();
  68. }
  69. HRETURN( hr );
  70. } //*** CEvictServices::S_HrCreateInstance
  71. //////////////////////////////////////////////////////////////////////////////
  72. //
  73. // CEvictServices::CEvictServices
  74. //
  75. //////////////////////////////////////////////////////////////////////////////
  76. CEvictServices::CEvictServices( void )
  77. : m_cRef( 1 )
  78. {
  79. TraceFunc( "" );
  80. InterlockedIncrement( &g_cObjects );
  81. TraceFuncExit();
  82. } //*** CEvictServices::CEvictServices
  83. //////////////////////////////////////////////////////////////////////////////
  84. //
  85. // HRESULT
  86. // CEvictServices::HrInit
  87. //
  88. //////////////////////////////////////////////////////////////////////////////
  89. HRESULT
  90. CEvictServices::HrInit( void )
  91. {
  92. TraceFunc( "" );
  93. HRESULT hr = S_OK;
  94. // IUnknown stuff
  95. Assert( m_cRef == 1 );
  96. // Resource
  97. Assert( m_presentry == NULL );
  98. HRETURN( hr );
  99. } //*** CEvictServices::HrInit
  100. //////////////////////////////////////////////////////////////////////////////
  101. //
  102. // CEvictServices::~CEvictServices
  103. //
  104. //////////////////////////////////////////////////////////////////////////////
  105. CEvictServices::~CEvictServices( void )
  106. {
  107. TraceFunc( "" );
  108. InterlockedDecrement( &g_cObjects );
  109. TraceFuncExit();
  110. } //*** CEvictServices::~CEvictServices
  111. // ************************************************************************
  112. //
  113. // IUnknown
  114. //
  115. // ************************************************************************
  116. //////////////////////////////////////////////////////////////////////////////
  117. //++
  118. //
  119. // CEvictServices::QueryInterface
  120. //
  121. // Description:
  122. // Query this object for the passed in interface.
  123. //
  124. // Arguments:
  125. // riidIn
  126. // Id of interface requested.
  127. //
  128. // ppvOut
  129. // Pointer to the requested interface.
  130. //
  131. // Return Value:
  132. // S_OK
  133. // If the interface is available on this object.
  134. //
  135. // E_NOINTERFACE
  136. // If the interface is not available.
  137. //
  138. // E_POINTER
  139. // ppvOut was NULL.
  140. //
  141. // Remarks:
  142. // None.
  143. //
  144. //--
  145. //////////////////////////////////////////////////////////////////////////////
  146. STDMETHODIMP
  147. CEvictServices::QueryInterface(
  148. REFIID riidIn
  149. , LPVOID * ppvOut
  150. )
  151. {
  152. TraceQIFunc( riidIn, ppvOut );
  153. HRESULT hr = S_OK;
  154. //
  155. // Validate arguments.
  156. //
  157. Assert( ppvOut != NULL );
  158. if ( ppvOut == NULL )
  159. {
  160. hr = THR( E_POINTER );
  161. goto Cleanup;
  162. }
  163. //
  164. // Handle known interfaces.
  165. //
  166. if ( IsEqualIID( riidIn, IID_IUnknown ) )
  167. {
  168. *ppvOut = static_cast< IClusCfgResourceEvict * >( this );
  169. } // if: IUnknown
  170. else if ( IsEqualIID( riidIn, IID_IClusCfgResourceEvict ) )
  171. {
  172. *ppvOut = TraceInterface( __THISCLASS__, IClusCfgResourceEvict, this, 0 );
  173. } // else if: IClusCfgResourceEvict
  174. else if ( IsEqualIID( riidIn, IID_IPrivatePostCfgResource ) )
  175. {
  176. *ppvOut = TraceInterface( __THISCLASS__, IPrivatePostCfgResource, this, 0 );
  177. } // else if: IPrivatePostCfgResource
  178. else
  179. {
  180. *ppvOut = NULL;
  181. hr = E_NOINTERFACE;
  182. }
  183. //
  184. // Add a reference to the interface if successful.
  185. //
  186. if ( SUCCEEDED( hr ) )
  187. {
  188. ((IUnknown *) *ppvOut)->AddRef();
  189. } // if: success
  190. Cleanup:
  191. QIRETURN_IGNORESTDMARSHALLING( hr, riidIn );
  192. } //*** CEvictServices::QueryInterface
  193. //////////////////////////////////////////////////////////////////////////////
  194. //
  195. // STDMETHODIMP_(ULONG)
  196. // CEvictServices::AddRef
  197. //
  198. //////////////////////////////////////////////////////////////////////////////
  199. STDMETHODIMP_( ULONG )
  200. CEvictServices::AddRef( void )
  201. {
  202. TraceFunc( "[IUnknown]" );
  203. InterlockedIncrement( &m_cRef );
  204. CRETURN( m_cRef );
  205. } //*** CEvictServices::AddRef
  206. //////////////////////////////////////////////////////////////////////////////
  207. //
  208. // STDMETHODIMP_(ULONG)
  209. // CEvictServices::Release
  210. //
  211. //////////////////////////////////////////////////////////////////////////////
  212. STDMETHODIMP_( ULONG )
  213. CEvictServices::Release( void )
  214. {
  215. TraceFunc( "[IUnknown]" );
  216. LONG cRef;
  217. cRef = InterlockedDecrement( &m_cRef );
  218. if ( cRef == 0 )
  219. {
  220. TraceDo( delete this );
  221. }
  222. CRETURN( cRef );
  223. } //*** CEvictServices::Release
  224. //****************************************************************************
  225. //
  226. // IPrivatePostCfgResource
  227. //
  228. //****************************************************************************
  229. //////////////////////////////////////////////////////////////////////////////
  230. //
  231. // STDMETHODIMP
  232. // CEvictServices::SetEntry(
  233. // CResourceEntry * presentryIn
  234. // )
  235. //
  236. //////////////////////////////////////////////////////////////////////////////
  237. STDMETHODIMP
  238. CEvictServices::SetEntry(
  239. CResourceEntry * presentryIn
  240. )
  241. {
  242. TraceFunc( "[IPrivatePostCfgResource]" );
  243. HRESULT hr = S_OK;
  244. m_presentry = presentryIn;
  245. HRETURN( hr );
  246. } //*** CEvictServices::SetEntry