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.

148 lines
4.0 KiB

  1. /*++
  2. Copyright (C) 1997-2001 Microsoft Corporation
  3. Module Name:
  4. Abstract:
  5. History:
  6. --*/
  7. //***************************************************************************
  8. //
  9. // REFRESHR.H
  10. //
  11. //***************************************************************************
  12. #ifndef _REFRESHR_H_
  13. #define _REFRESHR_H_
  14. //***************************************************************************
  15. //
  16. //***************************************************************************
  17. struct CachedInst
  18. {
  19. LPWSTR m_pName; // Instance name
  20. IWbemObjectAccess *m_pInst; // Pointer to WBEM object
  21. LONG m_lId; // ID for this object
  22. CachedInst() { m_pName = 0; m_pInst = 0; m_lId = 0; }
  23. ~CachedInst() { delete [] m_pName; if (m_pInst) m_pInst->Release(); }
  24. };
  25. typedef CachedInst *PCachedInst;
  26. //***************************************************************************
  27. //
  28. // RefresherCacheEl
  29. //
  30. // Each CNt5Refresher has a cache of <RefresherCacheEl> elements. There
  31. // is one RefresherCacheEl struct for each class of object in the refresher.
  32. //
  33. // As each object is added to the refresher, we locate the corresponding
  34. // <RefresherCacheEl> for the class of the object. We then add the
  35. // instance into the instance cache of the <RefresherCacheEl>. If there
  36. // is no RefresherCacheEl, we create one.
  37. //
  38. // For singleton instances, we simply special case by having a dedicated
  39. // pointer.
  40. //
  41. // For multi-instance counters, we use a binary search lookup.
  42. //
  43. //***************************************************************************
  44. // ok
  45. struct RefresherCacheEl
  46. {
  47. DWORD m_dwPerfObjIx; // Perf object index for Class Def
  48. CClassMapInfo *m_pClassMap; // WBEM Class def stuff
  49. IWbemObjectAccess *m_pSingleton; // Optional Singleton instance
  50. LONG m_lSingletonId;
  51. CFlexArray m_aInstances; // Instance list for non-singleton
  52. // of CachedInst pointers.
  53. RefresherCacheEl();
  54. ~RefresherCacheEl();
  55. IWbemObjectAccess *FindInst(LPWSTR pszName); // Already scoped by class
  56. BOOL RemoveInst(LONG lId);
  57. BOOL InsertInst(IWbemObjectAccess *p, LONG lNewId);
  58. };
  59. typedef RefresherCacheEl *PRefresherCacheEl;
  60. class CNt5Refresher : public IWbemRefresher
  61. {
  62. LONG m_lRef;
  63. LONG m_lProbableId;
  64. CFlexArray m_aCache;
  65. // Pointers to RefresherCacheEl objects which contain
  66. // all classes and their instances used in this refresher.
  67. public:
  68. CNt5Refresher();
  69. ~CNt5Refresher();
  70. // Interface members.
  71. // ==================
  72. ULONG STDMETHODCALLTYPE AddRef();
  73. ULONG STDMETHODCALLTYPE Release();
  74. STDMETHODIMP QueryInterface(REFIID riid, void** ppv);
  75. // Primary WBEM method for updating.
  76. // =================================
  77. virtual HRESULT STDMETHODCALLTYPE Refresh(/* [in] */ long lFlags);
  78. // Private members used by NTPERF.CPP
  79. // ==================================
  80. BOOL AddObject(
  81. IN IWbemObjectAccess *pObj, // Object to add
  82. IN CClassMapInfo *pClsMap, // Class of object
  83. OUT LONG *plId // The id of the object added
  84. );
  85. BOOL RemoveObject(LONG lId);
  86. CClassMapInfo * FindClassMap(
  87. DWORD dwObjectTitleIx
  88. );
  89. BOOL FindSingletonInst(
  90. IN DWORD dwPerfObjIx,
  91. OUT IWbemObjectAccess **pInst,
  92. OUT CClassMapInfo **pClsMap
  93. );
  94. BOOL FindInst(
  95. IN DWORD dwObjectClassIx,
  96. IN LPWSTR pszInstName,
  97. OUT IWbemObjectAccess **pInst,
  98. OUT CClassMapInfo **pClsMap
  99. );
  100. BOOL GetObjectIds(DWORD *pdwNumIds, DWORD **pdwIdList);
  101. // Use operator delete on returned <pdwIdList>
  102. LONG FindUnusedId();
  103. // Returns -1 on error or an unused id.
  104. PRefresherCacheEl GetCacheEl(CClassMapInfo *pClsMap);
  105. BOOL AddNewCacheEl(
  106. IN CClassMapInfo *pClsMap,
  107. PRefresherCacheEl *pOutput
  108. );
  109. };
  110. #endif