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.

130 lines
3.1 KiB

  1. //#---------------------------------------------------------------
  2. // File: CDescrip.h
  3. //
  4. // Synopsis: Header for the CDescriptor class
  5. //
  6. // Copyright (C) 1995 Microsoft Corporation
  7. // All rights reserved.
  8. //
  9. // Authors: HowardCu
  10. //----------------------------------------------------------------
  11. #ifndef _CDECRIPTOR_H_
  12. #define _CDECRIPTOR_H_
  13. #define AVAIL_SIGNATURE (DWORD)'daeD'
  14. #define DEFAULT_SIGNATURE (DWORD)'Defa'
  15. typedef enum _DESCRIPTOR_STATE_TYPE
  16. {
  17. DESCRIPTOR_FREE,
  18. DESCRIPTOR_INUSE,
  19. } DESCRIPTOR_STATE_TYPE;
  20. #include "dbgtrace.h"
  21. class CPool;
  22. void InitializeUniqueIDs( void );
  23. void TerminateUniqueIDs( void );
  24. class CDescriptor
  25. {
  26. public:
  27. CDescriptor( DWORD dwSig );
  28. ~CDescriptor( void );
  29. inline DWORD GetSignature( void );
  30. inline DWORD GetUniqueObjectID( void );
  31. inline DESCRIPTOR_STATE_TYPE GetState( void );
  32. private:
  33. //
  34. // Structure signature
  35. //
  36. const DWORD m_dwSignature;
  37. //
  38. // unique object identifier assigned from a static DWORD that is
  39. // updated with each new object being marked, In_use.
  40. //
  41. DWORD m_dwUniqueObjectID;
  42. //
  43. // the object state
  44. //
  45. DESCRIPTOR_STATE_TYPE m_eState;
  46. //
  47. // pointer to a generic reference item (the membership pool)
  48. //
  49. #ifdef DEBUG
  50. inline void IsValid( void );
  51. #else
  52. void IsValid( void ) { return; }
  53. #endif
  54. };
  55. //+---------------------------------------------------------------
  56. //
  57. // Function: GetSignature
  58. //
  59. // Returns: the current descriptor signature
  60. //
  61. // History: HowardCu Created 8 May 1995
  62. // t-alexwe cleaned up param checking 19 Jun 1995
  63. // t-alexwe inlined 27 Jun 1995
  64. //
  65. //----------------------------------------------------------------
  66. inline DWORD CDescriptor::GetSignature(void)
  67. {
  68. return m_dwSignature;
  69. }
  70. //+---------------------------------------------------------------
  71. //
  72. // Function: GetUniqueObjectID
  73. //
  74. // Returns: the current object ID
  75. //
  76. // History: HowardCu Created 8 May 1995
  77. // t-alexwe cleaned up param checking 19 Jun 1995
  78. // t-alexwe inlined 27 Jun 1995
  79. //
  80. //----------------------------------------------------------------
  81. inline DWORD CDescriptor::GetUniqueObjectID(void)
  82. {
  83. IsValid();
  84. return m_dwUniqueObjectID;
  85. }
  86. //+---------------------------------------------------------------
  87. //
  88. // Function: GetState
  89. //
  90. // Returns: the current descriptor state
  91. //
  92. // History: HowardCu Created 8 May 1995
  93. // t-alexwe cleaned up param checking 19 Jun 1995
  94. // t-alexwe inlined 27 Jun 1995
  95. //
  96. //----------------------------------------------------------------
  97. inline DESCRIPTOR_STATE_TYPE CDescriptor::GetState(void)
  98. {
  99. IsValid();
  100. return m_eState;
  101. }
  102. //
  103. // this function only exists in debug builds and does parameter
  104. // checking on many of the member variable for the CDescriptor class.
  105. //
  106. #ifdef DEBUG
  107. inline void CDescriptor::IsValid()
  108. {
  109. _ASSERT( m_dwSignature != AVAIL_SIGNATURE );
  110. _ASSERT( m_dwUniqueObjectID != 0l );
  111. _ASSERT( m_eState == DESCRIPTOR_INUSE );
  112. }
  113. #endif
  114. #endif //!_CDECRIPTOR_H_