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.

200 lines
3.6 KiB

  1. /*++
  2. Copyright (C) 1996-1999 Microsoft Corporation
  3. Module Name:
  4. DBID.INL
  5. History:
  6. --*/
  7. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  8. //
  9. // every new DBID is null
  10. //
  11. //-----------------------------------------------------------------------------
  12. inline
  13. DBID::DBID()
  14. {
  15. m_l = 0;
  16. DEBUGONLY(++m_UsageCounter);
  17. }
  18. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  19. //
  20. // a DBID can be created from a valid LONG
  21. //
  22. //-----------------------------------------------------------------------------
  23. inline
  24. DBID::DBID(
  25. LONG l)
  26. {
  27. LTASSERT(l > 0);
  28. m_l = l;
  29. DEBUGONLY(++m_UsageCounter);
  30. }
  31. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  32. //
  33. // a DBID can be created from a valid other dbid
  34. //
  35. //-----------------------------------------------------------------------------
  36. inline
  37. DBID::DBID(
  38. const DBID& id)
  39. {
  40. ASSERT_VALID(&id);
  41. m_l = id.m_l;
  42. DEBUGONLY(++m_UsageCounter);
  43. }
  44. inline
  45. DBID::~DBID()
  46. {
  47. DEBUGONLY(--m_UsageCounter);
  48. }
  49. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  50. //
  51. // sets the DBID to a valid value
  52. // only a null DBID can be set
  53. // any attempt to change a valid DBID will cause an assertion failure
  54. //
  55. //-----------------------------------------------------------------------------
  56. inline
  57. void
  58. DBID::Set(
  59. LONG l)
  60. {
  61. ASSERT_VALID(this);
  62. LTASSERT(l > 0);
  63. LTASSERT(m_l == 0);
  64. m_l = l;
  65. }
  66. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  67. //
  68. // sets the DBID to a valid value
  69. // only a null DBID can be set
  70. // any attempt to change a valid DBID will cause an assertion failure
  71. //
  72. //-----------------------------------------------------------------------------
  73. inline
  74. void
  75. DBID::operator=(
  76. const DBID& id)
  77. {
  78. ASSERT_VALID(this);
  79. LTASSERT(m_l == 0);
  80. ASSERT_VALID(&id);
  81. m_l = id.m_l;
  82. }
  83. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  84. //
  85. // LONG operator, the only way to get the value of a DBID, any attempt to get
  86. // the value of a null DBID will cause an assertion failure
  87. //
  88. //-----------------------------------------------------------------------------
  89. inline
  90. DBID::operator LONG ()
  91. const
  92. {
  93. ASSERT_VALID(this);
  94. LTASSERT(m_l > 0);
  95. return m_l;
  96. }
  97. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  98. //
  99. // the only way to clear (make it null) the dbid must be explicit
  100. //
  101. //-----------------------------------------------------------------------------
  102. inline
  103. void
  104. DBID::Clear()
  105. {
  106. ASSERT_VALID(this);
  107. m_l = 0;
  108. }
  109. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  110. //
  111. // the only way to know if a dbid is null
  112. //
  113. //-----------------------------------------------------------------------------
  114. inline
  115. BOOL
  116. DBID::IsNull()
  117. const
  118. {
  119. ASSERT_VALID(this);
  120. return (m_l == 0);
  121. }
  122. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  123. //
  124. // == operator
  125. //
  126. //-----------------------------------------------------------------------------
  127. inline
  128. int
  129. DBID::operator==(
  130. const DBID &dbid)
  131. const
  132. {
  133. ASSERT_VALID(this);
  134. return m_l == dbid.m_l;
  135. }
  136. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  137. //
  138. // != operator
  139. //
  140. //-----------------------------------------------------------------------------
  141. inline
  142. int
  143. DBID::operator!=(
  144. const DBID &dbid)
  145. const
  146. {
  147. ASSERT_VALID(this);
  148. return m_l != dbid.m_l;
  149. }