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.

192 lines
7.8 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 2000.
  5. //
  6. // File: idqreg.cxx
  7. //
  8. // Contents: CIdqRegParams class
  9. //
  10. // History: 22 Oct 97 AlanW Created from params.cxx
  11. //
  12. //--------------------------------------------------------------------------
  13. #include <pch.cxx>
  14. #pragma hdrstop
  15. #include <ciregkey.hxx>
  16. #include <regacc.hxx>
  17. #include <params.hxx>
  18. const WCHAR * IS_DEFAULT_CATALOG_DIRECTORY = L"web";
  19. //+-------------------------------------------------------------------------
  20. //
  21. // Member: CIdqRegParams::CIdqRegParams, public
  22. //
  23. // Synopsis: Constructor for registry param object
  24. //
  25. // Arguments: - NONE -
  26. //
  27. // History: 12-Oct-96 dlee Created
  28. //
  29. //--------------------------------------------------------------------------
  30. CIdqRegParams::CIdqRegParams( )
  31. {
  32. SetDefault();
  33. Refresh( );
  34. } //CIdqRegParams
  35. //+-------------------------------------------------------------------------
  36. //
  37. // Member: CIdqRegVars::SetDefault, public
  38. //
  39. // Synopsis: Sets default values for registry params
  40. //
  41. // History: 12-Oct-96 dlee Added header
  42. //
  43. //--------------------------------------------------------------------------
  44. void CIdqRegVars::SetDefault()
  45. {
  46. _maxISRowsInResultSet = IS_MAX_ROWS_IN_RESULT_DEFAULT;
  47. _maxISQueryCache = IS_MAX_ENTRIES_IN_CACHE_DEFAULT;
  48. _ISFirstRowsInResultSet = IS_FIRST_ROWS_IN_RESULT_DEFAULT;
  49. _ISCachePurgeInterval = IS_QUERY_CACHE_PURGE_INTERVAL_DEFAULT;
  50. _ISRequestQueueSize = IS_QUERY_REQUEST_QUEUE_SIZE_DEFAULT;
  51. _ISRequestThresholdFactor = IS_QUERY_REQUEST_THRESHOLD_FACTOR_DEFAULT;
  52. _ISDateTimeFormatting = IS_QUERY_DATETIME_FORMATTING_DEFAULT;
  53. _ISDateTimeLocal = IS_QUERY_DATETIME_LOCAL_DEFAULT;
  54. _maxActiveQueryThreads = CI_MAX_ACTIVE_QUERY_THREADS_DEFAULT;
  55. wcscpy( _awcISDefaultCatalog, IS_DEFAULT_CATALOG_DIRECTORY );
  56. } //SetDefault
  57. //+-------------------------------------------------------------------------
  58. //
  59. // Member: CIdqRegParams::_ReadAndOverrideValues, private
  60. //
  61. // Synopsis: Attempts to read values, with the default being the current
  62. // value.
  63. //
  64. // History: 12-Oct-96 dlee created
  65. //
  66. //--------------------------------------------------------------------------
  67. void CIdqRegParams::_ReadAndOverrideValues( CRegAccess & reg )
  68. {
  69. CIdqRegVars newVals;
  70. newVals._maxISRowsInResultSet = reg.Read(wcsISMaxRecordsInResultSet, _maxISRowsInResultSet );
  71. newVals._maxISQueryCache = reg.Read(wcsISMaxEntriesInQueryCache, _maxISQueryCache );
  72. newVals._ISFirstRowsInResultSet = reg.Read(wcsISFirstRowsInResultSet, _ISFirstRowsInResultSet );
  73. newVals._ISCachePurgeInterval = reg.Read(wcsISQueryCachePurgeInterval, _ISCachePurgeInterval );
  74. newVals._ISRequestQueueSize = reg.Read(wcsISRequestQueueSize, _ISRequestQueueSize );
  75. newVals._ISRequestThresholdFactor = reg.Read(wcsISRequestThresholdFactor, _ISRequestThresholdFactor );
  76. newVals._ISDateTimeFormatting = reg.Read(wcsISDateTimeFormatting, _ISDateTimeFormatting );
  77. newVals._ISDateTimeLocal = reg.Read(wcsISDateTimeLocal, _ISDateTimeLocal );
  78. newVals._maxActiveQueryThreads = reg.Read(wcsMaxActiveQueryThreads, _maxActiveQueryThreads );
  79. wcscpy( newVals._awcISDefaultCatalog, _awcISDefaultCatalog );
  80. _StoreNewValues( newVals );
  81. } //_ReadAndOverrideValues
  82. //+-------------------------------------------------------------------------
  83. //
  84. // Member: CIdqRegParams::_ReadValues, private
  85. //
  86. // Synopsis: Reads values for variables
  87. //
  88. // History: 12-Oct-96 dlee Added header
  89. //
  90. //--------------------------------------------------------------------------
  91. void CIdqRegParams::_ReadValues(
  92. CRegAccess & reg,
  93. CIdqRegVars & vars )
  94. {
  95. vars._maxISRowsInResultSet = reg.Read(wcsISMaxRecordsInResultSet, IS_MAX_ROWS_IN_RESULT_DEFAULT);
  96. vars._maxISQueryCache = reg.Read(wcsISMaxEntriesInQueryCache, IS_MAX_ENTRIES_IN_CACHE_DEFAULT);
  97. vars._ISFirstRowsInResultSet = reg.Read(wcsISFirstRowsInResultSet, IS_FIRST_ROWS_IN_RESULT_DEFAULT);
  98. vars._ISCachePurgeInterval = reg.Read(wcsISQueryCachePurgeInterval, IS_QUERY_CACHE_PURGE_INTERVAL_DEFAULT);
  99. vars._ISRequestQueueSize = reg.Read(wcsISRequestQueueSize, IS_QUERY_REQUEST_QUEUE_SIZE_DEFAULT);
  100. vars._ISRequestThresholdFactor = reg.Read(wcsISRequestThresholdFactor, IS_QUERY_REQUEST_THRESHOLD_FACTOR_DEFAULT);
  101. vars._ISDateTimeFormatting = reg.Read(wcsISDateTimeFormatting, IS_QUERY_DATETIME_FORMATTING_DEFAULT);
  102. vars._ISDateTimeLocal = reg.Read(wcsISDateTimeLocal, IS_QUERY_DATETIME_LOCAL_DEFAULT);
  103. vars._maxActiveQueryThreads = reg.Read(wcsMaxActiveQueryThreads, CI_MAX_ACTIVE_QUERY_THREADS_DEFAULT);
  104. XPtrST<WCHAR> xwszISDefaultCatalog( reg.Read(wcsISDefaultCatalogDirectory, IS_DEFAULT_CATALOG_DIRECTORY) );
  105. wcsncpy( vars._awcISDefaultCatalog, xwszISDefaultCatalog.GetPointer(), MAX_PATH );
  106. } //_ReadValues
  107. //+-------------------------------------------------------------------------
  108. //
  109. // Member: CIdqRegVars::_StoreNewValues, private
  110. //
  111. // Synopsis: Transfers range-checked values
  112. //
  113. // History: 12-Oct-96 dlee Added header
  114. //
  115. //--------------------------------------------------------------------------
  116. void CIdqRegParams::_StoreNewValues(CIdqRegVars & vars )
  117. {
  118. InterlockedExchange( (long *) &_maxISRowsInResultSet, Range( vars._maxISRowsInResultSet, IS_MAX_ROWS_IN_RESULT_MIN, IS_MAX_ROWS_IN_RESULT_MAX ) );
  119. InterlockedExchange( (long *) &_maxISQueryCache, Range( vars._maxISQueryCache, IS_MAX_ENTRIES_IN_CACHE_MIN, IS_MAX_ENTRIES_IN_CACHE_MAX ) );
  120. InterlockedExchange( (long *) &_ISFirstRowsInResultSet, Range( vars._ISFirstRowsInResultSet, IS_FIRST_ROWS_IN_RESULT_MIN, IS_FIRST_ROWS_IN_RESULT_MAX ) );
  121. InterlockedExchange( (long *) &_ISCachePurgeInterval, Range( vars._ISCachePurgeInterval, IS_QUERY_CACHE_PURGE_INTERVAL_MIN, IS_QUERY_CACHE_PURGE_INTERVAL_MAX ) );
  122. InterlockedExchange( (long *) &_ISRequestQueueSize, Range( vars._ISRequestQueueSize, IS_QUERY_REQUEST_QUEUE_SIZE_MIN, IS_QUERY_REQUEST_QUEUE_SIZE_MAX ) );
  123. InterlockedExchange( (long *) &_ISRequestThresholdFactor, Range( vars._ISRequestThresholdFactor, IS_QUERY_REQUEST_THRESHOLD_FACTOR_MIN, IS_QUERY_REQUEST_THRESHOLD_FACTOR_MAX ) );
  124. InterlockedExchange( (long *) &_ISDateTimeFormatting, Range( vars._ISDateTimeFormatting, IS_QUERY_DATETIME_FORMATTING_MIN, IS_QUERY_DATETIME_FORMATTING_MAX ) );
  125. InterlockedExchange( (long *) &_ISDateTimeLocal, vars._ISDateTimeLocal );
  126. InterlockedExchange( (long *) &_maxActiveQueryThreads, Range( vars._maxActiveQueryThreads, CI_MAX_ACTIVE_QUERY_THREADS_MIN, CI_MAX_ACTIVE_QUERY_THREADS_MAX ) );
  127. wcscpy( _awcISDefaultCatalog, vars._awcISDefaultCatalog );
  128. } //_StoreNewValues
  129. //+-------------------------------------------------------------------------
  130. //
  131. // Member: CIdqRegParams::Refresh, public
  132. //
  133. // Synopsis: Reads the values from the registry
  134. //
  135. // History: 12-Oct-96 dlee Added header, reorganized
  136. //
  137. //--------------------------------------------------------------------------
  138. void CIdqRegParams::Refresh(
  139. BOOL fUseDefaultsOnFailure )
  140. {
  141. // Grab the lock so no other writers try to update at the same time
  142. CIdqRegVars newVals;
  143. CLock lock( _mutex );
  144. TRY
  145. {
  146. // Query the registry.
  147. CRegAccess regAdmin( RTL_REGISTRY_CONTROL, wcsRegAdmin );
  148. _ReadValues( regAdmin, newVals );
  149. _StoreNewValues( newVals );
  150. }
  151. CATCH (CException, e)
  152. {
  153. // Only store defaults when told to do so -- the params
  154. // are still in good shape at this point and are more
  155. // accurate than the default settings.
  156. if ( fUseDefaultsOnFailure )
  157. {
  158. newVals.SetDefault();
  159. _StoreNewValues( newVals );
  160. }
  161. }
  162. END_CATCH
  163. } //Refresh