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.

181 lines
5.1 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. Environment:
  14. ULIB, User Mode
  15. Notes:
  16. --*/
  17. #if ! defined( _CLASS_DESCRIPTOR_ )
  18. #define _CLASS_DESCRIPTOR_
  19. //
  20. // Forward references
  21. //
  22. DECLARE_CLASS( CLASS_DESCRIPTOR );
  23. #define UNDEFINE_CLASS_DESCRIPTOR( c ) delete (PCLASS_DESCRIPTOR) c##_cd, c##_cd = 0
  24. #if DBG==1
  25. //
  26. // Define a CLASS_DESCRIPTOR in the file ulib.cxx. The name will be
  27. // the same as the type name for the associated class.
  28. //
  29. #define DEFINE_CLASS_DESCRIPTOR( c ) \
  30. ((( c##_cd = NEW CLASS_DESCRIPTOR ) != NULL ) && \
  31. ((( PCLASS_DESCRIPTOR ) c##_cd )->Initialize(( PCCLASS_NAME ) #c )))
  32. #define CLASS_DESCRIPTOR_INITIALIZE \
  33. NONVIRTUAL \
  34. ULIB_EXPORT \
  35. BOOLEAN \
  36. Initialize ( \
  37. IN PCCLASS_NAME ClassName \
  38. )
  39. //
  40. // For debugging purposes, CLASS_DESCRIPTOR stores the name of the class
  41. // that it describes.
  42. //
  43. // NOTE - DebugGetClassName is declared for both CLASS_DESCRIPTOR and
  44. // OBJECT. See the note at the end of this module.
  45. //
  46. //
  47. // Maximum length for the name of a class
  48. //
  49. CONST _MaxClassNameLength = 20;
  50. #define DECLARE_CD_DBG_DATA \
  51. CLASS_NAME _ClassName[ _MaxClassNameLength ]
  52. #define DECLARE_CD_DBG_FUNCTIONS \
  53. NONVIRTUAL \
  54. PCCLASS_NAME \
  55. DebugGetClassName ( \
  56. ) CONST
  57. #define DEFINE_CD_INLINE_DBG_FUNCTIONS \
  58. \
  59. inline \
  60. PCCLASS_NAME \
  61. CLASS_DESCRIPTOR::DebugGetClassName ( \
  62. ) CONST \
  63. { \
  64. return(( PCCLASS_NAME ) _ClassName );\
  65. }
  66. #define DbgGetClassName( pobj ) \
  67. ( pobj )->DebugGetClassName( )
  68. #else // DBG == 0
  69. #define DEFINE_CLASS_DESCRIPTOR( c ) \
  70. ((( c##_cd = NEW CLASS_DESCRIPTOR ) != NULL ) && \
  71. ((( PCLASS_DESCRIPTOR ) c##_cd )->Initialize( )))
  72. #define CLASS_DESCRIPTOR_INITIALIZE \
  73. NONVIRTUAL \
  74. ULIB_EXPORT \
  75. BOOLEAN \
  76. Initialize ( \
  77. )
  78. #define DECLARE_CD_DBG_DATA \
  79. static char d
  80. #define DECLARE_CD_DBG_FUNCTIONS \
  81. void f(void){}
  82. #define DEFINE_CD_INLINE_DBG_FUNCTIONS \
  83. inline void f(void){}
  84. #define DbgGetClassName( pobj )
  85. #endif // DBG
  86. class CLASS_DESCRIPTOR {
  87. friend
  88. BOOLEAN
  89. InitializeUlib(
  90. IN HANDLE DllHandle,
  91. IN ULONG Reason,
  92. IN PVOID Reserved
  93. );
  94. public:
  95. ULIB_EXPORT
  96. CLASS_DESCRIPTOR(
  97. );
  98. CLASS_DESCRIPTOR_INITIALIZE;
  99. NONVIRTUAL
  100. CLASS_ID
  101. QueryClassId (
  102. ) CONST;
  103. DECLARE_CD_DBG_FUNCTIONS;
  104. private:
  105. DECLARE_CD_DBG_DATA;
  106. CLASS_ID _ClassID;
  107. };
  108. INLINE
  109. CLASS_ID
  110. CLASS_DESCRIPTOR::QueryClassId (
  111. ) CONST
  112. /*++
  113. Routine Description:
  114. Return the CLASSID for the object described by this CLASS_DESCRIPTOR.
  115. Arguments:
  116. None.
  117. Return Value:
  118. CLASSID - The CLASSID as maintained by this CLASS_DESCRIPTOR.
  119. --*/
  120. {
  121. return( _ClassID );
  122. }
  123. DEFINE_CD_INLINE_DBG_FUNCTIONS;
  124. #endif // CLASS_DESCRIPTOR