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.

428 lines
9.9 KiB

  1. /*++
  2. Copyright (C) 1996-2001 Microsoft Corporation
  3. Module Name:
  4. Cache.H
  5. Abstract:
  6. History:
  7. --*/
  8. #ifndef _Server_Cache_H
  9. #define _Server_Cache_H
  10. #include <Allocator.h>
  11. #include <Algorithms.h>
  12. #include <TPQueue.h>
  13. #include <BasicTree.h>
  14. #include <Cache.h>
  15. #include "ProvRegInfo.h"
  16. /******************************************************************************
  17. *
  18. * Name:
  19. *
  20. *
  21. * Description:
  22. *
  23. *
  24. *****************************************************************************/
  25. extern LONG CompareElement ( const GUID &a_Arg1 , const GUID &a_Arg2 ) ;
  26. /******************************************************************************
  27. *
  28. * Name:
  29. *
  30. *
  31. * Description:
  32. *
  33. *
  34. *****************************************************************************/
  35. class ProviderCacheKey
  36. {
  37. public:
  38. BSTR m_User ;
  39. BSTR m_Locale ;
  40. Enum_Hosting m_HostingSpecification ;
  41. BSTR m_Provider ;
  42. bool m_Raw ;
  43. GUID *m_TransactionIdentifier ;
  44. public:
  45. ProviderCacheKey () :
  46. m_User ( NULL ) ,
  47. m_Locale ( NULL ) ,
  48. m_Raw ( false ) ,
  49. m_Provider ( NULL ) ,
  50. m_TransactionIdentifier ( NULL ) ,
  51. m_HostingSpecification ( e_Hosting_Undefined )
  52. {
  53. }
  54. ProviderCacheKey (
  55. const ProviderCacheKey &a_Key
  56. ) : m_User ( NULL ) ,
  57. m_Locale ( NULL ) ,
  58. m_TransactionIdentifier ( NULL ) ,
  59. m_Raw ( a_Key.m_Raw ) ,
  60. m_HostingSpecification ( a_Key.m_HostingSpecification ) ,
  61. m_Provider ( NULL )
  62. {
  63. if ( a_Key.m_User )
  64. {
  65. m_User = SysAllocString ( a_Key.m_User ) ;
  66. }
  67. if ( a_Key.m_Locale )
  68. {
  69. m_Locale = SysAllocString ( a_Key.m_Locale ) ;
  70. }
  71. if ( a_Key.m_Provider )
  72. {
  73. m_Provider = SysAllocString ( a_Key.m_Provider ) ;
  74. }
  75. if ( a_Key.m_TransactionIdentifier )
  76. {
  77. m_TransactionIdentifier = new GUID ;
  78. *m_TransactionIdentifier = *a_Key.m_TransactionIdentifier ;
  79. }
  80. }
  81. ProviderCacheKey (
  82. const wchar_t *a_Provider ,
  83. const Enum_Hosting &a_HostingSpecification ,
  84. const bool a_Raw ,
  85. GUID *a_TransactionIdentifier ,
  86. const wchar_t *a_User ,
  87. const wchar_t *a_Locale
  88. ) :
  89. m_Raw ( a_Raw ) ,
  90. m_Provider ( NULL ) ,
  91. m_HostingSpecification ( a_HostingSpecification ),
  92. m_TransactionIdentifier ( NULL ) ,
  93. m_User ( NULL ) ,
  94. m_Locale ( NULL )
  95. {
  96. if ( a_User )
  97. {
  98. m_User = SysAllocString ( a_User ) ;
  99. }
  100. if ( a_Locale )
  101. {
  102. m_Locale = SysAllocString ( a_Locale ) ;
  103. }
  104. if ( a_Provider )
  105. {
  106. m_Provider = SysAllocString ( a_Provider ) ;
  107. }
  108. if ( a_TransactionIdentifier )
  109. {
  110. m_TransactionIdentifier = new GUID ;
  111. *m_TransactionIdentifier = *a_TransactionIdentifier ;
  112. }
  113. }
  114. ~ProviderCacheKey ()
  115. {
  116. if ( m_User )
  117. {
  118. SysFreeString ( m_User ) ;
  119. }
  120. if ( m_Locale )
  121. {
  122. SysFreeString ( m_Locale ) ;
  123. }
  124. if ( m_Provider )
  125. {
  126. SysFreeString ( m_Provider ) ;
  127. }
  128. if ( m_TransactionIdentifier )
  129. {
  130. delete m_TransactionIdentifier ;
  131. }
  132. }
  133. ProviderCacheKey &operator= ( const ProviderCacheKey &a_Key )
  134. {
  135. m_Raw = a_Key.m_Raw ;
  136. m_HostingSpecification = a_Key.m_HostingSpecification ;
  137. if ( m_User )
  138. {
  139. SysFreeString ( m_User ) ;
  140. }
  141. if ( m_Locale )
  142. {
  143. SysFreeString ( m_Locale ) ;
  144. }
  145. if ( m_Provider )
  146. {
  147. SysFreeString ( m_Provider ) ;
  148. }
  149. if ( m_TransactionIdentifier )
  150. {
  151. delete m_TransactionIdentifier ;
  152. }
  153. if ( a_Key.m_User )
  154. {
  155. m_User = SysAllocString ( a_Key.m_User ) ;
  156. }
  157. if ( a_Key.m_Locale )
  158. {
  159. m_Locale = SysAllocString ( a_Key.m_Locale ) ;
  160. }
  161. if ( a_Key.m_Provider )
  162. {
  163. m_Provider = SysAllocString ( a_Key.m_Provider ) ;
  164. }
  165. if ( a_Key.m_TransactionIdentifier )
  166. {
  167. m_TransactionIdentifier = new GUID ;
  168. *m_TransactionIdentifier = *a_Key.m_TransactionIdentifier ;
  169. }
  170. return *this ;
  171. }
  172. LONG CompareUser ( const BSTR a_User ) const
  173. {
  174. if ( m_User && a_User )
  175. {
  176. return _wcsicmp ( m_User , a_User ) ;
  177. }
  178. else
  179. {
  180. return m_User == a_User ? 0 : ( m_User < a_User ) ? -1 : 1 ;
  181. }
  182. }
  183. LONG CompareLocale ( const BSTR a_Locale ) const
  184. {
  185. if ( m_Locale && a_Locale )
  186. {
  187. return _wcsicmp ( m_Locale , a_Locale ) ;
  188. }
  189. else
  190. {
  191. return m_Locale == a_Locale ? 0 : ( m_Locale < a_Locale ) ? -1 : 1 ;
  192. }
  193. }
  194. LONG CompareProvider ( const BSTR a_Provider ) const
  195. {
  196. if ( m_Provider && a_Provider )
  197. {
  198. return _wcsicmp ( m_Provider , a_Provider ) ;
  199. }
  200. else
  201. {
  202. return m_Provider == a_Provider ? 0 : ( m_Provider < a_Provider ) ? -1 : 1 ;
  203. }
  204. }
  205. LONG CompareTransaction ( const GUID *a_TransactionIdentifier ) const
  206. {
  207. if ( m_TransactionIdentifier && a_TransactionIdentifier )
  208. {
  209. return CompareElement ( *m_TransactionIdentifier , *a_TransactionIdentifier ) ;
  210. }
  211. else
  212. {
  213. return m_TransactionIdentifier == a_TransactionIdentifier ? 0 : ( m_TransactionIdentifier < a_TransactionIdentifier ) ? -1 : 1 ;
  214. }
  215. }
  216. LONG Compare ( const ProviderCacheKey &a_Key ) const
  217. {
  218. LONG t_CompareUser = CompareUser ( a_Key.m_User ) ;
  219. if ( t_CompareUser == 0 )
  220. {
  221. LONG t_CompareLocale = CompareLocale ( a_Key.m_Locale ) ;
  222. if ( t_CompareLocale == 0 )
  223. {
  224. if ( m_Raw == a_Key.m_Raw )
  225. {
  226. LONG t_CompareProvider = CompareProvider ( a_Key.m_Provider ) ;
  227. if ( t_CompareProvider == 0 )
  228. {
  229. if ( CompareTransaction ( a_Key.m_TransactionIdentifier ) == 0 )
  230. {
  231. return m_HostingSpecification - a_Key.m_HostingSpecification ;
  232. }
  233. else
  234. {
  235. return CompareElement ( m_TransactionIdentifier , a_Key.m_TransactionIdentifier ) ;
  236. }
  237. }
  238. else
  239. {
  240. return t_CompareProvider ;
  241. }
  242. }
  243. else
  244. {
  245. return m_Raw - a_Key.m_Raw ;
  246. }
  247. }
  248. else
  249. {
  250. return t_CompareLocale ;
  251. }
  252. }
  253. else
  254. {
  255. return t_CompareUser ;
  256. }
  257. }
  258. } ;
  259. /******************************************************************************
  260. *
  261. * Name:
  262. *
  263. *
  264. * Description:
  265. *
  266. *
  267. *****************************************************************************/
  268. extern LONG CompareElement ( const ProviderCacheKey &a_Arg1 , const ProviderCacheKey &a_Arg2 ) ;
  269. /******************************************************************************
  270. *
  271. * Name:
  272. *
  273. *
  274. * Description:
  275. *
  276. *
  277. *****************************************************************************/
  278. class CServerObject_BindingFactory ;
  279. /******************************************************************************
  280. *
  281. * Name:
  282. *
  283. *
  284. * Description:
  285. *
  286. *
  287. *****************************************************************************/
  288. class CInterceptor_IWbemProvider ;
  289. typedef WmiCacheController <ProviderCacheKey> CWbemGlobal_IWmiProviderController ;
  290. typedef CWbemGlobal_IWmiProviderController :: Cache CWbemGlobal_IWmiProviderController_Cache ;
  291. typedef CWbemGlobal_IWmiProviderController :: Cache_Iterator CWbemGlobal_IWmiProviderController_Cache_Iterator ;
  292. typedef CWbemGlobal_IWmiProviderController :: WmiCacheElement ServiceCacheElement ;
  293. /******************************************************************************
  294. *
  295. * Name:
  296. *
  297. *
  298. * Description:
  299. *
  300. *
  301. *****************************************************************************/
  302. class CInterceptor_IWbemObjectSink ;
  303. typedef WmiContainerController <void *> CWbemGlobal_IWmiObjectSinkController ;
  304. typedef CWbemGlobal_IWmiObjectSinkController :: Container CWbemGlobal_IWmiObjectSinkController_Container ;
  305. typedef CWbemGlobal_IWmiObjectSinkController :: Container_Iterator CWbemGlobal_IWmiObjectSinkController_Container_Iterator ;
  306. typedef CWbemGlobal_IWmiObjectSinkController :: WmiContainerElement ObjectSinkContainerElement ;
  307. /******************************************************************************
  308. *
  309. * Name:
  310. *
  311. *
  312. * Description:
  313. *
  314. *
  315. *****************************************************************************/
  316. class CServerObject_ProviderSubSystem ;
  317. typedef WmiContainerController <void *> CWbemGlobal_IWmiProvSubSysController ;
  318. typedef CWbemGlobal_IWmiProvSubSysController :: Container CWbemGlobal_IWmiProvSubSysController_Container ;
  319. typedef CWbemGlobal_IWmiProvSubSysController :: Container_Iterator CWbemGlobal_IWmiProvSubSysController_Container_Iterator ;
  320. typedef CWbemGlobal_IWmiProvSubSysController :: WmiContainerElement ProvSubSysContainerElement ;
  321. /******************************************************************************
  322. *
  323. * Name:
  324. *
  325. *
  326. * Description:
  327. *
  328. *
  329. *****************************************************************************/
  330. class CInterceptor_IWbemSyncProvider ;
  331. typedef WmiContainerController <GUID> CWbemGlobal_IWbemSyncProviderController ;
  332. typedef CWbemGlobal_IWbemSyncProviderController :: Container CWbemGlobal_IWbemSyncProvider_Container ;
  333. typedef CWbemGlobal_IWbemSyncProviderController :: Container_Iterator CWbemGlobal_IWbemSyncProvider_Container_Iterator ;
  334. typedef CWbemGlobal_IWbemSyncProviderController :: WmiContainerElement SyncProviderContainerElement ;
  335. /******************************************************************************
  336. *
  337. * Name:
  338. *
  339. *
  340. * Description:
  341. *
  342. *
  343. *****************************************************************************/
  344. typedef WmiContainerController <DWORD> CWbemGlobal_HostedProviderController ;
  345. typedef CWbemGlobal_HostedProviderController :: Container CWbemGlobal_HostedProviderController_Container ;
  346. typedef CWbemGlobal_HostedProviderController :: Container_Iterator CWbemGlobal_HostedProviderController_Container_Iterator ;
  347. typedef CWbemGlobal_HostedProviderController :: WmiContainerElement HostedProviderContainerElement ;
  348. /******************************************************************************
  349. *
  350. * Name:
  351. *
  352. *
  353. * Description:
  354. *
  355. *
  356. *****************************************************************************/
  357. #endif _Server_Cache_H