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.

268 lines
6.0 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 2000 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // EvictServices.h
  7. //
  8. // Description:
  9. // EvictServices implementation.
  10. //
  11. // Maintained By:
  12. // Geoffrey Pease (GPease) 15-JUN-2000
  13. //
  14. //////////////////////////////////////////////////////////////////////////////
  15. #include "pch.h"
  16. #include "GroupHandle.h"
  17. #include "ResourceEntry.h"
  18. #include "IPrivatePostCfgResource.h"
  19. #include "EvictServices.h"
  20. DEFINE_THISCLASS("CEvictServices")
  21. // ************************************************************************
  22. //
  23. // Constructor / Destructor
  24. //
  25. // ************************************************************************
  26. //////////////////////////////////////////////////////////////////////////////
  27. //
  28. // HRESULT
  29. // CEvictServices::S_HrCreateInstance(
  30. // IUnknown ** ppunkOut
  31. // )
  32. //
  33. //////////////////////////////////////////////////////////////////////////////
  34. HRESULT
  35. CEvictServices::S_HrCreateInstance(
  36. IUnknown ** ppunkOut
  37. )
  38. {
  39. TraceFunc( "" );
  40. HRESULT hr = E_UNEXPECTED;
  41. Assert( ppunkOut != NULL );
  42. CEvictServices * pdummy = new CEvictServices;
  43. if ( pdummy != NULL )
  44. {
  45. hr = THR( pdummy->HrInit( ) );
  46. if ( SUCCEEDED( hr ) )
  47. {
  48. hr = THR( pdummy->TypeSafeQI( IUnknown, ppunkOut ) );
  49. }
  50. pdummy->Release( );
  51. }
  52. else
  53. {
  54. hr = E_OUTOFMEMORY;
  55. }
  56. HRETURN( hr );
  57. } // S_HrCreateInstance( )
  58. //////////////////////////////////////////////////////////////////////////////
  59. //
  60. // CEvictServices::CEvictServices( void )
  61. //
  62. //////////////////////////////////////////////////////////////////////////////
  63. CEvictServices::CEvictServices( void )
  64. {
  65. TraceFunc( "" );
  66. InterlockedIncrement( &g_cObjects );
  67. TraceFuncExit();
  68. } // CEvictServices( )
  69. //////////////////////////////////////////////////////////////////////////////
  70. //
  71. // HRESULT
  72. // CEvictServices::HrInit( void )
  73. //
  74. //////////////////////////////////////////////////////////////////////////////
  75. HRESULT
  76. CEvictServices::HrInit( void )
  77. {
  78. TraceFunc( "" );
  79. HRESULT hr = S_OK;
  80. // IUnknown stuff
  81. Assert( m_cRef == 0 );
  82. AddRef( ); // Add one count
  83. // Resource
  84. Assert( m_presentry == NULL );
  85. HRETURN( hr );
  86. } // HrInit( )
  87. //////////////////////////////////////////////////////////////////////////////
  88. //
  89. // CEvictServices::~CEvictServices( )
  90. //
  91. //////////////////////////////////////////////////////////////////////////////
  92. CEvictServices::~CEvictServices( )
  93. {
  94. TraceFunc( "" );
  95. InterlockedDecrement( &g_cObjects );
  96. TraceFuncExit();
  97. } // ~CEvictServices( )
  98. // ************************************************************************
  99. //
  100. // IUnknown
  101. //
  102. // ************************************************************************
  103. //////////////////////////////////////////////////////////////////////////////
  104. //
  105. // STDMETHODIMP
  106. // CEvictServices::QueryInterface(
  107. // REFIID riid,
  108. // LPVOID *ppv
  109. // )
  110. //
  111. //////////////////////////////////////////////////////////////////////////////
  112. STDMETHODIMP
  113. CEvictServices::QueryInterface(
  114. REFIID riid,
  115. LPVOID *ppv
  116. )
  117. {
  118. TraceQIFunc( riid, ppv );
  119. HRESULT hr = E_NOINTERFACE;
  120. if ( IsEqualIID( riid, IID_IUnknown ) )
  121. {
  122. *ppv = static_cast< IClusCfgResourceEvict * >( this );
  123. hr = S_OK;
  124. } // if: IUnknown
  125. else if ( IsEqualIID( riid, IID_IClusCfgResourceEvict ) )
  126. {
  127. *ppv = TraceInterface( __THISCLASS__, IClusCfgResourceEvict, this, 0 );
  128. hr = S_OK;
  129. } // else if: IClusCfgResourceEvict
  130. else if ( IsEqualIID( riid, IID_IPrivatePostCfgResource ) )
  131. {
  132. *ppv = TraceInterface( __THISCLASS__, IPrivatePostCfgResource, this, 0 );
  133. hr = S_OK;
  134. } // else if: IPrivatePostCfgResource
  135. if ( SUCCEEDED( hr ) )
  136. {
  137. ((IUnknown*) *ppv)->AddRef( );
  138. } // if: success
  139. QIRETURN( hr, riid );
  140. } // QueryInterface( )
  141. //////////////////////////////////////////////////////////////////////////////
  142. //
  143. // STDMETHODIMP_(ULONG)
  144. // CEvictServices::AddRef( void )
  145. //
  146. //////////////////////////////////////////////////////////////////////////////
  147. STDMETHODIMP_(ULONG)
  148. CEvictServices::AddRef( void )
  149. {
  150. TraceFunc( "[IUnknown]" );
  151. m_cRef ++; // apartment model
  152. RETURN( m_cRef );
  153. } // AddRef( )
  154. //////////////////////////////////////////////////////////////////////////////
  155. //
  156. // STDMETHODIMP_(ULONG)
  157. // CEvictServices::Release( void )
  158. //
  159. //////////////////////////////////////////////////////////////////////////////
  160. STDMETHODIMP_(ULONG)
  161. CEvictServices::Release( void )
  162. {
  163. TraceFunc( "[IUnknown]" );
  164. m_cRef --; // apartment model
  165. if ( m_cRef )
  166. RETURN( m_cRef );
  167. TraceDo( delete this );
  168. RETURN(0);
  169. } // Release( )
  170. //****************************************************************************
  171. //
  172. // IClusCfgResourceEvict
  173. //
  174. //****************************************************************************
  175. //////////////////////////////////////////////////////////////////////////////
  176. //
  177. // STDMETHODIMP
  178. // CEvictServices::DoSomethingCool( void )
  179. //
  180. //////////////////////////////////////////////////////////////////////////////
  181. STDMETHODIMP
  182. CEvictServices::DoSomethingCool( void )
  183. {
  184. TraceFunc( "[IClusCfgResourceEvict]" );
  185. HRESULT hr = THR( E_NOTIMPL );
  186. HRETURN( hr );
  187. } // DoSomethingCool( )
  188. //****************************************************************************
  189. //
  190. // IPrivatePostCfgResource
  191. //
  192. //****************************************************************************
  193. //////////////////////////////////////////////////////////////////////////////
  194. //
  195. // STDMETHODIMP
  196. // CEvictServices::SetEntry(
  197. // CResourceEntry * presentryIn
  198. // )
  199. //
  200. //////////////////////////////////////////////////////////////////////////////
  201. STDMETHODIMP
  202. CEvictServices::SetEntry(
  203. CResourceEntry * presentryIn
  204. )
  205. {
  206. TraceFunc( "[IPrivatePostCfgResource]" );
  207. HRESULT hr = S_OK;
  208. m_presentry = presentryIn;
  209. HRETURN( hr );
  210. } // SetEntry( )