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.

242 lines
9.9 KiB

  1. /****************************************************************************/
  2. // cd.h
  3. //
  4. // Component Decoupler Class
  5. //
  6. // Copyright (C) 1997-2000 Microsoft Corporation
  7. /****************************************************************************/
  8. #ifndef _H_CD
  9. #define _H_CD
  10. extern "C" {
  11. #include <adcgdata.h>
  12. }
  13. #include "objs.h"
  14. /****************************************************************************/
  15. /* Component IDs */
  16. /****************************************************************************/
  17. #define CD_UI_COMPONENT 0
  18. #define CD_SND_COMPONENT 1
  19. #define CD_RCV_COMPONENT 2
  20. #define CD_MAX_COMPONENT 2
  21. #define CD_NUM_COMPONENTS 3
  22. /****************************************************************************/
  23. /* CD_NOTIFICATION_FN: */
  24. /* */
  25. /* Callback for notifications. */
  26. /****************************************************************************/
  27. typedef DCVOID DCAPI CD_NOTIFICATION_FN( PDCVOID pInst,
  28. PDCVOID pData,
  29. DCUINT dataLength );
  30. typedef CD_NOTIFICATION_FN DCPTR PCD_NOTIFICATION_FN;
  31. /****************************************************************************/
  32. /* CD_SIMPLE_NOTIFICATION_FN: */
  33. /* */
  34. /* Callback for simple notifications (can only pass a single ULONG_PTR). */
  35. /****************************************************************************/
  36. typedef DCVOID DCAPI CD_SIMPLE_NOTIFICATION_FN(PDCVOID pInst, ULONG_PTR value);
  37. typedef CD_SIMPLE_NOTIFICATION_FN DCPTR PCD_SIMPLE_NOTIFICATION_FN;
  38. /****************************************************************************/
  39. /* */
  40. /* CONSTANTS */
  41. /* */
  42. /****************************************************************************/
  43. #define CD_WINDOW_CLASS _T("ComponentDecouplerClass")
  44. #define CD_NOTIFICATION_MSG (DUC_CD_MESSAGE_BASE)
  45. #define CD_SIMPLE_NOTIFICATION_MSG (DUC_CD_MESSAGE_BASE+1)
  46. #define CD_MAX_NOTIFICATION_DATA_SIZE (0xFFFF - sizeof(CDTRANSFERBUFFERHDR))
  47. /****************************************************************************/
  48. /* Transfer buffers used by CD_DecoupleNotification. The largest size */
  49. /* required is used to pass connection userdata between Network Layer */
  50. /* components. */
  51. /* The number of buffers reflects the usage during connection startup */
  52. /****************************************************************************/
  53. #define CD_CACHED_TRANSFER_BUFFER_SIZE 0x100
  54. #define CD_NUM_CACHED_TRANSFER_BUFFERS 32 //changed from 6
  55. /****************************************************************************/
  56. /* */
  57. /* STRUCTURES */
  58. /* */
  59. /****************************************************************************/
  60. /**STRUCT+*******************************************************************/
  61. /* Structure: CDTRANSFERBUFFER */
  62. /* */
  63. /* Description: structure for buffer passed with decoupled notifications */
  64. /****************************************************************************/
  65. typedef struct tagCDTRANSFERBUFFERHDR
  66. {
  67. PCD_NOTIFICATION_FN pNotificationFn;
  68. PCD_SIMPLE_NOTIFICATION_FN pSimpleNotificationFn;
  69. PDCVOID pInst;
  70. } CDTRANSFERBUFFERHDR;
  71. typedef struct tagCDTRANSFERBUFFER
  72. {
  73. CDTRANSFERBUFFERHDR hdr;
  74. DCUINT8 data[1];
  75. } CDTRANSFERBUFFER;
  76. typedef CDTRANSFERBUFFER DCPTR PCDTRANSFERBUFFER;
  77. typedef DCUINT8 CDCACHEDTRANSFERBUFFER[CD_CACHED_TRANSFER_BUFFER_SIZE];
  78. /**STRUCT+*******************************************************************/
  79. /* Structure: CD_COMPONENT_DATA */
  80. /* */
  81. /* Description: Component Decoupler component data */
  82. /* */
  83. /* Note that the transferBufferInUse flags are declared as a separate */
  84. /* array so that when we search for a free buffer we look at contiguous */
  85. /* bytes rather than bytes separated by the size of a Transfer Buffer */
  86. /* i.e. it makes the most of processor memory caching. */
  87. /****************************************************************************/
  88. typedef struct tagCD_COMPONENT_DATA
  89. {
  90. #ifdef DC_DEBUG
  91. DCINT32 pendingMessageCount; /* must be 4-byte aligned */
  92. DCINT32 pad; /*transferBuffer must start on a processor word boundary*/
  93. #endif
  94. CDCACHEDTRANSFERBUFFER transferBuffer[CD_NUM_CACHED_TRANSFER_BUFFERS];
  95. DCBOOL32 transferBufferInUse[
  96. CD_NUM_CACHED_TRANSFER_BUFFERS];
  97. HWND hwnd[CD_NUM_COMPONENTS];
  98. } CD_COMPONENT_DATA;
  99. /**STRUCT-*******************************************************************/
  100. //
  101. // MACROS to create static versions of notification functions that
  102. // are CD callable
  103. //
  104. // This is needed because the CD does not support getting C++ pointer-to-member's
  105. // changing that would require having a copy of all the CD for each possible
  106. // class type that makes CD calls.
  107. //
  108. #define EXPOSE_CD_SIMPLE_NOTIFICATION_FN(class_name, fn_name) \
  109. public: \
  110. static DCVOID DCAPI MACROGENERATED_Static_##fn_name( \
  111. PDCVOID inst, ULONG_PTR param_name) \
  112. { \
  113. ((class_name*)inst)->##fn_name(param_name); \
  114. } \
  115. #define EXPOSE_CD_NOTIFICATION_FN(class_name, fn_name) \
  116. public: \
  117. static DCVOID DCAPI MACROGENERATED_Static_##fn_name( \
  118. PDCVOID inst, PDCVOID param1_name, DCUINT param2_name) \
  119. { \
  120. ((class_name*)inst)->##fn_name(param1_name, param2_name); \
  121. }
  122. #define CD_NOTIFICATION_FUNC(class_name, fn_name) \
  123. class_name::MACROGENERATED_Static_##fn_name
  124. class CUT;
  125. class CUI;
  126. class CCD
  127. {
  128. public:
  129. CCD(CObjs* objs);
  130. ~CCD();
  131. DCVOID DCAPI CD_TestNotify(DCUINT uni);
  132. DCVOID DCAPI CD_otify(DCUINT uni,int fo);
  133. public:
  134. //
  135. // API
  136. //
  137. /****************************************************************************/
  138. /* FUNCTIONS */
  139. /****************************************************************************/
  140. DCVOID DCAPI CD_Init(DCVOID);
  141. DCVOID DCAPI CD_Term(DCVOID);
  142. HRESULT DCAPI CD_RegisterComponent(DCUINT component);
  143. HRESULT DCAPI CD_UnregisterComponent(DCUINT component);
  144. //
  145. // Notifications..pass a buffer and a length
  146. //
  147. BOOL DCAPI CD_DecoupleNotification(unsigned,PDCVOID, PCD_NOTIFICATION_FN, PDCVOID,
  148. unsigned);
  149. BOOL DCAPI CD_DecoupleSyncDataNotification(unsigned,PDCVOID, PCD_NOTIFICATION_FN,
  150. PDCVOID, unsigned);
  151. //
  152. // Simple notifications (accept one parameter)
  153. //
  154. BOOL DCAPI CD_DecoupleSimpleNotification(unsigned,PDCVOID, PCD_SIMPLE_NOTIFICATION_FN,
  155. ULONG_PTR);
  156. BOOL DCAPI CD_DecoupleSyncNotification(unsigned,PDCVOID, PCD_SIMPLE_NOTIFICATION_FN,
  157. ULONG_PTR);
  158. public:
  159. //
  160. // Public data members
  161. //
  162. CD_COMPONENT_DATA _CD;
  163. private:
  164. //
  165. // Internal functions
  166. //
  167. /****************************************************************************/
  168. /* */
  169. /* FUNCTIONS */
  170. /* */
  171. /****************************************************************************/
  172. PCDTRANSFERBUFFER DCINTERNAL CDAllocTransferBuffer(DCUINT dataLength);
  173. DCVOID DCINTERNAL CDFreeTransferBuffer(PCDTRANSFERBUFFER pTransferBuffer);
  174. static LRESULT CALLBACK CDStaticWndProc( HWND hwnd,
  175. UINT message,
  176. WPARAM wParam,
  177. LPARAM lParam );
  178. LRESULT CALLBACK CDWndProc( HWND hwnd,
  179. UINT message,
  180. WPARAM wParam,
  181. LPARAM lParam );
  182. private:
  183. CUT* _pUt;
  184. CUI* _pUi;
  185. private:
  186. CObjs* _pClientObjects;
  187. BOOL _fCDInitComplete;
  188. };
  189. #endif