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.

114 lines
2.8 KiB

  1. // Copyright (c) 1997-1999 Microsoft Corporation
  2. ///////////////////////////////////////////////////////////////////
  3. //
  4. // RefClint.h : Refresher client header file
  5. //
  6. // Created by a-dcrews and sanjes
  7. //
  8. ///////////////////////////////////////////////////////////////////
  9. #ifndef _REFCLINT_H_
  10. #define _REFCLINT_H_
  11. #include <wbemcli.h>
  12. ///////////////////////////////////////////////////////////////////
  13. //
  14. // Globals and constants
  15. //
  16. ///////////////////////////////////////////////////////////////////
  17. const long clNumInstances = 5; // The number of Win32_BasicHiPerf instances
  18. const DWORD cdwNumReps = 100; // The number of sample refreshes
  19. ///////////////////////////////////////////////////////////////////
  20. //
  21. // CRefresherMember
  22. //
  23. // This class facilitates the management of objects or enumerators
  24. // that have been added to the refresher and the unique ID assigned
  25. // to them.
  26. //
  27. ///////////////////////////////////////////////////////////////////
  28. template<class T>
  29. class CRefresherMember
  30. {
  31. T* m_pMember;
  32. long m_lID;
  33. public:
  34. CRefresherMember() : m_pMember( NULL ), m_lID( 0 ) {}
  35. virtual ~CRefresherMember() { if ( NULL != m_pMember) m_pMember->Release(); }
  36. void Set(T* pMember, long lID);
  37. void Reset();
  38. T* GetMember();
  39. long GetID(){ return m_lID; }
  40. };
  41. template <class T> inline void CRefresherMember<T>::Set(T* pMember, long lID)
  42. {
  43. if ( NULL != pMember )
  44. pMember->AddRef();
  45. m_pMember = pMember;
  46. m_lID = lID;
  47. }
  48. template <class T> inline void CRefresherMember<T>::Reset()
  49. {
  50. if (NULL != m_pMember)
  51. m_pMember->Release();
  52. m_pMember = NULL;
  53. m_lID = 0;
  54. }
  55. template <class T> inline T* CRefresherMember<T>::GetMember()
  56. {
  57. if ( NULL != m_pMember )
  58. m_pMember->AddRef();
  59. return m_pMember;
  60. }
  61. ///////////////////////////////////////////////////////////////////
  62. //
  63. // CRefresher
  64. //
  65. // This class encapsulates the basic functionality of a WMI client
  66. // using the high performance refresher interface.
  67. //
  68. ///////////////////////////////////////////////////////////////////
  69. class CRefresher
  70. {
  71. IWbemServices* m_pNameSpace; // A pointer to the namespace
  72. IWbemRefresher* m_pRefresher; // A pointer to the refresher
  73. IWbemConfigureRefresher* m_pConfig; // A pointer to the refresher's manager
  74. CRefresherMember<IWbemHiPerfEnum> m_Enum; // The enumerator added to the refresher
  75. CRefresherMember<IWbemObjectAccess> m_Instances[clNumInstances]; // The instances added to the refreshrer
  76. protected:
  77. HRESULT SetHandles(WCHAR * wscClass);
  78. public:
  79. CRefresher();
  80. virtual ~CRefresher();
  81. HRESULT Initialize(IWbemServices* pNameSpace, WCHAR * wcsClass);
  82. HRESULT AddObjects(WCHAR * wcsClass);
  83. HRESULT RemoveObjects();
  84. HRESULT EnumerateObjectData();
  85. HRESULT AddEnum(WCHAR * wcsClass);
  86. HRESULT RemoveEnum();
  87. HRESULT EnumerateEnumeratorData();
  88. HRESULT Refresh();
  89. };
  90. #endif //_REFCLINT_H_