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.

182 lines
5.7 KiB

  1. /*++
  2. Copyright (C) 1998-1999 Microsoft Corporation
  3. Module Name:
  4. refreshr.h
  5. Abstract:
  6. <abstract>
  7. --*/
  8. #ifndef _REFRESHR_H_
  9. #define _REFRESHR_H_
  10. #include "ntperf.h"
  11. #include "perfacc.h"
  12. #include "utils.h"
  13. //***************************************************************************
  14. //
  15. //***************************************************************************
  16. struct CachedInst
  17. {
  18. LPWSTR m_pName; // Full Instance name
  19. IWbemObjectAccess *m_pInst; // Pointer to WBEM object
  20. LONG m_lId; // ID for this object
  21. LPWSTR m_szParentName; // parsed parent name from full name
  22. LPWSTR m_szInstanceName; // parsed instance name from full name
  23. DWORD m_dwIndex; // index parsed from full instance name
  24. CachedInst() { m_pName = 0;
  25. m_pInst = 0;
  26. m_lId = 0;
  27. m_szParentName = 0;
  28. m_szInstanceName = 0;
  29. m_dwIndex = 0;
  30. }
  31. ~CachedInst() { if (m_pInst) m_pInst->Release();
  32. if (m_pName) delete (m_pName);
  33. if (m_szParentName) delete (m_szParentName);
  34. if (m_szInstanceName) delete (m_szInstanceName);
  35. }
  36. };
  37. typedef CachedInst *PCachedInst;
  38. //***************************************************************************
  39. //
  40. // RefresherCacheEl
  41. //
  42. // Each CNt5Refresher has a cache of <RefresherCacheEl> elements. There
  43. // is one RefresherCacheEl struct for each class of object in the refresher.
  44. //
  45. // As each object is added to the refresher, we locate the corresponding
  46. // <RefresherCacheEl> for the class of the object. We then add the
  47. // instance into the instance cache of the <RefresherCacheEl>. If there
  48. // is no RefresherCacheEl, we create one.
  49. //
  50. // For singleton instances, we simply special case by having a dedicated
  51. // pointer.
  52. //
  53. // For multi-instance counters, we use a binary search lookup.
  54. //
  55. //***************************************************************************
  56. // ok
  57. struct RefresherCacheEl
  58. {
  59. DWORD m_dwPerfObjIx; // Perf object index for Class Def
  60. CClassMapInfo *m_pClassMap; // WBEM Class def stuff
  61. IWbemObjectAccess *m_pSingleton; // Optional Singleton instance
  62. LONG m_lSingletonId;
  63. CFlexArray m_aInstances; // Instance list for non-singleton
  64. // of CachedInst pointers.
  65. CFlexArray m_aEnumInstances; // array of IWbemObjectAccess pointers
  66. LONG *m_plIds; // array of ID's
  67. LONG m_lEnumArraySize; // size of enum item array in elements
  68. IWbemHiPerfEnum *m_pHiPerfEnum; // interface for hi perf enumerator
  69. LONG m_lEnumId; // id of the enumerator
  70. RefresherCacheEl();
  71. ~RefresherCacheEl();
  72. IWbemObjectAccess *FindInst(LPWSTR pszName); // Already scoped by class
  73. BOOL RemoveInst(LONG lId);
  74. BOOL InsertInst(IWbemObjectAccess **pp, LONG lNewId);
  75. // support for enumerator objects
  76. BOOL CreateEnum(IWbemHiPerfEnum *p, LONG lNewId);
  77. BOOL DeleteEnum(LONG lId);
  78. };
  79. typedef RefresherCacheEl *PRefresherCacheEl;
  80. // used by flags arg of AddObject Method
  81. #define REFRESHER_ADD_OBJECT_ADD_ITEM ((DWORD)0)
  82. #define REFRESHER_ADD_OBJECT_ADD_ENUM ((DWORD)0x00000001)
  83. class CNt5Refresher : public IWbemRefresher
  84. {
  85. HANDLE m_hAccessMutex;
  86. LONG m_lRef;
  87. LONG m_lProbableId;
  88. CFlexArray m_aCache;
  89. CNt5PerfProvider *m_pPerfProvider; // back pointer to provider if used
  90. DWORD m_dwGetGetNextClassIndex;
  91. CNt5PerfProvider::enumCLSID m_ClsidType;
  92. friend PerfHelper;
  93. public:
  94. CNt5Refresher(CNt5PerfProvider *pPerfProvider = NULL);
  95. ~CNt5Refresher();
  96. CPerfObjectAccess m_PerfObj;
  97. // Interface members.
  98. // ==================
  99. ULONG STDMETHODCALLTYPE AddRef();
  100. ULONG STDMETHODCALLTYPE Release();
  101. STDMETHODIMP QueryInterface(REFIID riid, void** ppv);
  102. // Primary WBEM method for updating.
  103. // =================================
  104. virtual HRESULT STDMETHODCALLTYPE Refresh(/* [in] */ long lFlags);
  105. // Private members used by NTPERF.CPP
  106. // ==================================
  107. BOOL AddObject(
  108. IN IWbemObjectAccess **ppObj, // Object to add
  109. IN CClassMapInfo *pClsMap, // Class of object
  110. OUT LONG *plId // The id of the object added
  111. );
  112. BOOL RemoveObject(LONG lId);
  113. BOOL AddEnum (
  114. IN IWbemHiPerfEnum *pEnum, // enum interface pointer
  115. IN CClassMapInfo *pClsMap, // Class of object
  116. OUT LONG *plId // id for new enum
  117. );
  118. CClassMapInfo * FindClassMap(
  119. DWORD dwObjectTitleIx
  120. );
  121. BOOL FindSingletonInst(
  122. IN DWORD dwPerfObjIx,
  123. OUT IWbemObjectAccess **pInst,
  124. OUT CClassMapInfo **pClsMap
  125. );
  126. BOOL FindInst(
  127. IN DWORD dwObjectClassIx,
  128. IN LPWSTR pszInstName,
  129. OUT IWbemObjectAccess **pInst,
  130. OUT CClassMapInfo **pClsMap
  131. );
  132. BOOL GetObjectIds(DWORD *pdwNumIds, DWORD **pdwIdList);
  133. // Use operator delete on returned <pdwIdList>
  134. LONG FindUnusedId();
  135. // Returns -1 on error or an unused id.
  136. PRefresherCacheEl GetCacheEl(CClassMapInfo *pClsMap);
  137. BOOL AddNewCacheEl(
  138. IN CClassMapInfo *pClsMap,
  139. PRefresherCacheEl *pOutput
  140. );
  141. };
  142. #endif