libjmmcg  release_579_6_g8cffd
A C++ library containing an eclectic mix of useful, advanced components.
messages_impl.hpp
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright © 2015 by J.M.McGuiness, isimud@hussar.me.uk
3 **
4 ** This library is free software; you can redistribute it and/or
5 ** modify it under the terms of the GNU Lesser General Public
6 ** License as published by the Free Software Foundation; either
7 ** version 2.1 of the License, or (at your option) any later version.
8 **
9 ** This library is distributed in the hope that it will be useful,
10 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 ** Lesser General Public License for more details.
13 **
14 ** You should have received a copy of the GNU Lesser General Public
15 ** License along with this library; if not, write to the Free Software
16 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18 
19 namespace isimud { namespace ISIMUD_VER_NAMESPACE { namespace exchanges { namespace MIT { namespace common {
20 
21 template<class MsgT>
22 inline constexpr
23 Header::Header(MsgT const *) noexcept(true)
24 : length_(static_cast<std::int16_t>(sizeof(MsgT)-sizeof(Header))), type_(MsgT::static_type) {
25 }
26 
27 inline constexpr
28 LogonRequest::LogonRequest(const logon_args_t::UserName_t &UN, const logon_args_t::Password_t &P, const logon_args_t::Password_t &NP) noexcept(true)
29 : Header_t(static_cast<LogonRequest const *>(nullptr)), userName(UN), password(P), newPassword(NP) {
30  assert(length_>0);
31 }
32 
33 inline constexpr
34 LogonRequest::LogonRequest(logon_args_t const &a) noexcept(true)
36 }
37 
38 template<class RejectCode>
39 inline
40 LogonReply<RejectCode>::LogonReply() noexcept(true)
41 : Header_t(static_cast<LogonReply const *>(nullptr)) {
42 }
43 
44 template<class RejectCode>
45 struct LogonReply<RejectCode>::respond {
46  template<class ReplyMsg, class Op> void
47  operator()(ReplyMsg const &msg, Op const &o) const noexcept(false) FORCE_INLINE {
48  switch (msg.rejectCode()) {
49  case ReplyMsg::logon_success:
50  o.operator()();
51  break;
52  default: {
53  std::ostringstream os;
54  os<<"Failed to logon. Reject code="<<msg.rejectCode();
55  assert(!"TODO need reject code as string.");
56  throw std::runtime_error(os.str());
57  }
58  }
59  }
60 };
61 
62 inline constexpr
63 LogoutRequest::LogoutRequest() noexcept(true)
64 : Header_t(static_cast<LogoutRequest const *>(nullptr)),
65  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(static_cast<LogoutRequest const *>(nullptr)), reason_(r) {
71 }
72 
73 inline constexpr
74 LogoutRequest::LogoutRequest(logoff_args_t const &a) noexcept(true)
76 }
77 
78 inline constexpr
79 Heartbeat::Heartbeat() noexcept(true)
80 : Header_t(static_cast<Heartbeat const *>(nullptr)) {
81 }
82 
83 inline constexpr
84 MissedMessageRequest::MissedMessageRequest(AppID a, SeqNum_t l) noexcept(true)
85 : Header_t(static_cast<MissedMessageRequest const *>(nullptr)), appID(a), lastMsgSeqNum(l) {
86 }
87 
88 inline
90 : Header_t(static_cast<MissedMessageRequestAck const *>(nullptr)) {
91 }
92 
93 inline
95 : Header_t(static_cast<MissedMessageReport const *>(nullptr)) {
96 }
97 
98 template<class RejectCode, RejectCode RejectCodeNum>
99 inline
101 : Header_t(static_cast<Reject const *>(nullptr)) {
102 }
103 
104 template<class RejectCode, RejectCode RejectCodeNum>
105 inline
107 : Header_t(static_cast<Reject const *>(nullptr)),
108  rejectCode_(rc) {
109 }
110 
111 template<class RejectCode, RejectCode RejectCodeNum>
112 inline
114 : Reject(rc) {
116 }
117 
118 inline
119 SystemStatus::SystemStatus() noexcept(true)
120 : Header_t(static_cast<SystemStatus const *>(nullptr)) {
121 }
122 
123 template<class Specific1, class Specific2, class Specific3>
124 inline constexpr
126 : Header_t(static_cast<NewOrder const *>(nullptr)),
127  specific1(instID),
128  orderType_(oT),
129  tif_(t),
130  side_(s),
131  specific2(ordQty),
132  limitPrice_(p)
133 {
135 }
136 
137 template<class Specific1, class Specific2>
138 inline constexpr
140 : Header_t(static_cast<NewQuote const *>(nullptr)) {
141 }
142 
143 template<class Specific1, class Specific2, class Specific3>
144 inline constexpr
146 : Header_t(static_cast<OrderCancelReplaceRequest const *>(nullptr)),
147  specific1(instID),
148  specific2(ordQty),
149  limitPrice_(p),
150  tif_(t),
151  side_(s) {
154 }
155 
156 template<class Specific1, class Specific2>
157 inline constexpr
159 : Header_t(static_cast<OrderCancelRequest const *>(nullptr)),
163 }
164 
165 template<class Specific1, class Specific2>
166 inline constexpr
168 : Header_t(static_cast<OrderMassCancelRequest const *>(nullptr)), specific1(instID) {
169 }
170 
171 template<class Specific1, class Specific2>
172 inline constexpr
174 : Header_t(static_cast<ExecutionReport const *>(nullptr)) {
175 }
176 
177 template<class Specific1, class Specific2>
178 inline constexpr
180 : Header_t(static_cast<ExecutionReport const *>(nullptr)),
181  appID(aID),
183  execType_(eT),
186  side_(s) {
188 }
189 
190 template<class Specific1, class Specific2>
191 inline constexpr
196 }
197 
198 template<class Specific>
199 inline
201 : Header_t(static_cast<OrderCancelReject const *>(nullptr)) {
202 }
203 
204 template<class Specific>
205 inline
207 : Header_t(static_cast<OrderCancelReject const *>(nullptr)),
210 }
211 
212 template<class Specific>
213 inline
215 : Header_t(static_cast<OrderMassCancelReport const *>(nullptr)) {
216 }
217 
218 template<class Specific>
219 inline
221 : Header_t(static_cast<BusinessReject const *>(nullptr)) {
222 }
223 
224 template<class Specific>
225 inline
227 : Header_t(static_cast<BusinessReject const *>(nullptr)),
230 }
231 
232 } } } } }