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.

185 lines
5.2 KiB

  1. /*++
  2. Copyright (c) 1990 Microsoft Corporation
  3. Module Name:
  4. clasdesc.hxx
  5. Abstract:
  6. This module contains the declaration for the CLASS_DESCRIPTOR class.
  7. A CLASS_DESCRIPTOR contains informatiom to help identify an object's
  8. type at run-time. It is a concrete class which is associated with all
  9. other concrete classes (i.e. there is one instance of a CLASS_DESCRIPTOR
  10. for every concrete class in Ulib). The most important aspect of a
  11. CLASS_DESCRIPTOR is that it supplies a guaranteed unique id for the class
  12. that it decsribes.
  13. Author:
  14. David J. Gilman (davegi) 26-Oct-1990
  15. Environment:
  16. ULIB, User Mode
  17. Notes:
  18. --*/
  19. #if ! defined( _CLASS_DESCRIPTOR_ )
  20. #define _CLASS_DESCRIPTOR_
  21. //
  22. // Forward references
  23. //
  24. DECLARE_CLASS( CLASS_DESCRIPTOR );
  25. #define UNDEFINE_CLASS_DESCRIPTOR( c ) delete (PCLASS_DESCRIPTOR) c##_cd, c##_cd = 0
  26. #if DBG==1
  27. //
  28. // Define a CLASS_DESCRIPTOR in the file ulib.cxx. The name will be
  29. // the same as the type name for the associated class.
  30. //
  31. #define DEFINE_CLASS_DESCRIPTOR( c ) \
  32. ((( c##_cd = NEW CLASS_DESCRIPTOR ) != NULL ) && \
  33. ((( PCLASS_DESCRIPTOR ) c##_cd )->Initialize(( PCCLASS_NAME ) #c )))
  34. #define CLASS_DESCRIPTOR_INITIALIZE \
  35. NONVIRTUAL \
  36. ULIB_EXPORT \
  37. BOOLEAN \
  38. Initialize ( \
  39. IN PCCLASS_NAME ClassName \
  40. )
  41. //
  42. // For debugging purposes, CLASS_DESCRIPTOR stores the name of the class
  43. // that it describes.
  44. //
  45. // NOTE - DebugGetClassName is declared for both CLASS_DESCRIPTOR and
  46. // OBJECT. See the note at the end of this module.
  47. //
  48. //
  49. // Maximum length for the name of a class
  50. //
  51. CONST _MaxClassNameLength = 20;
  52. #define DECLARE_CD_DBG_DATA \
  53. CLASS_NAME _ClassName[ _MaxClassNameLength ]
  54. #define DECLARE_CD_DBG_FUNCTIONS \
  55. NONVIRTUAL \
  56. PCCLASS_NAME \
  57. DebugGetClassName ( \
  58. ) CONST
  59. #define DEFINE_CD_INLINE_DBG_FUNCTIONS \
  60. \
  61. inline \
  62. PCCLASS_NAME \
  63. CLASS_DESCRIPTOR::DebugGetClassName ( \
  64. ) CONST \
  65. { \
  66. return(( PCCLASS_NAME ) _ClassName );\
  67. }
  68. #define DbgGetClassName( pobj ) \
  69. ( pobj )->DebugGetClassName( )
  70. #else // DBG == 0
  71. #define DEFINE_CLASS_DESCRIPTOR( c ) \
  72. ((( c##_cd = NEW CLASS_DESCRIPTOR ) != NULL ) && \
  73. ((( PCLASS_DESCRIPTOR ) c##_cd )->Initialize( )))
  74. #define CLASS_DESCRIPTOR_INITIALIZE \
  75. NONVIRTUAL \
  76. ULIB_EXPORT \
  77. BOOLEAN \
  78. Initialize ( \
  79. )
  80. #define DECLARE_CD_DBG_DATA \
  81. static char d
  82. #define DECLARE_CD_DBG_FUNCTIONS \
  83. void f(void){}
  84. #define DEFINE_CD_INLINE_DBG_FUNCTIONS \
  85. inline void f(void){}
  86. #define DbgGetClassName( pobj )
  87. #endif // DBG
  88. class CLASS_DESCRIPTOR {
  89. friend
  90. BOOLEAN
  91. InitializeUlib(
  92. IN HANDLE DllHandle,
  93. IN ULONG Reason,
  94. IN PVOID Reserved
  95. );
  96. public:
  97. ULIB_EXPORT
  98. CLASS_DESCRIPTOR(
  99. );
  100. CLASS_DESCRIPTOR_INITIALIZE;
  101. NONVIRTUAL
  102. CLASS_ID
  103. QueryClassId (
  104. ) CONST;
  105. DECLARE_CD_DBG_FUNCTIONS;
  106. private:
  107. DECLARE_CD_DBG_DATA;
  108. CLASS_ID _ClassID;
  109. };
  110. INLINE
  111. CLASS_ID
  112. CLASS_DESCRIPTOR::QueryClassId (
  113. ) CONST
  114. /*++
  115. Routine Description:
  116. Return the CLASSID for the object described by this CLASS_DESCRIPTOR.
  117. Arguments:
  118. None.
  119. Return Value:
  120. CLASSID - The CLASSID as maintained by this CLASS_DESCRIPTOR.
  121. --*/
  122. {
  123. return( _ClassID );
  124. }
  125. DEFINE_CD_INLINE_DBG_FUNCTIONS;
  126. #endif // CLASS_DESCRIPTOR