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.

174 lines
4.5 KiB

  1. //
  2. // Copyright (c) 1997-2001 Microsoft Corporation, All Rights Reserved
  3. //
  4. // ***************************************************************************
  5. //
  6. // Original Author: Rajesh Rao
  7. //
  8. // $Author: rajeshr $
  9. // $Date: 6/11/98 4:43p $
  10. // $Workfile:wbemcach.h $
  11. //
  12. // $Modtime: 6/11/98 11:21a $
  13. // $Revision: 1 $
  14. // $Nokeywords: $
  15. //
  16. //
  17. // Description: Cache for WBEM Class objects
  18. //
  19. //***************************************************************************
  20. #ifndef WBEM_CACHE_H
  21. #define WBEM_CACHE_H
  22. // This encapsulates a WBEM Class object
  23. class CWbemClass : public CRefCountedObject
  24. {
  25. private:
  26. IWbemClassObject *m_pWbemClass;
  27. public:
  28. static DWORD dwCWbemClassCount;
  29. CWbemClass(LPCWSTR pszWbemClassName, IWbemClassObject *pWbemClass)
  30. : CRefCountedObject(pszWbemClassName)
  31. {
  32. dwCWbemClassCount++;
  33. m_pWbemClass = pWbemClass;
  34. m_pWbemClass->AddRef();
  35. }
  36. ~CWbemClass()
  37. {
  38. dwCWbemClassCount--;
  39. m_pWbemClass->Release();
  40. }
  41. IWbemClassObject *GetWbemClass()
  42. {
  43. m_pWbemClass->AddRef();
  44. return m_pWbemClass;
  45. }
  46. };
  47. // This encapsulates subclass enumeration (deep) of a WBEM class
  48. class CEnumInfo : public CRefCountedObject
  49. {
  50. private:
  51. CNamesList *m_pClassNameList;
  52. public:
  53. static DWORD dwCEnumInfoCount;
  54. CEnumInfo(LPCWSTR pszWbemSuperClassName, CNamesList *pClassNameList)
  55. : CRefCountedObject(pszWbemSuperClassName)
  56. {
  57. dwCEnumInfoCount++;
  58. m_pClassNameList = pClassNameList;
  59. }
  60. ~CEnumInfo()
  61. {
  62. dwCEnumInfoCount--;
  63. delete m_pClassNameList;
  64. }
  65. CNamesList *GetSubClassNames()
  66. {
  67. return m_pClassNameList;
  68. }
  69. };
  70. class CWbemCache
  71. {
  72. private:
  73. // The storage for cached classes
  74. CObjectTree m_objectTree;
  75. // The storage for enumeration information
  76. CObjectTree m_EnumTree;
  77. // Cache configuration parameters
  78. static const __int64 MAX_CACHE_AGE; // In seconds
  79. static const DWORD MAX_CACHE_SIZE;
  80. static DWORD dwWBEMCacheCount;
  81. public:
  82. //***************************************************************************
  83. //
  84. // CWbemCache::CLDAPCache
  85. //
  86. // Purpose : Constructor. Creates an empty cache
  87. //
  88. // Parameters:
  89. //***************************************************************************
  90. CWbemCache();
  91. //***************************************************************************
  92. //
  93. // CWbemCache::GetClass
  94. //
  95. // Purpose : Retreives the IDirectory interface of an LDAP Class
  96. //
  97. // Parameters:
  98. // lpszClassName : The WBEM name of the Class to be retreived.
  99. // ppWbemClass : The address of the pointer where the CWbemClass object will be placed
  100. //
  101. // Return value:
  102. // The COM value representing the return status. The user should release the WBEM cclass
  103. // when done.
  104. //
  105. //***************************************************************************
  106. HRESULT GetClass(LPCWSTR lpszWbemClassName, CWbemClass **ppWbemClass );
  107. //***************************************************************************
  108. //
  109. // CWbemCache::AddClass
  110. //
  111. // Purpose : Adds the CWbemClass object to the cache
  112. //
  113. // Parameters:
  114. // ppWbemClass : The CWbemClass pointer of the object to be added
  115. //
  116. // Return value:
  117. // The COM value representing the return status.
  118. // when done.
  119. //
  120. //***************************************************************************
  121. HRESULT AddClass(CWbemClass *pWbemClass );
  122. //***************************************************************************
  123. //
  124. // CEnumCache::GetEnumInfo
  125. //
  126. // Purpose : Retreives the CEnumInfo object of a WBEM class
  127. //
  128. // Parameters:
  129. // lpszWbemClassName : The WBEM name of the Class to be retreived.
  130. // ppEnumInfo : The address of the pointer where the CEnumInfo object will be placed
  131. //
  132. // Return value:
  133. // The COM value representing the return status. The user should release the WBEM cclass
  134. // when done.
  135. //
  136. //***************************************************************************
  137. HRESULT GetEnumInfo(LPCWSTR lpszWbemClassName, CEnumInfo **ppEnumInfo );
  138. //***************************************************************************
  139. //
  140. // CEnumCache::AddEnumInfo
  141. //
  142. // Purpose : Adds the CEnumInfo object to the cache
  143. //
  144. // Parameters:
  145. // ppWbemClass : The CEnumInfo pointer of the object to be added
  146. //
  147. // Return value:
  148. // The COM value representing the return status.
  149. // when done.
  150. //
  151. //***************************************************************************
  152. HRESULT AddEnumInfo(CEnumInfo *pEnumInfo);
  153. };
  154. #endif /* WBEM_CACHE_H */