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.

199 lines
3.8 KiB

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