quickfix_ruby_ud 2.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (196) hide show
  1. checksums.yaml +7 -0
  2. data/ext/quickfix/Acceptor.cpp +257 -0
  3. data/ext/quickfix/Acceptor.h +127 -0
  4. data/ext/quickfix/Allocator.h +9 -0
  5. data/ext/quickfix/Application.h +137 -0
  6. data/ext/quickfix/DOMDocument.h +70 -0
  7. data/ext/quickfix/DataDictionary.cpp +679 -0
  8. data/ext/quickfix/DataDictionary.h +607 -0
  9. data/ext/quickfix/DataDictionaryProvider.cpp +66 -0
  10. data/ext/quickfix/DataDictionaryProvider.h +67 -0
  11. data/ext/quickfix/DatabaseConnectionID.h +98 -0
  12. data/ext/quickfix/DatabaseConnectionPool.h +84 -0
  13. data/ext/quickfix/Dictionary.cpp +157 -0
  14. data/ext/quickfix/Dictionary.h +89 -0
  15. data/ext/quickfix/Event.h +89 -0
  16. data/ext/quickfix/Except.h +39 -0
  17. data/ext/quickfix/Exceptions.h +257 -0
  18. data/ext/quickfix/Field.h +654 -0
  19. data/ext/quickfix/FieldConvertors.cpp +86 -0
  20. data/ext/quickfix/FieldConvertors.h +800 -0
  21. data/ext/quickfix/FieldMap.cpp +254 -0
  22. data/ext/quickfix/FieldMap.h +327 -0
  23. data/ext/quickfix/FieldNumbers.h +44 -0
  24. data/ext/quickfix/FieldTypes.cpp +62 -0
  25. data/ext/quickfix/FieldTypes.h +817 -0
  26. data/ext/quickfix/Fields.h +30 -0
  27. data/ext/quickfix/FileLog.cpp +176 -0
  28. data/ext/quickfix/FileLog.h +110 -0
  29. data/ext/quickfix/FileStore.cpp +369 -0
  30. data/ext/quickfix/FileStore.h +131 -0
  31. data/ext/quickfix/FixCommonFields.h +13 -0
  32. data/ext/quickfix/FixFieldNumbers.h +6132 -0
  33. data/ext/quickfix/FixFields.h +6133 -0
  34. data/ext/quickfix/FixValues.h +5790 -0
  35. data/ext/quickfix/Group.cpp +44 -0
  36. data/ext/quickfix/Group.h +78 -0
  37. data/ext/quickfix/HostDetailsProvider.cpp +79 -0
  38. data/ext/quickfix/HostDetailsProvider.h +44 -0
  39. data/ext/quickfix/HtmlBuilder.h +178 -0
  40. data/ext/quickfix/HttpConnection.cpp +914 -0
  41. data/ext/quickfix/HttpConnection.h +74 -0
  42. data/ext/quickfix/HttpMessage.cpp +229 -0
  43. data/ext/quickfix/HttpMessage.h +112 -0
  44. data/ext/quickfix/HttpParser.cpp +49 -0
  45. data/ext/quickfix/HttpParser.h +49 -0
  46. data/ext/quickfix/HttpServer.cpp +152 -0
  47. data/ext/quickfix/HttpServer.h +76 -0
  48. data/ext/quickfix/Initiator.cpp +310 -0
  49. data/ext/quickfix/Initiator.h +151 -0
  50. data/ext/quickfix/Log.cpp +71 -0
  51. data/ext/quickfix/Log.h +254 -0
  52. data/ext/quickfix/Message.cpp +617 -0
  53. data/ext/quickfix/Message.h +419 -0
  54. data/ext/quickfix/MessageCracker.h +171 -0
  55. data/ext/quickfix/MessageSorters.cpp +101 -0
  56. data/ext/quickfix/MessageSorters.h +185 -0
  57. data/ext/quickfix/MessageStore.cpp +182 -0
  58. data/ext/quickfix/MessageStore.h +164 -0
  59. data/ext/quickfix/Mutex.h +120 -0
  60. data/ext/quickfix/MySQLConnection.h +187 -0
  61. data/ext/quickfix/MySQLLog.cpp +262 -0
  62. data/ext/quickfix/MySQLLog.h +158 -0
  63. data/ext/quickfix/MySQLStore.cpp +323 -0
  64. data/ext/quickfix/MySQLStore.h +161 -0
  65. data/ext/quickfix/MySQLStubs.h +203 -0
  66. data/ext/quickfix/NullStore.cpp +40 -0
  67. data/ext/quickfix/NullStore.h +89 -0
  68. data/ext/quickfix/OdbcConnection.h +241 -0
  69. data/ext/quickfix/OdbcLog.cpp +230 -0
  70. data/ext/quickfix/OdbcLog.h +109 -0
  71. data/ext/quickfix/OdbcStore.cpp +313 -0
  72. data/ext/quickfix/OdbcStore.h +124 -0
  73. data/ext/quickfix/PUGIXML_DOMDocument.cpp +112 -0
  74. data/ext/quickfix/PUGIXML_DOMDocument.h +81 -0
  75. data/ext/quickfix/Parser.cpp +111 -0
  76. data/ext/quickfix/Parser.h +50 -0
  77. data/ext/quickfix/PostgreSQLConnection.h +163 -0
  78. data/ext/quickfix/PostgreSQLLog.cpp +263 -0
  79. data/ext/quickfix/PostgreSQLLog.h +157 -0
  80. data/ext/quickfix/PostgreSQLStore.cpp +327 -0
  81. data/ext/quickfix/PostgreSQLStore.h +160 -0
  82. data/ext/quickfix/PostgreSQLStubs.h +203 -0
  83. data/ext/quickfix/Queue.h +66 -0
  84. data/ext/quickfix/QuickfixRuby.cpp +131900 -0
  85. data/ext/quickfix/QuickfixRuby.h +56 -0
  86. data/ext/quickfix/Responder.h +41 -0
  87. data/ext/quickfix/SSLSocketAcceptor.cpp +409 -0
  88. data/ext/quickfix/SSLSocketAcceptor.h +186 -0
  89. data/ext/quickfix/SSLSocketConnection.cpp +434 -0
  90. data/ext/quickfix/SSLSocketConnection.h +221 -0
  91. data/ext/quickfix/SSLSocketInitiator.cpp +558 -0
  92. data/ext/quickfix/SSLSocketInitiator.h +203 -0
  93. data/ext/quickfix/SSLStubs.h +129 -0
  94. data/ext/quickfix/Session.cpp +1437 -0
  95. data/ext/quickfix/Session.h +343 -0
  96. data/ext/quickfix/SessionFactory.cpp +314 -0
  97. data/ext/quickfix/SessionFactory.h +84 -0
  98. data/ext/quickfix/SessionID.h +136 -0
  99. data/ext/quickfix/SessionSettings.cpp +165 -0
  100. data/ext/quickfix/SessionSettings.h +283 -0
  101. data/ext/quickfix/SessionState.h +260 -0
  102. data/ext/quickfix/Settings.cpp +160 -0
  103. data/ext/quickfix/Settings.h +56 -0
  104. data/ext/quickfix/SharedArray.h +274 -0
  105. data/ext/quickfix/SocketAcceptor.cpp +216 -0
  106. data/ext/quickfix/SocketAcceptor.h +77 -0
  107. data/ext/quickfix/SocketConnection.cpp +256 -0
  108. data/ext/quickfix/SocketConnection.h +102 -0
  109. data/ext/quickfix/SocketConnector.cpp +112 -0
  110. data/ext/quickfix/SocketConnector.h +76 -0
  111. data/ext/quickfix/SocketInitiator.cpp +241 -0
  112. data/ext/quickfix/SocketInitiator.h +76 -0
  113. data/ext/quickfix/SocketMonitor.h +26 -0
  114. data/ext/quickfix/SocketMonitor_UNIX.cpp +238 -0
  115. data/ext/quickfix/SocketMonitor_UNIX.h +101 -0
  116. data/ext/quickfix/SocketMonitor_WIN32.cpp +248 -0
  117. data/ext/quickfix/SocketMonitor_WIN32.h +99 -0
  118. data/ext/quickfix/SocketServer.cpp +163 -0
  119. data/ext/quickfix/SocketServer.h +100 -0
  120. data/ext/quickfix/ThreadedSSLSocketAcceptor.cpp +436 -0
  121. data/ext/quickfix/ThreadedSSLSocketAcceptor.h +209 -0
  122. data/ext/quickfix/ThreadedSSLSocketConnection.cpp +364 -0
  123. data/ext/quickfix/ThreadedSSLSocketConnection.h +191 -0
  124. data/ext/quickfix/ThreadedSSLSocketInitiator.cpp +434 -0
  125. data/ext/quickfix/ThreadedSSLSocketInitiator.h +193 -0
  126. data/ext/quickfix/ThreadedSocketAcceptor.cpp +242 -0
  127. data/ext/quickfix/ThreadedSocketAcceptor.h +95 -0
  128. data/ext/quickfix/ThreadedSocketConnection.cpp +227 -0
  129. data/ext/quickfix/ThreadedSocketConnection.h +89 -0
  130. data/ext/quickfix/ThreadedSocketInitiator.cpp +238 -0
  131. data/ext/quickfix/ThreadedSocketInitiator.h +78 -0
  132. data/ext/quickfix/TimeRange.cpp +227 -0
  133. data/ext/quickfix/TimeRange.h +215 -0
  134. data/ext/quickfix/Utility.cpp +639 -0
  135. data/ext/quickfix/Utility.h +255 -0
  136. data/ext/quickfix/UtilitySSL.cpp +1612 -0
  137. data/ext/quickfix/UtilitySSL.h +274 -0
  138. data/ext/quickfix/Values.h +63 -0
  139. data/ext/quickfix/config-all.h +10 -0
  140. data/ext/quickfix/config.h +10 -0
  141. data/ext/quickfix/config_unix.h +178 -0
  142. data/ext/quickfix/config_windows.h +0 -0
  143. data/ext/quickfix/dirent_windows.h +838 -0
  144. data/ext/quickfix/double-conversion/bignum-dtoa.cc +641 -0
  145. data/ext/quickfix/double-conversion/bignum-dtoa.h +84 -0
  146. data/ext/quickfix/double-conversion/bignum.cc +766 -0
  147. data/ext/quickfix/double-conversion/bignum.h +144 -0
  148. data/ext/quickfix/double-conversion/cached-powers.cc +176 -0
  149. data/ext/quickfix/double-conversion/cached-powers.h +64 -0
  150. data/ext/quickfix/double-conversion/diy-fp.cc +57 -0
  151. data/ext/quickfix/double-conversion/diy-fp.h +118 -0
  152. data/ext/quickfix/double-conversion/double-conversion.cc +994 -0
  153. data/ext/quickfix/double-conversion/double-conversion.h +543 -0
  154. data/ext/quickfix/double-conversion/fast-dtoa.cc +665 -0
  155. data/ext/quickfix/double-conversion/fast-dtoa.h +88 -0
  156. data/ext/quickfix/double-conversion/fixed-dtoa.cc +404 -0
  157. data/ext/quickfix/double-conversion/fixed-dtoa.h +56 -0
  158. data/ext/quickfix/double-conversion/ieee.h +402 -0
  159. data/ext/quickfix/double-conversion/strtod.cc +557 -0
  160. data/ext/quickfix/double-conversion/strtod.h +45 -0
  161. data/ext/quickfix/double-conversion/utils.h +374 -0
  162. data/ext/quickfix/extconf.rb +76 -0
  163. data/ext/quickfix/index.h +37 -0
  164. data/ext/quickfix/pugiconfig.hpp +77 -0
  165. data/ext/quickfix/pugixml.cpp +13237 -0
  166. data/ext/quickfix/pugixml.hpp +1516 -0
  167. data/ext/quickfix/scope_guard.hpp +215 -0
  168. data/ext/quickfix/stdint_msvc.h +254 -0
  169. data/ext/quickfix/strptime.h +7 -0
  170. data/lib/quickfix40.rb +274 -0
  171. data/lib/quickfix41.rb +351 -0
  172. data/lib/quickfix42.rb +1184 -0
  173. data/lib/quickfix43.rb +3504 -0
  174. data/lib/quickfix44.rb +14040 -0
  175. data/lib/quickfix50.rb +20051 -0
  176. data/lib/quickfix50sp1.rb +23596 -0
  177. data/lib/quickfix50sp2.rb +412444 -0
  178. data/lib/quickfix_fields.rb +79393 -0
  179. data/lib/quickfix_ruby.rb +82 -0
  180. data/lib/quickfixt11.rb +65 -0
  181. data/spec/FIX40.xml +862 -0
  182. data/spec/FIX41.xml +1282 -0
  183. data/spec/FIX42.xml +2743 -0
  184. data/spec/FIX43.xml +4230 -0
  185. data/spec/FIX44.xml +6600 -0
  186. data/spec/FIX50.xml +8142 -0
  187. data/spec/FIX50SP1.xml +9506 -0
  188. data/spec/FIX50SP2.xml +26069 -0
  189. data/spec/FIXT11.xml +252 -0
  190. data/test/DataDictionaryTestCase.rb +268 -0
  191. data/test/DictionaryTestCase.rb +112 -0
  192. data/test/FieldBaseTestCase.rb +24 -0
  193. data/test/MessageStoreTestCase.rb +19 -0
  194. data/test/MessageTestCase.rb +368 -0
  195. data/test/SessionSettingsTestCase.rb +41 -0
  196. metadata +236 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 6e5120f1bfc89a75f924b795da1c48e29c526a95b943bbd5e4deb13fc1e78578
