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.

121 lines
3.0 KiB

  1. /*
  2. * randchnl.h
  3. *
  4. * Copyright (c) 1995 by DataBeam Corporation, Lexington, KY
  5. *
  6. * Abstract:
  7. * This is the interface file for the RandomChannelGenerator class. This
  8. * class inherits from the RandomNumberGenerator class. On instantiation,
  9. * instances of this class will internally generate a random number which
  10. * falls within the allowable range of dynamic channel values. Channel
  11. * assignments are then generated by incrementing this value each time a
  12. * new assignment is requested. Once the maximum allowable value has been
  13. * assigned, the next value to be generated "wraps around" to the minimum
  14. * allowable value.
  15. *
  16. * Obviously, this class does not generate completely random channel
  17. * values for each request. With a completely random generator, it is
  18. * possible to delete a channel in MCS, and then have the random number
  19. * generator assign the same value as the deleted channel before all
  20. * components of the system even know that the channel was deleted to
  21. * start with, thus causing erratic behavior in the system. In this
  22. * class, no channel can be reassigned until all other possible channels
  23. * have been assigned.
  24. *
  25. * This class can be modifed in the future to incorporate additional
  26. * "randomness" into the algorithm and still not reassign any channel
  27. * numbers before all other possible values are used. This, however,
  28. * would be at the expense of performance and/or memory resources.
  29. *
  30. * Caveats:
  31. * None.
  32. *
  33. * Author:
  34. * Alan D. May
  35. */
  36. #ifndef _RANDOM_CHANNEL_GENERATOR_
  37. #define _RANDOM_CHANNEL_GENERATOR_
  38. #include "databeam.h"
  39. #include "random.h"
  40. /*
  41. * The definition of the RandomChannelGenerator class.
  42. */
  43. class RandomChannelGenerator
  44. {
  45. public:
  46. RandomChannelGenerator ();
  47. virtual ~RandomChannelGenerator ();
  48. RandomValue GetRandomChannel ();
  49. private:
  50. ULong Current_Channel;
  51. };
  52. typedef RandomChannelGenerator * PRandomChannelGenerator;
  53. /*
  54. * RandomChannelGenerator ()
  55. *
  56. * Functional Description:
  57. * The constructor creates a random channel generator object by calling the
  58. * constructor for the parent class, RandomNumberGenerator. This then
  59. * automatically seeds the random number generator with the current time.
  60. * The default algorithm will be used.
  61. *
  62. * Formal Parameters:
  63. * None.
  64. *
  65. * Return Value:
  66. * None.
  67. *
  68. * Side Effects:
  69. * None.
  70. *
  71. * Caveats:
  72. * None.
  73. */
  74. /*
  75. * ~RandomChannelGenerator ()
  76. *
  77. * Public
  78. *
  79. * Functional Description:
  80. * This is the destructor for the RandomChannelGenerator class.
  81. *
  82. * Formal Parameters:
  83. * None.
  84. *
  85. * Return Value:
  86. * None.
  87. *
  88. * Side Effects:
  89. * None.
  90. *
  91. * Caveats:
  92. * None.
  93. */
  94. /*
  95. * RandomValue GetRandomChannel ()
  96. *
  97. * Public
  98. *
  99. * Functional Description:
  100. * This method returns a valid dynamic channel number.
  101. *
  102. * Formal Parameters:
  103. * None.
  104. *
  105. * Return Value:
  106. * A RandomValue in the range of valid dynamic channel values.
  107. *
  108. * Side Effects:
  109. * None.
  110. *
  111. * Caveats:
  112. * None.
  113. */
  114. #endif