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.

307 lines
9.5 KiB

  1. //-----------------------------------------------------------------------------
  2. //
  3. //
  4. // File: aqroute.h
  5. //
  6. // Description: AQ Routing helper classes. Defines AQ concepts of message
  7. // type (CAQMessageType) and ScheduleID (CAQScheduleID).
  8. //
  9. // Author: Mike Swafford (MikeSwa)
  10. //
  11. // History:
  12. // 5/21/98 - MikeSwa Created
  13. // 6/9/98 - MikeSwa Modified constructors
  14. //
  15. // Copyright (C) 1998 Microsoft Corporation
  16. //
  17. //-----------------------------------------------------------------------------
  18. #ifndef __AQROUTE_H__
  19. #define __AQROUTE_H__
  20. #include <smproute.h>
  21. //---[ CAQMessageType ]--------------------------------------------------------
  22. //
  23. //
  24. // Description:
  25. // Encapsulates message type returned by IMessageRouter as well as the
  26. // GUID id of the message router itself
  27. // Hungarian:
  28. // aqmt, paqmt
  29. //
  30. //-----------------------------------------------------------------------------
  31. class CAQMessageType
  32. {
  33. public:
  34. inline CAQMessageType(GUID guidRouter, DWORD dwMessageType);
  35. inline CAQMessageType(CAQMessageType *paqmt);
  36. inline BOOL fIsEqual(CAQMessageType *paqmt);
  37. inline BOOL fSameMessageRouter(CAQMessageType *paqmt);
  38. DWORD dwGetMessageType() {return m_dwMessageType;};
  39. inline void GetGUID(IN OUT GUID *pguid);
  40. //Used to update message type when changed befored msg is queued
  41. void SetMessageType(DWORD dwMessageType) {m_dwMessageType = dwMessageType;};
  42. protected:
  43. GUID m_guidRouter;
  44. DWORD m_dwMessageType;
  45. };
  46. //---[ CAQScheduleID ]---------------------------------------------------------
  47. //
  48. //
  49. // Description:
  50. // Encapsulates schedule id returned by IMessageRouter as well as the
  51. // GUID id of the message router itseld
  52. // Hungarian:
  53. // aqsched, paqsched
  54. //
  55. //-----------------------------------------------------------------------------
  56. class CAQScheduleID
  57. {
  58. public:
  59. inline CAQScheduleID();
  60. inline CAQScheduleID(IMessageRouter *pIMessageRouter, DWORD dwScheduleID);
  61. inline CAQScheduleID(GUID guidRouter, DWORD dwScheduleID);
  62. inline void Init(IMessageRouter *pIMessageRouter, DWORD dwScheduleID);
  63. inline BOOL fIsEqual(CAQScheduleID *paqsched);
  64. inline BOOL fSameMessageRouter(CAQScheduleID *paqsched);
  65. inline DWORD dwGetScheduleID() {return m_dwScheduleID;};
  66. inline void GetGUID(IN OUT GUID *pguid);
  67. protected:
  68. GUID m_guidRouter;
  69. DWORD m_dwScheduleID;
  70. };
  71. //---[ CAQMessageType::CAQMessageType ]----------------------------------------
  72. //
  73. //
  74. // Description:
  75. // Constructor for CAQMessageType
  76. // Parameters:
  77. // guidRouter - GUID returned by IMessageRouter::GetTransportSinkID
  78. // dwMessageType - Message type returned by IMessageRouter::GetMessageType
  79. // Returns:
  80. // -
  81. // History:
  82. // 5/21/98 - MikeSwa Created
  83. //
  84. //-----------------------------------------------------------------------------
  85. CAQMessageType::CAQMessageType(GUID guidRouter, DWORD dwMessageType)
  86. {
  87. m_guidRouter = guidRouter;
  88. m_dwMessageType = dwMessageType;
  89. }
  90. //---[ CAQMessageType::CAQMessageType ]----------------------------------------
  91. //
  92. //
  93. // Description:
  94. // Contructor for CAQMessageType that clones another CAQMessageType
  95. // Parameters:
  96. // paqmt CAQMessageType to clone
  97. // Returns:
  98. // -
  99. // History:
  100. // 5/21/98 - MikeSwa Created
  101. //
  102. //-----------------------------------------------------------------------------
  103. CAQMessageType::CAQMessageType(CAQMessageType *paqmt)
  104. {
  105. m_guidRouter = paqmt->m_guidRouter;
  106. m_dwMessageType = paqmt->m_dwMessageType;
  107. }
  108. //---[ CAQMessageType::fIsEqual ]----------------------------------------------
  109. //
  110. //
  111. // Description:
  112. // Determines if 2 given CAQMessageType's refer to the same router and
  113. // message type pair
  114. // Parameters:
  115. // paqmt - Other CAQMessageType to compare against
  116. // Returns:
  117. // TRUE if the refer to the same message type and router
  118. // History:
  119. // 5/21/98 - MikeSwa Created
  120. //
  121. //-----------------------------------------------------------------------------
  122. BOOL CAQMessageType::fIsEqual(CAQMessageType *paqmt)
  123. {
  124. return ((paqmt->m_dwMessageType == m_dwMessageType) &&
  125. (paqmt->m_guidRouter == m_guidRouter));
  126. };
  127. //---[ CAQMessageType::fSameMessageRouter ]------------------------------------
  128. //
  129. //
  130. // Description:
  131. // Determines if 2 given CAQMessageType's refer to the same router ID
  132. // Parameters:
  133. // paqmt - Other CAQMessageType to compare against
  134. // Returns:
  135. // TRUE if the refer to the same router ID
  136. // History:
  137. // 5/21/98 - MikeSwa Created
  138. //
  139. //-----------------------------------------------------------------------------
  140. BOOL CAQMessageType::fSameMessageRouter(CAQMessageType *paqmt)
  141. {
  142. return(paqmt->m_guidRouter == m_guidRouter);
  143. };
  144. //---[ CAQMessageType::GetGUID ]------------------------------------------------
  145. //
  146. //
  147. // Description:
  148. // Gets the GUID associated with this message type
  149. // Parameters:
  150. // pguid GUID to copy value into
  151. // Returns:
  152. // -
  153. // History:
  154. // 12/3/98 - MikeSwa Created
  155. //
  156. //-----------------------------------------------------------------------------
  157. void CAQMessageType::GetGUID(IN OUT GUID *pguid)
  158. {
  159. _ASSERT(pguid);
  160. memcpy(pguid, &m_guidRouter, sizeof(GUID));
  161. }
  162. //---[ CAQScheduleID::CAQScheduleID ]------------------------------------------
  163. //
  164. //
  165. // Description:
  166. // CAQScheduleID constructor & initialization function
  167. // Parameters:
  168. // pIMessageRouter - Message Router for this link
  169. // dwScheduleID - ScheduleID returned by IMessageRouter::GetNextHop
  170. // Returns:
  171. // -
  172. // History:
  173. // 5/21/98 - MikeSwa Created
  174. // 6/9/98 - MikeSwa Modified to take pIMessageRouter
  175. //
  176. //-----------------------------------------------------------------------------
  177. CAQScheduleID::CAQScheduleID(IMessageRouter *pIMessageRouter, DWORD dwScheduleID)
  178. {
  179. Init(pIMessageRouter, dwScheduleID);
  180. }
  181. //---[ CAQScheduleID::CAQScheduleID ]-------------------------------------------
  182. //
  183. //
  184. // Description:
  185. // Default constructor for CAQScheduleID... should be used with
  186. // Parameters:
  187. //
  188. // Returns:
  189. //
  190. // History:
  191. // 6/11/98 - MikeSwa Created
  192. //
  193. //-----------------------------------------------------------------------------
  194. CAQScheduleID::CAQScheduleID()
  195. {
  196. ZeroMemory(&m_guidRouter, sizeof(GUID));
  197. m_dwScheduleID = 0xDEAFBEEF;
  198. }
  199. //---[ CAQScheduleID::CAQScheduleID ]------------------------------------------
  200. //
  201. //
  202. // Description:
  203. // Yet another flavor of CAQScheduleID constructor
  204. // Parameters:
  205. // guidRouter GUID of router for schedule ID
  206. // dwScheduleID Schedule ID returned by router
  207. // Returns:
  208. // -
  209. // History:
  210. // 9/22/98 - MikeSwa Created
  211. //
  212. //-----------------------------------------------------------------------------
  213. CAQScheduleID::CAQScheduleID(GUID guidRouter, DWORD dwScheduleID)
  214. {
  215. m_guidRouter = guidRouter;
  216. m_dwScheduleID = dwScheduleID;
  217. }
  218. //---[ CAQScheduleID::Init ]---------------------------------------------------
  219. //
  220. //
  221. // Description:
  222. // Initalization of CAQScheduleID object... used to allow allocation of
  223. // object on stack before dwScheduleID is known
  224. // Parameters:
  225. // pIMessageRouter - Message Router for this link
  226. // dwScheduleID - ScheduleID returned by IMessageRouter::GetNextHop
  227. // Returns:
  228. // -
  229. // History:
  230. // 6/11/98 - MikeSwa Created
  231. //
  232. //-----------------------------------------------------------------------------
  233. void CAQScheduleID::Init(IMessageRouter *pIMessageRouter, DWORD dwScheduleID)
  234. {
  235. m_guidRouter = pIMessageRouter->GetTransportSinkID();
  236. m_dwScheduleID = dwScheduleID;
  237. }
  238. //---[ CAQScheduleID::fIsEqual ]----------------------------------------------
  239. //
  240. //
  241. // Description:
  242. // Determines if 2 given CAQScheduleID's refer to the same router and
  243. // Schedule ID pair
  244. // Parameters:
  245. // paqsched - Other CAQScheduleID to compare against
  246. // Returns:
  247. // TRUE if the refer to the same schedule ID and router
  248. // History:
  249. // 5/21/98 - MikeSwa Created
  250. //
  251. //-----------------------------------------------------------------------------
  252. BOOL CAQScheduleID::fIsEqual(CAQScheduleID *paqsched)
  253. {
  254. return ((paqsched->m_dwScheduleID == m_dwScheduleID) &&
  255. (paqsched->m_guidRouter == m_guidRouter));
  256. };
  257. //---[ CAQScheduleID::fSameMessageRouter ]-------------------------------------
  258. //
  259. //
  260. // Description:
  261. // Determines if 2 given CAQScheduleID's refer to the same router ID
  262. // Parameters:
  263. // paqsched - Other CAQScheduleID to compare against
  264. // Returns:
  265. // TRUE if the refer to the same router ID
  266. // History:
  267. // 5/21/98 - MikeSwa Created
  268. //
  269. //-----------------------------------------------------------------------------
  270. BOOL CAQScheduleID::fSameMessageRouter(CAQScheduleID *paqsched)
  271. {
  272. return (paqsched->m_guidRouter == m_guidRouter);
  273. };
  274. //---[ CAQScheduleID::GetGUID ]------------------------------------------------
  275. //
  276. //
  277. // Description:
  278. // Gets the GUID associated with this schedule ID
  279. // Parameters:
  280. // pguid GUID to copy value into
  281. // Returns:
  282. // -
  283. // History:
  284. // 9/25/98 - MikeSwa Created
  285. //
  286. //-----------------------------------------------------------------------------
  287. void CAQScheduleID::GetGUID(IN OUT GUID *pguid)
  288. {
  289. _ASSERT(pguid);
  290. memcpy(pguid, &m_guidRouter, sizeof(GUID));
  291. }
  292. #endif //__AQROUTE_H__