4
+ data.tar.gz: 6da11fd94214a1203ff805a0be13b96557b9a9049a32594c075b00e5e25310fa
5
+ SHA512:
6
+ metadata.gz: d6f1ae38e1721eb0eb60bec4e06a4523b111717c2856b6075863f34dc892022daae5c440e23c239de118ac4768cc5b446905fe2a6e4b4d1846caf9b7d197c0e4
7
+ data.tar.gz: '08179d127d0345d881513b9d8a1d2dd0e73d7b45584b675424584b4b7e65b585df01c7ea02b2c1bb24857d4d8df4d2e5d546e4829104145c34f759160c679d4a'
@@ -0,0 +1,257 @@
1
+ /****************************************************************************
2
+ ** Copyright (c) 2001-2014
3
+ **
4
+ ** This file is part of the QuickFIX FIX Engine
5
+ **
6
+ ** This file may be distributed under the terms of the quickfixengine.org
7
+ ** license as defined by quickfixengine.org and appearing in the file
8
+ ** LICENSE included in the packaging of this file.
9
+ **
10
+ ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
11
+ ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
12
+ **
13
+ ** See http://www.quickfixengine.org/LICENSE for licensing information.
14
+ **
15
+ ** Contact ask@quickfixengine.org if any conditions of this licensing are
16
+ ** not clear to you.
17
+ **
18
+ ****************************************************************************/
19
+
20
+ #ifdef _MSC_VER
21
+ #include "stdafx.h"
22
+ #else
23
+ #include "config.h"
24
+ #endif
25
+
26
+ #include "Acceptor.h"
27
+ #include "HttpServer.h"
28
+ #include "Session.h"
29
+ #include "SessionFactory.h"
30
+ #include "Utility.h"
31
+ #include "scope_guard.hpp"
32
+
33
+ #include <algorithm>
34
+ #include <fstream>
35
+
36
+ namespace FIX {
37
+ Acceptor::Acceptor(Application &application, MessageStoreFactory &messageStoreFactory, const SessionSettings &settings)
38
+ EXCEPT(ConfigError)
39
+ : m_threadid(0),
40
+ m_application(application),
41
+ m_messageStoreFactory(messageStoreFactory),
42
+ m_settings(settings),
43
+ m_pLogFactory(0),
44
+ m_pLog(0),
45
+ m_processing(false),
46
+ m_firstPoll(true),
47
+ m_stop(true) {
48
+ initialize();
49
+ }
50
+
51
+ Acceptor::Acceptor(
52
+ Application &application,
53
+ MessageStoreFactory &messageStoreFactory,
54
+ const SessionSettings &settings,
55
+ LogFactory &logFactory) EXCEPT(ConfigError)
56
+ : m_threadid(0),
57
+ m_application(application),
58
+ m_messageStoreFactory(messageStoreFactory),
59
+ m_settings(settings),
60
+ m_pLogFactory(&logFactory),
61
+ m_pLog(logFactory.create()),
62
+ m_processing(false),
63
+ m_firstPoll(true),
64
+ m_stop(true) {
65
+ initialize();
66
+ }
67
+
68
+ void Acceptor::initialize() EXCEPT(ConfigError) {
69
+ std::set<SessionID> sessions = m_settings.getSessions();
70
+ std::set<SessionID>::iterator i;
71
+
72
+ if (!sessions.size()) {
73
+ throw ConfigError("No sessions defined");
74
+ }
75
+
76
+ SessionFactory factory(m_application, m_messageStoreFactory, m_pLogFactory);
77
+
78
+ for (i = sessions.begin(); i != sessions.end(); ++i) {
79
+ if (m_settings.get(*i).getString(CONNECTION_TYPE) == "acceptor") {
80
+ m_sessionIDs.insert(*i);
81
+ m_sessions[*i] = factory.create(*i, m_settings.get(*i));
82
+ }
83
+ }
84
+
85
+ if (!m_sessions.size()) {
86
+ throw ConfigError("No sessions defined for acceptor");
87
+ }
88
+ }
89
+
90
+ Acceptor::~Acceptor() {
91
+ Sessions::iterator i;
92
+ for (i = m_sessions.begin(); i != m_sessions.end(); ++i) {
93
+ delete i->second;
94
+ }
95
+
96
+ if (m_pLogFactory && m_pLog) {
97
+ m_pLogFactory->destroy(m_pLog);
98
+ }
99
+ }
100
+
101
+ Session *Acceptor::getSession(const std::string &msg, Responder &responder) {
102
+ Message message;
103
+ if (!message.setStringHeader(msg)) {
104
+ return 0;
105
+ }
106
+
107
+ try {
108
+ auto const &beginString = message.getHeader().getField<BeginString>();
109
+ auto const &clSenderCompID = message.getHeader().getField<SenderCompID>();
110
+ auto const &clTargetCompID = message.getHeader().getField<TargetCompID>();
111
+ auto const &msgType = message.getHeader().getField<MsgType>();
112
+ if (msgType != MsgType_Logon) {
113
+ return 0;
114
+ }
115
+
116
+ SenderCompID senderCompID(clTargetCompID);
117
+ TargetCompID targetCompID(clSenderCompID);
118
+ SessionID sessionID(beginString, senderCompID, targetCompID);
119
+
120
+ Sessions::iterator i = m_sessions.find(sessionID);
121
+ if (i != m_sessions.end()) {
122
+ i->second->setResponder(&responder);
123
+ return i->second;
124
+ }
125
+ } catch (FieldNotFound &) {}
126
+ return 0;
127
+ }
128
+
129
+ Session *Acceptor::getSession(const SessionID &sessionID) const {
130
+ Sessions::const_iterator i = m_sessions.find(sessionID);
131
+ if (i != m_sessions.end()) {
132
+ return i->second;
133
+ } else {
134
+ return 0;
135
+ }
136
+ }
137
+
138
+ const Dictionary *const Acceptor::getSessionSettings(const SessionID &sessionID) const {
139
+ try {
140
+ return &m_settings.get(sessionID);
141
+ } catch (ConfigError &) {
142
+ return 0;
143
+ }
144
+ }
145
+
146
+ void Acceptor::start() EXCEPT(ConfigError, RuntimeError) {
147
+ if (m_processing) {
148
+ throw RuntimeError("Acceptor::start called when already processing messages");
149
+ }
150
+
151
+ m_processing = true;
152
+ m_stop = false;
153
+
154
+ try {
155
+ onConfigure(m_settings);
156
+ onInitialize(m_settings);
157
+
158
+ HttpServer::startGlobal(m_settings);
159
+ } catch (...) {
160
+ m_processing = false;
161
+ throw;
162
+ }
163
+
164
+ if (!thread_spawn(&startThread, this, m_threadid)) {
165
+ m_processing = false;
166
+ throw RuntimeError("Unable to spawn thread");
167
+ }
168
+ }
169
+
170
+ void Acceptor::block() EXCEPT(ConfigError, RuntimeError) {
171
+ if (m_processing) {
172
+ throw RuntimeError("Acceptor::block called when already processing messages");
173
+ }
174
+
175
+ m_processing = true;
176
+ m_stop = false;
177
+ onConfigure(m_settings);
178
+ onInitialize(m_settings);
179
+
180
+ startThread(this);
181
+ }
182
+
183
+ bool Acceptor::poll() EXCEPT(ConfigError, RuntimeError) {
184
+ if (m_processing) {
185
+ throw RuntimeError("Acceptor::poll called when already processing messages");
186
+ }
187
+
188
+ {
189
+ auto guard = sg::make_scope_guard([this]() { m_processing = false; });
190
+
191
+ m_processing = true;
192
+ if (m_firstPoll) {
193
+ m_stop = false;
194
+ onConfigure(m_settings);
195
+ onInitialize(m_settings);
196
+ m_firstPoll = false;
197
+ }
198
+ }
199
+
200
+ return onPoll();
201
+ }
202
+
203
+ void Acceptor::stop(bool force) {
204
+ if (isStopped()) {
205
+ return;
206
+ }
207
+
208
+ HttpServer::stopGlobal();
209
+
210
+ std::vector<Session *> enabledSessions;
211
+
212
+ Sessions sessions = m_sessions;
213
+ Sessions::iterator i = sessions.begin();
214
+ for (; i != sessions.end(); ++i) {
215
+ Session *pSession = Session::lookupSession(i->first);
216
+ if (pSession && pSession->isEnabled()) {
217
+ enabledSessions.push_back(pSession);
218
+ pSession->logout();
219
+ Session::unregisterSession(pSession->getSessionID());
220
+ }
221
+ }
222
+
223
+ if (!force) {
224
+ for (int second = 1; second <= 10 && isLoggedOn(); ++second) {
225
+ process_sleep(1);
226
+ }
227
+ }
228
+
229
+ m_stop = true;
230
+ onStop();
231
+ if (m_threadid) {
232
+ thread_join(m_threadid);
233
+ }
234
+ m_threadid = 0;
235
+
236
+ for (Session *session : enabledSessions) {
237
+ session->logon();
238
+ }
239
+ }
240
+
241
+ bool Acceptor::isLoggedOn() const {
242
+ Sessions sessions = m_sessions;
243
+ for (Sessions::value_type const &sessionIDWithSession : sessions) {
244
+ if (sessionIDWithSession.second->isLoggedOn()) {
245
+ return true;
246
+ }
247
+ }
248
+ return false;
249
+ }
250
+
251
+ THREAD_PROC Acceptor::startThread(void *p) {
252
+ Acceptor *pAcceptor = static_cast<Acceptor *>(p);
253
+ auto guard = sg::make_scope_guard([pAcceptor]() { pAcceptor->m_processing = false; });
254
+ pAcceptor->onStart();
255
+ return 0;
256
+ }
257
+ } // namespace FIX
@@ -0,0 +1,127 @@
1
+ /* -*- C++ -*- */
2
+
3
+ /****************************************************************************
4
+ ** Copyright (c) 2001-2014
5
+ **
6
+ ** This file is part of the QuickFIX FIX Engine
7
+ **
8
+ ** This file may be distributed under the terms of the quickfixengine.org
9
+ ** license as defined by quickfixengine.org and appearing in the file
10
+ ** LICENSE included in the packaging of this file.
11
+ **
12
+ ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
13
+ ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
14
+ **
15
+ ** See http://www.quickfixengine.org/LICENSE for licensing information.
16
+ **
17
+ ** Contact ask@quickfixengine.org if any conditions of this licensing are
18
+ ** not clear to you.
19
+ **
20
+ ****************************************************************************/
21
+
22
+ #ifndef FIX_ACCEPTOR_H
23
+ #define FIX_ACCEPTOR_H
24
+
25
+ #ifdef _MSC_VER
26
+ #pragma warning(disable : 4503 4355 4786 4290)
27
+ #endif
28
+
29
+ #include "Application.h"
30
+ #include "Exceptions.h"
31
+ #include "Log.h"
32
+ #include "MessageStore.h"
33
+ #include "Responder.h"
34
+ #include "SessionSettings.h"
35
+ #include <map>
36
+ #include <string>
37
+
38
+ namespace FIX {
39
+ class Client;
40
+ class Session;
41
+
42
+ /**
43
+ * Base for classes which act as an acceptor for incoming connections.
44
+ *
45
+ * Most users will not need to implement one of these. The default
46
+ * SocketAcceptor implementation will be used in most cases.
47
+ */
48
+ class Acceptor {
49
+ public:
50
+ Acceptor(Application &, MessageStoreFactory &, const SessionSettings &) EXCEPT(ConfigError);
51
+ Acceptor(Application &, MessageStoreFactory &, const SessionSettings &, LogFactory &) EXCEPT(ConfigError);
52
+
53
+ virtual ~Acceptor();
54
+
55
+ Log *getLog() {
56
+ if (m_pLog) {
57
+ return m_pLog;
58
+ }
59
+ return &m_nullLog;
60
+ }
61
+
62
+ /// Start acceptor.
63
+ void start() EXCEPT(ConfigError, RuntimeError);
64
+ /// Block on the acceptor
65
+ void block() EXCEPT(ConfigError, RuntimeError);
66
+ /// Poll the acceptor
67
+ bool poll() EXCEPT(ConfigError, RuntimeError);
68
+
69
+ /// Stop acceptor.
70
+ void stop(bool force = false);
71
+
72
+ /// Check to see if any sessions are currently logged on
73
+ bool isLoggedOn() const;
74
+
75
+ Session *getSession(const std::string &msg, Responder &);
76
+
77
+ const std::set<SessionID> &getSessions() const { return m_sessionIDs; }
78
+ Session *getSession(const SessionID &sessionID) const;
79
+ const Dictionary *const getSessionSettings(const SessionID &sessionID) const;
80
+
81
+ bool has(const SessionID &id) const { return m_sessions.find(id) != m_sessions.end(); }
82
+
83
+ bool isStopped() const { return m_stop; }
84
+
85
+ Application &getApplication() const { return m_application; }
86
+ MessageStoreFactory &getMessageStoreFactory() const { return m_messageStoreFactory; }
87
+
88
+ private:
89
+ void initialize() EXCEPT(ConfigError);
90
+
91
+ /// Implemented to configure acceptor
92
+ virtual void onConfigure(const SessionSettings &) EXCEPT(ConfigError) {};
93
+ /// Implemented to initialize acceptor
94
+ virtual void onInitialize(const SessionSettings &) EXCEPT(RuntimeError) {};
95
+ /// Implemented to start listening for connections.
96
+ virtual void onStart() = 0;
97
+ /// Implemented to connect and poll for events.
98
+ virtual bool onPoll() = 0;
99
+ /// Implemented to stop a running acceptor.
100
+ virtual void onStop() = 0;
101
+
102
+ static THREAD_PROC startThread(void *p);
103
+
104
+ typedef std::set<SessionID> SessionIDs;
105
+ typedef std::map<SessionID, Session *> Sessions;
106
+
107
+ thread_id m_threadid;
108
+ Sessions m_sessions;
109
+ SessionIDs m_sessionIDs;
110
+ Application &m_application;
111
+ MessageStoreFactory &m_messageStoreFactory;
112
+
113
+ protected:
114
+ SessionSettings m_settings;
115
+
116
+ private:
117
+ LogFactory *m_pLogFactory;
118
+ Log *m_pLog;
119
+ NullLog m_nullLog;
120
+ std::atomic<bool> m_processing;
121
+ std::atomic<bool> m_firstPoll;
122
+ std::atomic<bool> m_stop;
123
+ };
124
+ /*! @} */
125
+ } // namespace FIX
126
+
127
+ #endif // FIX_ACCEPTOR_H
@@ -0,0 +1,9 @@
1
+ /* #undef ENABLE_BITMAP_ALLOCATOR */
2
+ /* #undef ENABLE_BOOST_FAST_POOL_ALLOCATOR */
3
+ /* #undef ENABLE_BOOST_POOL_ALLOCATOR */
4
+ /* #undef ENABLE_DEBUG_ALLOCATOR */
5
+ /* #undef ENABLE_MT_ALLOCATOR */
6
+ /* #undef ENABLE_NEW_ALLOCATOR */
7
+ /* #undef ENABLE_POOL_ALLOCATOR */
8
+ /* #undef ENABLE_TBB_ALLOCATOR */
9
+ /* #undef HAVE_ALLOCATOR_CONFIG */
@@ -0,0 +1,137 @@
1
+ /* -*- C++ -*- */
2
+
3
+ /****************************************************************************
4
+ ** Copyright (c) 2001-2014
5
+ **
6
+ ** This file is part of the QuickFIX FIX Engine
7
+ **
8
+ ** This file may be distributed under the terms of the quickfixengine.org
9
+ ** license as defined by quickfixengine.org and appearing in the file
10
+ ** LICENSE included in the packaging of this file.
11
+ **
12
+ ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
13
+ ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
14
+ **
15
+ ** See http://www.quickfixengine.org/LICENSE for licensing information.
16
+ **
17
+ ** Contact ask@quickfixengine.org if any conditions of this licensing are
18
+ ** not clear to you.
19
+ **
20
+ ****************************************************************************/
21
+
22
+ #ifndef FIX_APPLICATION_H
23
+ #define FIX_APPLICATION_H
24
+
25
+ #include "Message.h"
26
+ #include "Mutex.h"
27
+ #include "SessionID.h"
28
+
29
+ namespace FIX {
30
+ /**
31
+ * This interface must be implemented to define what your %FIX application
32
+ * does.
33
+ *
34
+ * These methods notify your application about events that happen on
35
+ * active %FIX sessions. There is no guarantee how many threads will be calling
36
+ * these functions. If the application is sharing resources among multiple sessions,
37
+ * you must synchronize those resources. You can also use the SynchronizedApplication
38
+ * class to automatically synchronize all function calls into your application.
39
+ * The various MessageCracker classes can be used to parse the generic message
40
+ * structure into specific %FIX messages.
41
+ */
42
+ class Application {
43
+ public:
44
+ virtual ~Application() {};
45
+ /// Notification of a session begin created
46
+ virtual void onCreate(const SessionID &) = 0;
47
+ /// Notification of a session successfully logging on
48
+ virtual void onLogon(const SessionID &) = 0;
49
+ /// Notification of a session logging off or disconnecting
50
+ virtual void onLogout(const SessionID &) = 0;
51
+ /// Notification of admin message being sent to target
52
+ virtual void toAdmin(Message &, const SessionID &) = 0;
53
+ /// Notification of app message being sent to target
54
+ virtual void toApp(Message &, const SessionID &) EXCEPT(DoNotSend) = 0;
55
+ /// Notification of admin message being received from target
56
+ virtual void fromAdmin(const Message &, const SessionID &)
57
+ EXCEPT(FieldNotFound, IncorrectDataFormat, IncorrectTagValue, RejectLogon)
58
+ = 0;
59
+ /// Notification of app message being received from target
60
+ virtual void fromApp(const Message &, const SessionID &)
61
+ EXCEPT(FieldNotFound, IncorrectDataFormat, IncorrectTagValue, UnsupportedMessageType)
62
+ = 0;
63
+ };
64
+
65
+ /**
66
+ * This is a special implementation of the Application interface that takes
67
+ * in another Application interface and synchronizes all of its callbacks. This
68
+ * will guarantee that only one thread will access the applications code at a time.
69
+ *
70
+ * This class is a great convenience for writing applications where you
71
+ * don't want to worry about synchronization. There is of course a tradeoff
72
+ * in that you may be synchronizing more than you need to. There is also a very
73
+ * minor performance penalty due to the extra virtual table lookup.
74
+ */
75
+ class SynchronizedApplication : public Application {
76
+ public:
77
+ SynchronizedApplication(Application &app)
78
+ : m_app(app) {}
79
+
80
+ void onCreate(const SessionID &sessionID) {
81
+ Locker l(m_mutex);
82
+ app().onCreate(sessionID);
83
+ }
84
+ void onLogon(const SessionID &sessionID) {
85
+ Locker l(m_mutex);
86
+ app().onLogon(sessionID);
87
+ }
88
+ void onLogout(const SessionID &sessionID) {
89
+ Locker l(m_mutex);
90
+ app().onLogout(sessionID);
91
+ }
92
+ void toAdmin(Message &message, const SessionID &sessionID) {
93
+ Locker l(m_mutex);
94
+ app().toAdmin(message, sessionID);
95
+ }
96
+ void toApp(Message &message, const SessionID &sessionID) EXCEPT(DoNotSend) {
97
+ Locker l(m_mutex);
98
+ app().toApp(message, sessionID);
99
+ }
100
+ void fromAdmin(const Message &message, const SessionID &sessionID)
101
+ EXCEPT(FieldNotFound, IncorrectDataFormat, IncorrectTagValue, RejectLogon) {
102
+ Locker l(m_mutex);
103
+ app().fromAdmin(message, sessionID);
104
+ }
105
+ void fromApp(const Message &message, const SessionID &sessionID)
106
+ EXCEPT(FieldNotFound, IncorrectDataFormat, IncorrectTagValue, UnsupportedMessageType) {
107
+ Locker l(m_mutex);
108
+ app().fromApp(message, sessionID);
109
+ }
110
+
111
+ Mutex m_mutex;
112
+
113
+ Application &app() { return m_app; }
114
+ Application &m_app;
115
+ };
116
+
117
+ /**
118
+ * An empty implementation of an Application. This can be used if you
119
+ * do not want to provide an implementation for all the callback methods.
120
+ * It is also useful for unit tests where the callback
121
+ * values of some or all methods are not of interest.
122
+ */
123
+ class NullApplication : public Application {
124
+ void onCreate(const SessionID &) {}
125
+ void onLogon(const SessionID &) {}
126
+ void onLogout(const SessionID &) {}
127
+ void toAdmin(Message &, const SessionID &) {}
128
+ void toApp(Message &, const SessionID &) EXCEPT(DoNotSend) {}
129
+ void fromAdmin(const Message &, const SessionID &)
130
+ EXCEPT(FieldNotFound, IncorrectDataFormat, IncorrectTagValue, RejectLogon) {}
131
+ void fromApp(const Message &, const SessionID &)
132
+ EXCEPT(FieldNotFound, IncorrectDataFormat, IncorrectTagValue, UnsupportedMessageType) {}
133
+ };
134
+ /*! @} */
135
+ } // namespace FIX
136
+
137
+ #endif // FIX_APPLICATION_H
@@ -0,0 +1,70 @@
1
+ /* -*- C++ -*- */
2
+
3
+ /****************************************************************************
4
+ ** Copyright (c) 2001-2014
5
+ **
6
+ ** This file is part of the QuickFIX FIX Engine
7
+ **
8
+ ** This file may be distributed under the terms of the quickfixengine.org
9
+ ** license as defined by quickfixengine.org and appearing in the file
10
+ ** LICENSE included in the packaging of this file.
11
+ **
12
+ ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
13
+ ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
14
+ **
15
+ ** See http://www.quickfixengine.org/LICENSE for licensing information.
16
+ **
17
+ ** Contact ask@quickfixengine.org if any conditions of this licensing are
18
+ ** not clear to you.
19
+ **
20
+ ****************************************************************************/
21
+
22
+ #ifndef FIX_DOMDOCUMENT_H
23
+ #define FIX_DOMDOCUMENT_H
24
+
25
+ #include <iostream>
26
+ #include <map>
27
+ #include <memory>
28
+ #include <string>
29
+
30
+ namespace FIX {
31
+ /// Interface that represents attribute from underlying XML parser.
32
+ class DOMAttributes {
33
+ public:
34
+ typedef std::map<std::string, std::string> map;
35
+
36
+ virtual ~DOMAttributes() {}
37
+
38
+ virtual bool get(const std::string &, std::string &) = 0;
39
+ virtual map toMap() = 0;
40
+ };
41
+ typedef std::unique_ptr<DOMAttributes> DOMAttributesPtr;
42
+
43
+ /// Interface that represents node from underlying XML parser.
44
+ class DOMNode {
45
+ public:
46
+ virtual ~DOMNode() {}
47
+
48
+ virtual std::unique_ptr<DOMNode> getFirstChildNode() = 0;
49
+ virtual std::unique_ptr<DOMNode> getNextSiblingNode() = 0;
50
+ virtual std::unique_ptr<DOMAttributes> getAttributes() = 0;
51
+ virtual std::string getName() = 0;
52
+ virtual std::string getText() = 0;
53
+ };
54
+ typedef std::unique_ptr<DOMNode> DOMNodePtr;
55
+
56
+ /// Interface that represents document of underlying XML parser.
57
+ class DOMDocument {
58
+ public:
59
+ virtual ~DOMDocument() {}
60
+
61
+ virtual bool load(std::istream &) = 0;
62
+ virtual bool load(const std::string &) = 0;
63
+ virtual bool xml(std::ostream &) = 0;
64
+
65
+ virtual std::unique_ptr<DOMNode> getNode(const std::string &) = 0;
66
+ };
67
+ typedef std::unique_ptr<DOMDocument> DOMDocumentPtr;
68
+ } // namespace FIX
69
+
70
+ #endif