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.

187 lines
4.8 KiB

  1. /*++
  2. Copyright (C) 1999-2001 Microsoft Corporation
  3. Module Name:
  4. CLASSBROKER.H
  5. Abstract:
  6. History:
  7. --*/
  8. #ifndef _CLASSBROKER_H_
  9. #define _CLASSBROKER_H_
  10. #include <windows.h>
  11. #include <wbemcomn.h>
  12. #include <wbemcli.h>
  13. #include <wbemint.h>
  14. #include "perfndb.h"
  15. #define WMI_ADAP_DEFAULT_OBJECT 238;
  16. class CClassBroker
  17. {
  18. protected:
  19. PERF_OBJECT_TYPE* m_pPerfObj;
  20. BOOL m_bCostly;
  21. WString m_wstrServiceName;
  22. WString m_wstrClassName;
  23. IWbemClassObject* m_pBaseClass;
  24. CPerfNameDb* m_pDefaultNameDb;
  25. HRESULT SetClassName( DWORD dwType, IWbemClassObject* pObj );
  26. virtual HRESULT SetClassQualifiers( IWbemClassObject* pObj, DWORD dwType, BOOL fIsDefault ) = 0;
  27. virtual HRESULT AddDefaultProperties( IWbemClassObject* pObj ) = 0;
  28. virtual HRESULT EnumProperties( DWORD dwType, IWbemClassObject* pObj ) = 0;
  29. virtual HRESULT SetPropertyQualifiers( PERF_COUNTER_DEFINITION* pCtrDefinition,
  30. DWORD dwType,
  31. BOOL fIsDefault,
  32. LPCWSTR pwcsPropertyName,
  33. IWbemClassObject* pClass,
  34. BOOL bBase ) = 0;
  35. virtual HRESULT AddProperty( PERF_COUNTER_DEFINITION* pCtrDefinition,
  36. DWORD dwType,
  37. BOOL fIsDefault,
  38. IWbemClassObject* pClass,
  39. WString &wstrLastCtrName,
  40. BOOL* pbLastCounterIsNotBase ) = 0;
  41. // Helper methods
  42. // ==============
  43. BOOL IsSingleton()
  44. {
  45. return ( PERF_NO_INSTANCES == m_pPerfObj->NumInstances );
  46. }
  47. HRESULT RemoveWhitespaceAndNonAlphaNum( WString& wstr );
  48. HRESULT ReplaceReserved( WString& wstr );
  49. public:
  50. CClassBroker( IWbemClassObject* pBaseClass, WString wstrClassName, CPerfNameDb* pDefaultNameDb );
  51. CClassBroker( PERF_OBJECT_TYPE* pPerfObj,
  52. BOOL bCostly,
  53. IWbemClassObject* pBaseClass,
  54. CPerfNameDb* pDefaultNameDb,
  55. WCHAR* pwcsServiceName );
  56. virtual ~CClassBroker();
  57. HRESULT Generate( DWORD dwType, IWbemClassObject** ppObj );
  58. };
  59. class CLocaleClassBroker : public CClassBroker
  60. {
  61. protected:
  62. CPerfNameDb* m_pLocaleNameDb;
  63. LANGID m_LangId;
  64. virtual HRESULT SetClassQualifiers( IWbemClassObject* pObj, DWORD dwType, BOOL fIsDefault );
  65. virtual HRESULT AddDefaultProperties( IWbemClassObject* pObj );
  66. virtual HRESULT EnumProperties( DWORD dwType, IWbemClassObject* pObj );
  67. virtual HRESULT SetPropertyQualifiers( PERF_COUNTER_DEFINITION* pCtrDefinition,
  68. DWORD dwType,
  69. BOOL fIsDefault,
  70. LPCWSTR pwcsPropertyName,
  71. IWbemClassObject* pClass,
  72. BOOL bBase );
  73. virtual HRESULT AddProperty( PERF_COUNTER_DEFINITION* pCtrDefinition,
  74. DWORD dwType,
  75. BOOL fIsDefault,
  76. IWbemClassObject* pClass,
  77. WString &wstrLastCtrName,
  78. BOOL* pbLastCounterIsNotBase );
  79. public:
  80. CLocaleClassBroker( IWbemClassObject* pBaseClass,
  81. WString wstrClassName,
  82. CPerfNameDb* pDefaultNameDb,
  83. CPerfNameDb* pLocaleNameDb );
  84. CLocaleClassBroker( PERF_OBJECT_TYPE* pPerfObj,
  85. BOOL bCostly,
  86. IWbemClassObject* pBaseClass,
  87. CPerfNameDb* pDefaultNameDb,
  88. CPerfNameDb* pLocaleNameDb,
  89. LANGID LangId,
  90. WCHAR* pwcsServiceName );
  91. ~CLocaleClassBroker();
  92. static HRESULT GenPerfClass( PERF_OBJECT_TYPE* pPerfObj,
  93. DWORD dwType,
  94. BOOL bCostly,
  95. IWbemClassObject* pBaseClass,
  96. CPerfNameDb* pDefaultNameDb,
  97. CPerfNameDb* pLocaleNameDb,
  98. LANGID LangId,
  99. WCHAR* pwcsServiceName,
  100. IWbemClassObject** ppObj);
  101. static HRESULT ConvertToLocale( IWbemClassObject* pDefaultObject,
  102. CLocaleDefn* pLocaleDefn,
  103. CLocaleDefn* pDefaultDefn,
  104. IWbemClassObject** ppObject );
  105. };
  106. class CDefaultClassBroker : public CClassBroker
  107. {
  108. protected:
  109. virtual HRESULT SetClassQualifiers( IWbemClassObject* pObj, DWORD dwType, BOOL fIsDefault );
  110. virtual HRESULT AddDefaultProperties( IWbemClassObject* pObj );
  111. virtual HRESULT EnumProperties( DWORD dwType, IWbemClassObject* pObj );
  112. virtual HRESULT SetPropertyQualifiers( PERF_COUNTER_DEFINITION* pCtrDefinition,
  113. DWORD dwType,
  114. BOOL fIsDefault,
  115. LPCWSTR pwcsPropertyName,
  116. IWbemClassObject* pClass,
  117. BOOL bBase );
  118. virtual HRESULT AddProperty( PERF_COUNTER_DEFINITION* pCtrDefinition,
  119. DWORD dwType,
  120. BOOL fIsDefault,
  121. IWbemClassObject* pClass,
  122. WString &wstrLastCtrName,
  123. BOOL* pbLastCounterIsNotBase );
  124. public:
  125. CDefaultClassBroker( PERF_OBJECT_TYPE* pPerfObj,
  126. BOOL bCostly,
  127. IWbemClassObject* pBaseClass,
  128. CPerfNameDb* pDefaultNameDb,
  129. WCHAR* pwcsServiceName )
  130. : CClassBroker( pPerfObj, bCostly, pBaseClass, pDefaultNameDb, pwcsServiceName ) {}
  131. static HRESULT GenPerfClass( PERF_OBJECT_TYPE* pPerfObj,
  132. DWORD dwType,
  133. BOOL bCostly,
  134. IWbemClassObject* pBaseClass,
  135. CPerfNameDb* pDefaultNameDb,
  136. WCHAR* pwcsServiceName,
  137. IWbemClassObject** ppObj);
  138. };
  139. #endif // _BROKERS_H_