MessageCracker.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. /* -*- C++ -*- */
  2. /****************************************************************************
  3. ** Copyright (c) 2001-2014
  4. **
  5. ** This file is part of the QuickFIX FIX Engine
  6. **
  7. ** This file may be distributed under the terms of the quickfixengine.org
  8. ** license as defined by quickfixengine.org and appearing in the file
  9. ** LICENSE included in the packaging of this file.
  10. **
  11. ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
  12. ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  13. **
  14. ** See http://www.quickfixengine.org/LICENSE for licensing information.
  15. **
  16. ** Contact ask@quickfixengine.org if any conditions of this licensing are
  17. ** not clear to you.
  18. **
  19. ****************************************************************************/
  20. #ifndef FIX_MESSAGECRACKER_H
  21. #define FIX_MESSAGECRACKER_H
  22. #include "fix40/MessageCracker.h"
  23. #include "fix41/MessageCracker.h"
  24. #include "fix42/MessageCracker.h"
  25. #include "fix43/MessageCracker.h"
  26. #include "fix44/MessageCracker.h"
  27. #include "fix50/MessageCracker.h"
  28. #include "fix50sp1/MessageCracker.h"
  29. #include "fix50sp2/MessageCracker.h"
  30. #include "fixt11/MessageCracker.h"
  31. #include "Values.h"
  32. #include "Session.h"
  33. namespace FIX
  34. {
  35. /** Takes in a generic Message and produces an object that represents
  36. * its specific version and message type.
  37. */
  38. class MessageCracker
  39. :
  40. public FIX40::MessageCracker,
  41. public FIX41::MessageCracker,
  42. public FIX42::MessageCracker,
  43. public FIX43::MessageCracker,
  44. public FIX44::MessageCracker,
  45. public FIX50::MessageCracker,
  46. public FIX50SP1::MessageCracker,
  47. public FIX50SP2::MessageCracker,
  48. public FIXT11::MessageCracker
  49. {
  50. public:
  51. void crack( const Message& message,
  52. const SessionID& sessionID )
  53. {
  54. const FIX::BeginString& beginString =
  55. FIELD_GET_REF( message.getHeader(), BeginString );
  56. crack( message, sessionID, beginString );
  57. }
  58. void crack( const Message& message,
  59. const SessionID& sessionID,
  60. const BeginString& beginString )
  61. {
  62. if ( beginString == BeginString_FIX40 )
  63. ((FIX40::MessageCracker&)(*this)).crack((const FIX40::Message&) message, sessionID);
  64. else if ( beginString == BeginString_FIX41 )
  65. ((FIX41::MessageCracker&)(*this)).crack((const FIX41::Message&) message, sessionID);
  66. else if ( beginString == BeginString_FIX42 )
  67. ((FIX42::MessageCracker&)(*this)).crack((const FIX42::Message&) message, sessionID);
  68. else if ( beginString == BeginString_FIX43 )
  69. ((FIX43::MessageCracker&)(*this)).crack((const FIX43::Message&) message, sessionID);
  70. else if ( beginString == BeginString_FIX44 )
  71. ((FIX44::MessageCracker&)(*this)).crack((const FIX44::Message&) message, sessionID);
  72. else if ( beginString == BeginString_FIXT11 )
  73. {
  74. if( message.isAdmin() )
  75. {
  76. ((FIXT11::MessageCracker&)(*this)).crack((const FIXT11::Message&) message, sessionID);
  77. }
  78. else
  79. {
  80. ApplVerID applVerID;
  81. if(!message.getHeader().getFieldIfSet(applVerID))
  82. {
  83. Session* pSession = Session::lookupSession( sessionID );
  84. applVerID = pSession->getSenderDefaultApplVerID();
  85. }
  86. crack( message, sessionID, applVerID );
  87. }
  88. }
  89. }
  90. void crack( const Message& message,
  91. const SessionID& sessionID,
  92. const ApplVerID& applVerID )
  93. {
  94. if ( applVerID == ApplVerID_FIX40 )
  95. ((FIX40::MessageCracker&)(*this)).crack((const FIX40::Message&) message, sessionID);
  96. if ( applVerID == ApplVerID_FIX41 )
  97. ((FIX41::MessageCracker&)(*this)).crack((const FIX41::Message&) message, sessionID);
  98. if ( applVerID == ApplVerID_FIX42 )
  99. ((FIX42::MessageCracker&)(*this)).crack((const FIX42::Message&) message, sessionID);
  100. if ( applVerID == ApplVerID_FIX43 )
  101. ((FIX43::MessageCracker&)(*this)).crack((const FIX43::Message&) message, sessionID);
  102. if ( applVerID == ApplVerID_FIX44 )
  103. ((FIX44::MessageCracker&)(*this)).crack((const FIX44::Message&) message, sessionID);
  104. if ( applVerID == ApplVerID_FIX50 )
  105. ((FIX50::MessageCracker&)(*this)).crack((const FIX50::Message&) message, sessionID);
  106. if ( applVerID == ApplVerID_FIX50SP1 )
  107. ((FIX50SP1::MessageCracker&)(*this)).crack((const FIX50SP1::Message&) message, sessionID);
  108. if ( applVerID == ApplVerID_FIX50SP2 )
  109. ((FIX50SP2::MessageCracker&)(*this)).crack((const FIX50SP2::Message&) message, sessionID);
  110. }
  111. void crack( Message& message,
  112. const SessionID& sessionID )
  113. {
  114. const FIX::BeginString& beginString =
  115. FIELD_GET_REF( message.getHeader(), BeginString );
  116. crack( message, sessionID, beginString );
  117. }
  118. void crack( Message& message,
  119. const SessionID& sessionID,
  120. const BeginString& beginString )
  121. {
  122. if ( beginString == BeginString_FIX40 )
  123. ((FIX40::MessageCracker&)(*this)).crack((FIX40::Message&) message, sessionID);
  124. else if ( beginString == BeginString_FIX41 )
  125. ((FIX41::MessageCracker&)(*this)).crack((FIX41::Message&) message, sessionID);
  126. else if ( beginString == BeginString_FIX42 )
  127. ((FIX42::MessageCracker&)(*this)).crack((FIX42::Message&) message, sessionID);
  128. else if ( beginString == BeginString_FIX43 )
  129. ((FIX43::MessageCracker&)(*this)).crack((FIX43::Message&) message, sessionID);
  130. else if ( beginString == BeginString_FIX44 )
  131. ((FIX44::MessageCracker&)(*this)).crack((FIX44::Message&) message, sessionID);
  132. else if ( beginString == BeginString_FIXT11 )
  133. {
  134. if( message.isAdmin() )
  135. {
  136. ((FIXT11::MessageCracker&)(*this)).crack((FIXT11::Message&) message, sessionID);
  137. }
  138. else
  139. {
  140. ApplVerID applVerID;
  141. if(!message.getHeader().getFieldIfSet(applVerID))
  142. {
  143. Session* pSession = Session::lookupSession( sessionID );
  144. applVerID = pSession->getSenderDefaultApplVerID();
  145. }
  146. crack( message, sessionID, applVerID );
  147. }
  148. }
  149. }
  150. void crack( Message& message,
  151. const SessionID& sessionID,
  152. const ApplVerID& applVerID )
  153. {
  154. if ( applVerID == ApplVerID_FIX40 )
  155. ((FIX40::MessageCracker&)(*this)).crack((FIX40::Message&) message, sessionID);
  156. if ( applVerID == ApplVerID_FIX41 )
  157. ((FIX41::MessageCracker&)(*this)).crack((FIX41::Message&) message, sessionID);
  158. if ( applVerID == ApplVerID_FIX42 )
  159. ((FIX42::MessageCracker&)(*this)).crack((FIX42::Message&) message, sessionID);
  160. if ( applVerID == ApplVerID_FIX43 )
  161. ((FIX43::MessageCracker&)(*this)).crack((FIX43::Message&) message, sessionID);
  162. if ( applVerID == ApplVerID_FIX44 )
  163. ((FIX44::MessageCracker&)(*this)).crack((FIX44::Message&) message, sessionID);
  164. if ( applVerID == ApplVerID_FIX50 )
  165. ((FIX50::MessageCracker&)(*this)).crack((FIX50::Message&) message, sessionID);
  166. if ( applVerID == ApplVerID_FIX50SP1 )
  167. ((FIX50SP1::MessageCracker&)(*this)).crack((FIX50SP1::Message&) message, sessionID);
  168. if ( applVerID == ApplVerID_FIX50SP2 )
  169. ((FIX50SP2::MessageCracker&)(*this)).crack((FIX50SP2::Message&) message, sessionID);
  170. }
  171. };
  172. }
  173. #endif //FIX_MESSAGECRACKER_H