root/isimud/exchanges/MIT/common/messages_impl.hpp

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. type_
  2. newPassword
  3. reason_
  4. lastMsgSeqNum
  5. rejectCode_
  6. rejectCode_
  7. limitPrice_
  8. side_
  9. side_
  10. specific1
  11. side_
  12. sequenceNumber
  13. sequenceNumber

   1 /******************************************************************************
   2 ** $Header: svn+ssh://jmmcg@svn.code.sf.net/p/libjmmcg/code/trunk/libjmmcg/isimud/exchanges/MIT/common/messages_impl.hpp 2330 2018-09-26 03:49:30Z jmmcg $
   3 **
   4 ** Copyright (c) 2015 by J.M.McGuiness, isimud@hussar.me.uk
   5 **
   6 ** This library is free software; you can redistribute it and/or
   7 ** modify it under the terms of the GNU Lesser General Public
   8 ** License as published by the Free Software Foundation; either
   9 ** version 2.1 of the License, or (at your option) any later version.
  10 **
  11 ** This library is distributed in the hope that it will be useful,
  12 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  13 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14 ** Lesser General Public License for more details.
  15 **
  16 ** You should have received a copy of the GNU Lesser General Public
  17 ** License along with this library; if not, write to the Free Software
  18 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19 */
  20 
  21 namespace isimud { namespace exchanges { namespace MIT { namespace common {
  22 
  23 template<class MsgT>
  24 inline constexpr
  25 Header::Header(std::size_t l, MsgT t) noexcept(true)
  26 : length_(static_cast<std::int16_t>(l)-sizeof(std::int8_t)-sizeof(std::int16_t)), type_(static_cast<MsgType_t>(t)) {
  27 }
  28 
  29 inline constexpr
  30 LogonRequest::LogonRequest(const UserName_t &UN, const Password_t &P, const Password_t &NP) noexcept(true)
  31 : Header_t(sizeof(LogonRequest), AdminMsgType::LogonRequest), userName(UN), password(P), newPassword(NP) {
  32 }
  33 
  34 inline constexpr
  35 LogonRequest::LogonRequest(logon_args_t const &a) noexcept(true)
  36 : LogonRequest(a.username, a.password, a.new_password) {
  37 }
  38 
  39 template<class RejectCode>
  40 inline
  41 LogonReply<RejectCode>::LogonReply() noexcept(true)
  42 : Header_t(sizeof(LogonReply), AdminMsgType::LogonReply) {
  43 }
  44 
  45 template<class RejectCode>
  46 struct LogonReply<RejectCode>::respond {
  47         template<class ReplyMsg, class Op> void
  48         operator()(ReplyMsg const &msg, Op const &o) const noexcept(false) FORCE_INLINE {
  49                 switch (msg.rejectCode()) {
  50                         case ReplyMsg::logon_success:
  51                                 o.operator()();
  52                                 break;
  53                         default: {
  54                                 std::ostringstream os;
  55                                 os<<"Failed to logon. Reject code="<<msg.rejectCode();
  56                                 assert(!"TODO need reject code as string.");
  57                                 throw std::runtime_error(os.str());
  58                         }
  59                 }
  60         }
  61 };
  62 
  63 inline constexpr
  64 LogoutRequest::LogoutRequest() noexcept(true)
  65 : Header_t(sizeof(LogoutRequest), AdminMsgType::LogoutRequest), reason_{"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"} {
  66 }
  67 
  68 inline constexpr
  69 LogoutRequest::LogoutRequest(Reason_t r) noexcept(true)
  70 : Header_t(sizeof(LogoutRequest), AdminMsgType::LogoutRequest), reason_(r) {
  71 }
  72 
  73 inline constexpr
  74 LogoutRequest::LogoutRequest(logoff_args_t const &a) noexcept(true)
  75 : LogoutRequest(a.reason) {
  76 }
  77 
  78 inline constexpr
  79 Heartbeat::Heartbeat() noexcept(true)
  80 : Header_t(sizeof(Heartbeat), AdminMsgType::Heartbeat) {
  81 }
  82 
  83 inline constexpr
  84 MissedMessageRequest::MissedMessageRequest(AppID a, std::int32_t l) noexcept(true)
  85 : Header_t(sizeof(MissedMessageRequest), AdminMsgType::MissedMessageRequest), appID(a), lastMsgSeqNum(l) {
  86 }
  87 
  88 inline
  89 MissedMessageRequestAck::MissedMessageRequestAck() noexcept(true)
  90 : Header_t(sizeof(MissedMessageRequestAck), AdminMsgType::MissedMessageRequestAck) {
  91 }
  92 
  93 inline
  94 MissedMessageReport::MissedMessageReport() noexcept(true)
  95 : Header_t(sizeof(MissedMessageReport), AdminMsgType::MissedMessageReport) {
  96 }
  97 
  98 template<class RejectCode, RejectCode RejectCodeNum>
  99 inline
 100 Reject<RejectCode, RejectCodeNum>::Reject() noexcept(true)
 101 : Header_t(sizeof(Reject), AdminMsgType::Reject) {
 102 }
 103 
 104 template<class RejectCode, RejectCode RejectCodeNum>
 105 inline
 106 Reject<RejectCode, RejectCodeNum>::Reject(RejectCode_t const rc) noexcept(true)
 107 : Header_t(sizeof(Reject), AdminMsgType::Reject),
 108         rejectCode_(rc) {
 109 }
 110 
 111 template<class RejectCode, RejectCode RejectCodeNum>
 112 inline
 113 Reject<RejectCode, RejectCodeNum>::Reject(ClientOrderID_t const &clID, RejectCode_t const rc) noexcept(true)
 114 : Header_t(sizeof(Reject), AdminMsgType::Reject),
 115         rejectCode_(rc) {
 116         jmmcg::memcpy_opt(clID, clientOrderID_);
 117 }
 118 
 119 inline
 120 SystemStatus::SystemStatus() noexcept(true)
 121 : Header_t(sizeof(SystemStatus), AdminMsgType::SystemStatus) {
 122 }
 123 
 124 template<class Specific1, class Specific2, class Specific3>
 125 inline constexpr
 126 NewOrder<Specific1, Specific2, Specific3>::NewOrder(ClientOrderID_t const &clID, OrderType const oT, TIF const t, Side const s, SecurityID_t instID, typename specific2_t::order_qty_t ordQty, Price_t p) noexcept(true)
 127 : Header_t(sizeof(NewOrder), ClientMsgType::NewOrder),
 128         specific1(instID),
 129         orderType_(oT),
 130         tif_(t),
 131         side_(s),
 132         specific2(ordQty),
 133         limitPrice_(p)
 134 {
 135         jmmcg::memcpy_opt(clID, clientOrderID_);
 136 }
 137 
 138 template<class Specific1, class Specific2>
 139 inline constexpr
 140 NewQuote<Specific1, Specific2>::NewQuote() noexcept(true)
 141 : Header_t(sizeof(NewQuote), ClientMsgType::NewQuote) {
 142 }
 143 
 144 template<class Specific1, class Specific2, class Specific3>
 145 inline constexpr
 146 OrderCancelReplaceRequest<Specific1, Specific2, Specific3>::OrderCancelReplaceRequest(common::ClientOrderID_t const &clID, ClientOrderID_t const &origclID, SecurityID_t instID, typename specific2_t::order_qty_t ordQty, Price_t const p, TIF t, Side s) noexcept(true)
 147 : Header_t(sizeof(OrderCancelReplaceRequest), ClientMsgType::OrderCancelReplaceRequest),
 148         specific1(instID),
 149         specific2(ordQty),
 150         limitPrice_(p),
 151         tif_(t),
 152         side_(s) {
 153         jmmcg::memcpy_opt(clID, clientOrderID_);
 154         jmmcg::memcpy_opt(origclID, originalClientOrderID_);
 155 }
 156 
 157 template<class Specific1, class Specific2>
 158 inline constexpr
 159 OrderCancelRequest<Specific1, Specific2>::OrderCancelRequest(ClientOrderID_t const &clID, ClientOrderID_t const &origclID, SecurityID_t instID, Side side) noexcept(true)
 160 : Header_t(sizeof(OrderCancelRequest), ClientMsgType::OrderCancelRequest),
 161         specific1(instID), side_(side) {
 162         jmmcg::memcpy_opt(clID, clientOrderID_);
 163         jmmcg::memcpy_opt(origclID, originalClientOrderID_);
 164 }
 165 
 166 template<class Specific1, class Specific2>
 167 inline constexpr
 168 OrderMassCancelRequest<Specific1, Specific2>::OrderMassCancelRequest(SecurityID_t instID) noexcept(true)
 169 : Header_t(sizeof(OrderMassCancelRequest), ClientMsgType::OrderMassCancelRequest), specific1(instID) {
 170 }
 171 
 172 template<class Specific1, class Specific2>
 173 inline constexpr
 174 ExecutionReport<Specific1, Specific2>::ExecutionReport() noexcept(true)
 175 : Header_t(sizeof(ExecutionReport), ServerMsgType::ExecutionReport) {
 176 }
 177 
 178 template<class Specific1, class Specific2>
 179 inline constexpr
 180 ExecutionReport<Specific1, Specific2>::ExecutionReport(std::int32_t seqNum, ClientOrderID_t const &clID, AppID aID, ExecType eT, Price_t const price, SecurityID_t instID, Side s) noexcept(true)
 181 : Header_t(sizeof(ExecutionReport), ServerMsgType::ExecutionReport),
 182         appID(aID),
 183         sequenceNumber(seqNum),
 184         execType_(eT),
 185         executedPrice_(price),
 186         instrumentID_(instID),
 187         side_(s) {
 188         jmmcg::memcpy_opt(clID, clientOrderID_);
 189 }
 190 
 191 template<class Specific>
 192 inline
 193 OrderCancelReject<Specific>::OrderCancelReject() noexcept(true)
 194 : Header_t(sizeof(OrderCancelReject), ServerMsgType::OrderCancelReject) {
 195 }
 196 
 197 template<class Specific>
 198 inline
 199 OrderCancelReject<Specific>::OrderCancelReject(std::int32_t seqNum, ClientOrderID_t const &clID) noexcept(true)
 200 : Header_t(sizeof(OrderCancelReject), ServerMsgType::OrderCancelReject),
 201         sequenceNumber(seqNum) {
 202         jmmcg::memcpy_opt(clID, clientOrderID_);
 203 }
 204 
 205 template<class Specific>
 206 inline
 207 OrderMassCancelReport<Specific>::OrderMassCancelReport() noexcept(true)
 208 : Header_t(sizeof(OrderMassCancelReport), ServerMsgType::OrderMassCancelReport) {
 209 }
 210 
 211 template<class RejectCode, RejectCode UnknownInstrument>
 212 constexpr const typename BusinessRejectSpecific<RejectCode, UnknownInstrument>::RejectCode_t BusinessRejectSpecific<RejectCode, UnknownInstrument>::unknown_instrument;
 213 
 214 template<class Specific>
 215 constexpr const typename BusinessReject<Specific>::RejectCode_t BusinessReject<Specific>::unknown_instrument;
 216 
 217 template<class Specific>
 218 inline
 219 BusinessReject<Specific>::BusinessReject() noexcept(true)
 220 : Header_t(sizeof(BusinessReject), ServerMsgType::BusinessMessageReject) {
 221 }
 222 
 223 template<class Specific>
 224 inline
 225 BusinessReject<Specific>::BusinessReject(std::int32_t seqNum, ClientOrderID_t const &clID) noexcept(true)
 226 : Header_t(sizeof(BusinessReject), ServerMsgType::BusinessMessageReject),
 227         sequenceNumber(seqNum) {
 228         jmmcg::memcpy_opt(clID, clientOrderID_);
 229 }
 230 
 231 } } } }

/* [<][>][^][v][top][bottom][index][help] */