quickfix_ruby_ud 2.0.7-aarch64-linux
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.
- checksums.yaml +7 -0
- data/ext/quickfix/Acceptor.cpp +257 -0
- data/ext/quickfix/Acceptor.h +127 -0
- data/ext/quickfix/Allocator.h +9 -0
- data/ext/quickfix/Application.h +137 -0
- data/ext/quickfix/DOMDocument.h +70 -0
- data/ext/quickfix/DataDictionary.cpp +679 -0
- data/ext/quickfix/DataDictionary.h +607 -0
- data/ext/quickfix/DataDictionaryProvider.cpp +66 -0
- data/ext/quickfix/DataDictionaryProvider.h +67 -0
- data/ext/quickfix/DatabaseConnectionID.h +98 -0
- data/ext/quickfix/DatabaseConnectionPool.h +84 -0
- data/ext/quickfix/Dictionary.cpp +157 -0
- data/ext/quickfix/Dictionary.h +89 -0
- data/ext/quickfix/Event.h +89 -0
- data/ext/quickfix/Except.h +39 -0
- data/ext/quickfix/Exceptions.h +257 -0
- data/ext/quickfix/Field.h +654 -0
- data/ext/quickfix/FieldConvertors.cpp +86 -0
- data/ext/quickfix/FieldConvertors.h +800 -0
- data/ext/quickfix/FieldMap.cpp +254 -0
- data/ext/quickfix/FieldMap.h +327 -0
- data/ext/quickfix/FieldNumbers.h +44 -0
- data/ext/quickfix/FieldTypes.cpp +62 -0
- data/ext/quickfix/FieldTypes.h +817 -0
- data/ext/quickfix/Fields.h +30 -0
- data/ext/quickfix/FileLog.cpp +176 -0
- data/ext/quickfix/FileLog.h +110 -0
- data/ext/quickfix/FileStore.cpp +369 -0
- data/ext/quickfix/FileStore.h +131 -0
- data/ext/quickfix/FixCommonFields.h +13 -0
- data/ext/quickfix/FixFieldNumbers.h +6132 -0
- data/ext/quickfix/FixFields.h +6133 -0
- data/ext/quickfix/FixValues.h +5790 -0
- data/ext/quickfix/Group.cpp +44 -0
- data/ext/quickfix/Group.h +78 -0
- data/ext/quickfix/HostDetailsProvider.cpp +79 -0
- data/ext/quickfix/HostDetailsProvider.h +44 -0
- data/ext/quickfix/HtmlBuilder.h +178 -0
- data/ext/quickfix/HttpConnection.cpp +914 -0
- data/ext/quickfix/HttpConnection.h +74 -0
- data/ext/quickfix/HttpMessage.cpp +229 -0
- data/ext/quickfix/HttpMessage.h +112 -0
- data/ext/quickfix/HttpParser.cpp +49 -0
- data/ext/quickfix/HttpParser.h +49 -0
- data/ext/quickfix/HttpServer.cpp +152 -0
- data/ext/quickfix/HttpServer.h +76 -0
- data/ext/quickfix/Initiator.cpp +310 -0
- data/ext/quickfix/Initiator.h +151 -0
- data/ext/quickfix/Log.cpp +71 -0
- data/ext/quickfix/Log.h +254 -0
- data/ext/quickfix/Message.cpp +617 -0
- data/ext/quickfix/Message.h +419 -0
- data/ext/quickfix/MessageCracker.h +171 -0
- data/ext/quickfix/MessageSorters.cpp +101 -0
- data/ext/quickfix/MessageSorters.h +185 -0
- data/ext/quickfix/MessageStore.cpp +182 -0
- data/ext/quickfix/MessageStore.h +164 -0
- data/ext/quickfix/Mutex.h +120 -0
- data/ext/quickfix/MySQLConnection.h +187 -0
- data/ext/quickfix/MySQLLog.cpp +262 -0
- data/ext/quickfix/MySQLLog.h +158 -0
- data/ext/quickfix/MySQLStore.cpp +323 -0
- data/ext/quickfix/MySQLStore.h +161 -0
- data/ext/quickfix/MySQLStubs.h +203 -0
- data/ext/quickfix/NullStore.cpp +40 -0
- data/ext/quickfix/NullStore.h +89 -0
- data/ext/quickfix/OdbcConnection.h +241 -0
- data/ext/quickfix/OdbcLog.cpp +230 -0
- data/ext/quickfix/OdbcLog.h +109 -0
- data/ext/quickfix/OdbcStore.cpp +313 -0
- data/ext/quickfix/OdbcStore.h +124 -0
- data/ext/quickfix/PUGIXML_DOMDocument.cpp +112 -0
- data/ext/quickfix/PUGIXML_DOMDocument.h +81 -0
- data/ext/quickfix/Parser.cpp +111 -0
- data/ext/quickfix/Parser.h +50 -0
- data/ext/quickfix/PostgreSQLConnection.h +163 -0
- data/ext/quickfix/PostgreSQLLog.cpp +263 -0
- data/ext/quickfix/PostgreSQLLog.h +157 -0
- data/ext/quickfix/PostgreSQLStore.cpp +327 -0
- data/ext/quickfix/PostgreSQLStore.h +160 -0
- data/ext/quickfix/PostgreSQLStubs.h +203 -0
- data/ext/quickfix/Queue.h +66 -0
- data/ext/quickfix/QuickfixRuby.cpp +131900 -0
- data/ext/quickfix/QuickfixRuby.h +56 -0
- data/ext/quickfix/Responder.h +41 -0
- data/ext/quickfix/SSLSocketAcceptor.cpp +409 -0
- data/ext/quickfix/SSLSocketAcceptor.h +186 -0
- data/ext/quickfix/SSLSocketConnection.cpp +434 -0
- data/ext/quickfix/SSLSocketConnection.h +221 -0
- data/ext/quickfix/SSLSocketInitiator.cpp +558 -0
- data/ext/quickfix/SSLSocketInitiator.h +203 -0
- data/ext/quickfix/SSLStubs.h +129 -0
- data/ext/quickfix/Session.cpp +1437 -0
- data/ext/quickfix/Session.h +343 -0
- data/ext/quickfix/SessionFactory.cpp +314 -0
- data/ext/quickfix/SessionFactory.h +84 -0
- data/ext/quickfix/SessionID.h +136 -0
- data/ext/quickfix/SessionSettings.cpp +165 -0
- data/ext/quickfix/SessionSettings.h +283 -0
- data/ext/quickfix/SessionState.h +260 -0
- data/ext/quickfix/Settings.cpp +160 -0
- data/ext/quickfix/Settings.h +56 -0
- data/ext/quickfix/SharedArray.h +274 -0
- data/ext/quickfix/SocketAcceptor.cpp +216 -0
- data/ext/quickfix/SocketAcceptor.h +77 -0
- data/ext/quickfix/SocketConnection.cpp +256 -0
- data/ext/quickfix/SocketConnection.h +102 -0
- data/ext/quickfix/SocketConnector.cpp +112 -0
- data/ext/quickfix/SocketConnector.h +76 -0
- data/ext/quickfix/SocketInitiator.cpp +241 -0
- data/ext/quickfix/SocketInitiator.h +76 -0
- data/ext/quickfix/SocketMonitor.h +26 -0
- data/ext/quickfix/SocketMonitor_UNIX.cpp +238 -0
- data/ext/quickfix/SocketMonitor_UNIX.h +101 -0
- data/ext/quickfix/SocketMonitor_WIN32.cpp +248 -0
- data/ext/quickfix/SocketMonitor_WIN32.h +99 -0
- data/ext/quickfix/SocketServer.cpp +163 -0
- data/ext/quickfix/SocketServer.h +100 -0
- data/ext/quickfix/ThreadedSSLSocketAcceptor.cpp +436 -0
- data/ext/quickfix/ThreadedSSLSocketAcceptor.h +209 -0
- data/ext/quickfix/ThreadedSSLSocketConnection.cpp +364 -0
- data/ext/quickfix/ThreadedSSLSocketConnection.h +191 -0
- data/ext/quickfix/ThreadedSSLSocketInitiator.cpp +434 -0
- data/ext/quickfix/ThreadedSSLSocketInitiator.h +193 -0
- data/ext/quickfix/ThreadedSocketAcceptor.cpp +242 -0
- data/ext/quickfix/ThreadedSocketAcceptor.h +95 -0
- data/ext/quickfix/ThreadedSocketConnection.cpp +227 -0
- data/ext/quickfix/ThreadedSocketConnection.h +89 -0
- data/ext/quickfix/ThreadedSocketInitiator.cpp +238 -0
- data/ext/quickfix/ThreadedSocketInitiator.h +78 -0
- data/ext/quickfix/TimeRange.cpp +227 -0
- data/ext/quickfix/TimeRange.h +215 -0
- data/ext/quickfix/Utility.cpp +639 -0
- data/ext/quickfix/Utility.h +255 -0
- data/ext/quickfix/UtilitySSL.cpp +1612 -0
- data/ext/quickfix/UtilitySSL.h +274 -0
- data/ext/quickfix/Values.h +63 -0
- data/ext/quickfix/config-all.h +10 -0
- data/ext/quickfix/config.h +10 -0
- data/ext/quickfix/config_unix.h +178 -0
- data/ext/quickfix/config_windows.h +0 -0
- data/ext/quickfix/dirent_windows.h +838 -0
- data/ext/quickfix/double-conversion/bignum-dtoa.cc +641 -0
- data/ext/quickfix/double-conversion/bignum-dtoa.h +84 -0
- data/ext/quickfix/double-conversion/bignum.cc +766 -0
- data/ext/quickfix/double-conversion/bignum.h +144 -0
- data/ext/quickfix/double-conversion/cached-powers.cc +176 -0
- data/ext/quickfix/double-conversion/cached-powers.h +64 -0
- data/ext/quickfix/double-conversion/diy-fp.cc +57 -0
- data/ext/quickfix/double-conversion/diy-fp.h +118 -0
- data/ext/quickfix/double-conversion/double-conversion.cc +994 -0
- data/ext/quickfix/double-conversion/double-conversion.h +543 -0
- data/ext/quickfix/double-conversion/fast-dtoa.cc +665 -0
- data/ext/quickfix/double-conversion/fast-dtoa.h +88 -0
- data/ext/quickfix/double-conversion/fixed-dtoa.cc +404 -0
- data/ext/quickfix/double-conversion/fixed-dtoa.h +56 -0
- data/ext/quickfix/double-conversion/ieee.h +402 -0
- data/ext/quickfix/double-conversion/strtod.cc +557 -0
- data/ext/quickfix/double-conversion/strtod.h +45 -0
- data/ext/quickfix/double-conversion/utils.h +374 -0
- data/ext/quickfix/extconf.rb +76 -0
- data/ext/quickfix/index.h +37 -0
- data/ext/quickfix/pugiconfig.hpp +77 -0
- data/ext/quickfix/pugixml.cpp +13237 -0
- data/ext/quickfix/pugixml.hpp +1516 -0
- data/ext/quickfix/scope_guard.hpp +215 -0
- data/ext/quickfix/stdint_msvc.h +254 -0
- data/ext/quickfix/strptime.h +7 -0
- data/lib/2.4/quickfix.so +0 -0
- data/lib/2.5/quickfix.so +0 -0
- data/lib/2.6/quickfix.so +0 -0
- data/lib/2.7/quickfix.so +0 -0
- data/lib/3.0/quickfix.so +0 -0
- data/lib/3.1/quickfix.so +0 -0
- data/lib/3.2/quickfix.so +0 -0
- data/lib/3.3/quickfix.so +0 -0
- data/lib/3.4/quickfix.so +0 -0
- data/lib/quickfix40.rb +274 -0
- data/lib/quickfix41.rb +351 -0
- data/lib/quickfix42.rb +1184 -0
- data/lib/quickfix43.rb +3504 -0
- data/lib/quickfix44.rb +14040 -0
- data/lib/quickfix50.rb +20051 -0
- data/lib/quickfix50sp1.rb +23596 -0
- data/lib/quickfix50sp2.rb +412444 -0
- data/lib/quickfix_fields.rb +79393 -0
- data/lib/quickfix_ruby.rb +82 -0
- data/lib/quickfixt11.rb +65 -0
- data/spec/FIX40.xml +862 -0
- data/spec/FIX41.xml +1282 -0
- data/spec/FIX42.xml +2743 -0
- data/spec/FIX43.xml +4230 -0
- data/spec/FIX44.xml +6600 -0
- data/spec/FIX50.xml +8142 -0
- data/spec/FIX50SP1.xml +9506 -0
- data/spec/FIX50SP2.xml +26069 -0
- data/spec/FIXT11.xml +252 -0
- data/test/DataDictionaryTestCase.rb +268 -0
- data/test/DictionaryTestCase.rb +112 -0
- data/test/FieldBaseTestCase.rb +24 -0
- data/test/MessageStoreTestCase.rb +19 -0
- data/test/MessageTestCase.rb +368 -0
- data/test/SessionSettingsTestCase.rb +41 -0
- metadata +247 -0
@@ -0,0 +1,76 @@
|
|
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_HTTPSERVER_H
|
23
|
+
#define FIX_HTTPSERVER_H
|
24
|
+
|
25
|
+
#ifdef _MSC_VER
|
26
|
+
#pragma warning(disable : 4503 4355 4786 4290)
|
27
|
+
#endif
|
28
|
+
|
29
|
+
#include "Exceptions.h"
|
30
|
+
#include "Mutex.h"
|
31
|
+
#include "SessionSettings.h"
|
32
|
+
#include "SocketServer.h"
|
33
|
+
|
34
|
+
namespace FIX {
|
35
|
+
/// Basic HTTP Server
|
36
|
+
class HttpServer : public SocketServer::Strategy {
|
37
|
+
public:
|
38
|
+
HttpServer(const SessionSettings &) EXCEPT(ConfigError);
|
39
|
+
|
40
|
+
static void startGlobal(const SessionSettings &) EXCEPT(ConfigError, RuntimeError);
|
41
|
+
static void stopGlobal();
|
42
|
+
|
43
|
+
void start() EXCEPT(ConfigError, RuntimeError);
|
44
|
+
void stop();
|
45
|
+
|
46
|
+
private:
|
47
|
+
void onConfigure(const SessionSettings &) EXCEPT(ConfigError);
|
48
|
+
void onInitialize(const SessionSettings &) EXCEPT(RuntimeError);
|
49
|
+
|
50
|
+
void onStart();
|
51
|
+
bool onPoll();
|
52
|
+
void onStop();
|
53
|
+
|
54
|
+
void onConnect(SocketServer &, socket_handle, socket_handle);
|
55
|
+
void onWrite(SocketServer &, socket_handle);
|
56
|
+
bool onData(SocketServer &, socket_handle);
|
57
|
+
void onDisconnect(SocketServer &, socket_handle);
|
58
|
+
void onError(SocketServer &);
|
59
|
+
void onTimeout(SocketServer &);
|
60
|
+
|
61
|
+
static THREAD_PROC startThread(void *p);
|
62
|
+
|
63
|
+
SocketServer *m_pServer;
|
64
|
+
SessionSettings m_settings;
|
65
|
+
thread_id m_threadid;
|
66
|
+
int m_port;
|
67
|
+
bool m_stop;
|
68
|
+
|
69
|
+
static Mutex s_mutex;
|
70
|
+
static int s_count;
|
71
|
+
static HttpServer *s_pServer;
|
72
|
+
};
|
73
|
+
/*! @} */
|
74
|
+
} // namespace FIX
|
75
|
+
|
76
|
+
#endif // FIX_HTTPSERVER_H
|
@@ -0,0 +1,310 @@
|
|
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 "HttpServer.h"
|
27
|
+
#include "Initiator.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
|
+
Initiator::Initiator(
|
38
|
+
Application &application,
|
39
|
+
MessageStoreFactory &messageStoreFactory,
|
40
|
+
const SessionSettings &settings) EXCEPT(ConfigError)
|
41
|
+
: m_threadid(0),
|
42
|
+
m_application(application),
|
43
|
+
m_messageStoreFactory(messageStoreFactory),
|
44
|
+
m_settings(settings),
|
45
|
+
m_pLogFactory(0),
|
46
|
+
m_pLog(0),
|
47
|
+
m_processing(false),
|
48
|
+
m_firstPoll(true),
|
49
|
+
m_stop(true) {
|
50
|
+
initialize();
|
51
|
+
}
|
52
|
+
|
53
|
+
Initiator::Initiator(
|
54
|
+
Application &application,
|
55
|
+
MessageStoreFactory &messageStoreFactory,
|
56
|
+
const SessionSettings &settings,
|
57
|
+
LogFactory &logFactory) EXCEPT(ConfigError)
|
58
|
+
: m_threadid(0),
|
59
|
+
m_application(application),
|
60
|
+
m_messageStoreFactory(messageStoreFactory),
|
61
|
+
m_settings(settings),
|
62
|
+
m_pLogFactory(&logFactory),
|
63
|
+
m_pLog(logFactory.create()),
|
64
|
+
m_processing(false),
|
65
|
+
m_firstPoll(true),
|
66
|
+
m_stop(true) {
|
67
|
+
initialize();
|
68
|
+
}
|
69
|
+
|
70
|
+
void Initiator::initialize() EXCEPT(ConfigError) {
|
71
|
+
std::set<SessionID> sessions = m_settings.getSessions();
|
72
|
+
std::set<SessionID>::iterator i;
|
73
|
+
|
74
|
+
if (!sessions.size()) {
|
75
|
+
throw ConfigError("No sessions defined");
|
76
|
+
}
|
77
|
+
|
78
|
+
SessionFactory factory(m_application, m_messageStoreFactory, m_pLogFactory);
|
79
|
+
|
80
|
+
for (i = sessions.begin(); i != sessions.end(); ++i) {
|
81
|
+
if (m_settings.get(*i).getString("ConnectionType") == "initiator") {
|
82
|
+
m_sessionIDs.insert(*i);
|
83
|
+
m_sessions[*i] = factory.create(*i, m_settings.get(*i));
|
84
|
+
setDisconnected(*i);
|
85
|
+
}
|
86
|
+
}
|
87
|
+
|
88
|
+
if (!m_sessions.size()) {
|
89
|
+
throw ConfigError("No sessions defined for initiator");
|
90
|
+
}
|
91
|
+
}
|
92
|
+
|
93
|
+
Initiator::~Initiator() {
|
94
|
+
Sessions::iterator i;
|
95
|
+
for (i = m_sessions.begin(); i != m_sessions.end(); ++i) {
|
96
|
+
delete i->second;
|
97
|
+
}
|
98
|
+
|
99
|
+
if (m_pLogFactory && m_pLog) {
|
100
|
+
m_pLogFactory->destroy(m_pLog);
|
101
|
+
}
|
102
|
+
}
|
103
|
+
|
104
|
+
Session *Initiator::getSession(const SessionID &sessionID, Responder &responder) {
|
105
|
+
Sessions::iterator i = m_sessions.find(sessionID);
|
106
|
+
if (i != m_sessions.end()) {
|
107
|
+
i->second->setResponder(&responder);
|
108
|
+
return i->second;
|
109
|
+
}
|
110
|
+
return 0;
|
111
|
+
}
|
112
|
+
|
113
|
+
Session *Initiator::getSession(const SessionID &sessionID) const {
|
114
|
+
Sessions::const_iterator i = m_sessions.find(sessionID);
|
115
|
+
if (i != m_sessions.end()) {
|
116
|
+
return i->second;
|
117
|
+
} else {
|
118
|
+
return 0;
|
119
|
+
}
|
120
|
+
}
|
121
|
+
|
122
|
+
const Dictionary *const Initiator::getSessionSettings(const SessionID &sessionID) const {
|
123
|
+
try {
|
124
|
+
return &m_settings.get(sessionID);
|
125
|
+
} catch (ConfigError &) {
|
126
|
+
return 0;
|
127
|
+
}
|
128
|
+
}
|
129
|
+
|
130
|
+
void Initiator::connect() {
|
131
|
+
Locker l(m_mutex);
|
132
|
+
|
133
|
+
SessionIDs disconnected = m_disconnected;
|
134
|
+
SessionIDs::iterator i = disconnected.begin();
|
135
|
+
for (; i != disconnected.end(); ++i) {
|
136
|
+
Session *pSession = Session::lookupSession(*i);
|
137
|
+
if (pSession->isEnabled() && pSession->isSessionTime(UtcTimeStamp::now())) {
|
138
|
+
doConnect(*i, m_settings.get(*i));
|
139
|
+
}
|
140
|
+
}
|
141
|
+
}
|
142
|
+
|
143
|
+
void Initiator::setPending(const SessionID &sessionID) {
|
144
|
+
Locker l(m_mutex);
|
145
|
+
|
146
|
+
m_pending.insert(sessionID);
|
147
|
+
m_connected.erase(sessionID);
|
148
|
+
m_disconnected.erase(sessionID);
|
149
|
+
}
|
150
|
+
|
151
|
+
void Initiator::setConnected(const SessionID &sessionID) {
|
152
|
+
Locker l(m_mutex);
|
153
|
+
|
154
|
+
m_pending.erase(sessionID);
|
155
|
+
m_connected.insert(sessionID);
|
156
|
+
m_disconnected.erase(sessionID);
|
157
|
+
}
|
158
|
+
|
159
|
+
void Initiator::setDisconnected(const SessionID &sessionID) {
|
160
|
+
Locker l(m_mutex);
|
161
|
+
|
162
|
+
m_pending.erase(sessionID);
|
163
|
+
m_connected.erase(sessionID);
|
164
|
+
m_disconnected.insert(sessionID);
|
165
|
+
}
|
166
|
+
|
167
|
+
bool Initiator::isPending(const SessionID &sessionID) const {
|
168
|
+
Locker l(m_mutex);
|
169
|
+
return m_pending.find(sessionID) != m_pending.end();
|
170
|
+
}
|
171
|
+
|
172
|
+
bool Initiator::isConnected(const SessionID &sessionID) const {
|
173
|
+
Locker l(m_mutex);
|
174
|
+
return m_connected.find(sessionID) != m_connected.end();
|
175
|
+
}
|
176
|
+
|
177
|
+
bool Initiator::isDisconnected(const SessionID &sessionID) const {
|
178
|
+
Locker l(m_mutex);
|
179
|
+
return m_disconnected.find(sessionID) != m_disconnected.end();
|
180
|
+
}
|
181
|
+
|
182
|
+
void Initiator::start() EXCEPT(ConfigError, RuntimeError) {
|
183
|
+
if (m_processing) {
|
184
|
+
throw RuntimeError("Initiator::start called when already processing messages");
|
185
|
+
}
|
186
|
+
|
187
|
+
m_processing = true;
|
188
|
+
m_stop = false;
|
189
|
+
|
190
|
+
try {
|
191
|
+
onConfigure(m_settings);
|
192
|
+
onInitialize(m_settings);
|
193
|
+
|
194
|
+
HttpServer::startGlobal(m_settings);
|
195
|
+
} catch (...) {
|
196
|
+
m_processing = false;
|
197
|
+
throw;
|
198
|
+
}
|
199
|
+
|
200
|
+
if (!thread_spawn(&startThread, this, m_threadid)) {
|
201
|
+
m_processing = false;
|
202
|
+
throw RuntimeError("Unable to spawn thread");
|
203
|
+
}
|
204
|
+
}
|
205
|
+
|
206
|
+
void Initiator::block() EXCEPT(ConfigError, RuntimeError) {
|
207
|
+
if (m_processing) {
|
208
|
+
throw RuntimeError("Initiator::block called when already processing messages");
|
209
|
+
}
|
210
|
+
|
211
|
+
auto guard = sg::make_scope_guard([this]() { m_processing = false; });
|
212
|
+
|
213
|
+
m_processing = true;
|
214
|
+
m_stop = false;
|
215
|
+
|
216
|
+
onConfigure(m_settings);
|
217
|
+
onInitialize(m_settings);
|
218
|
+
|
219
|
+
startThread(this);
|
220
|
+
}
|
221
|
+
|
222
|
+
bool Initiator::poll() EXCEPT(ConfigError, RuntimeError) {
|
223
|
+
if (m_processing) {
|
224
|
+
throw RuntimeError("Initiator::poll called when already processing messages");
|
225
|
+
}
|
226
|
+
|
227
|
+
auto guard = sg::make_scope_guard([this]() { m_processing = false; });
|
228
|
+
|
229
|
+
m_processing = true;
|
230
|
+
if (m_firstPoll) {
|
231
|
+
m_stop = false;
|
232
|
+
onConfigure(m_settings);
|
233
|
+
onInitialize(m_settings);
|
234
|
+
connect();
|
235
|
+
m_firstPoll = false;
|
236
|
+
}
|
237
|
+
|
238
|
+
return onPoll();
|
239
|
+
}
|
240
|
+
|
241
|
+
void Initiator::stop(bool force) {
|
242
|
+
if (isStopped()) {
|
243
|
+
return;
|
244
|
+
}
|
245
|
+
|
246
|
+
HttpServer::stopGlobal();
|
247
|
+
|
248
|
+
std::vector<Session *> enabledSessions;
|
249
|
+
|
250
|
+
SessionIDs connected;
|
251
|
+
|
252
|
+
{
|
253
|
+
Locker l(m_mutex);
|
254
|
+
connected = m_connected;
|
255
|
+
}
|
256
|
+
|
257
|
+
SessionIDs::iterator i = connected.begin();
|
258
|
+
for (; i != connected.end(); ++i) {
|
259
|
+
Session *pSession = Session::lookupSession(*i);
|
260
|
+
if (pSession && pSession->isEnabled()) {
|
261
|
+
enabledSessions.push_back(pSession);
|
262
|
+
pSession->logout();
|
263
|
+
}
|
264
|
+
}
|
265
|
+
|
266
|
+
if (!force) {
|
267
|
+
for (int second = 1; second <= 10 && isLoggedOn(); ++second) {
|
268
|
+
process_sleep(1);
|
269
|
+
}
|
270
|
+
}
|
271
|
+
|
272
|
+
{
|
273
|
+
Locker l(m_mutex);
|
274
|
+
for (i = connected.begin(); i != connected.end(); ++i) {
|
275
|
+
setDisconnected(Session::lookupSession(*i)->getSessionID());
|
276
|
+
}
|
277
|
+
}
|
278
|
+
|
279
|
+
m_stop = true;
|
280
|
+
onStop();
|
281
|
+
if (m_threadid) {
|
282
|
+
thread_join(m_threadid);
|
283
|
+
}
|
284
|
+
m_threadid = 0;
|
285
|
+
|
286
|
+
for (Session *session : enabledSessions) {
|
287
|
+
session->logon();
|
288
|
+
}
|
289
|
+
}
|
290
|
+
|
291
|
+
bool Initiator::isLoggedOn() const {
|
292
|
+
Locker l(m_mutex);
|
293
|
+
|
294
|
+
SessionIDs connected = m_connected;
|
295
|
+
SessionIDs::iterator i = connected.begin();
|
296
|
+
for (; i != connected.end(); ++i) {
|
297
|
+
if (Session::lookupSession(*i)->isLoggedOn()) {
|
298
|
+
return true;
|
299
|
+
}
|
300
|
+
}
|
301
|
+
return false;
|
302
|
+
}
|
303
|
+
|
304
|
+
THREAD_PROC Initiator::startThread(void *p) {
|
305
|
+
Initiator *pInitiator = static_cast<Initiator *>(p);
|
306
|
+
auto guard = sg::make_scope_guard([pInitiator]() { pInitiator->m_processing = false; });
|
307
|
+
pInitiator->onStart();
|
308
|
+
return 0;
|
309
|
+
}
|
310
|
+
} // namespace FIX
|
@@ -0,0 +1,151 @@
|
|
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_INITIATOR_H
|
23
|
+
#define FIX_INITIATOR_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 "Mutex.h"
|
34
|
+
#include "Responder.h"
|
35
|
+
#include "Session.h"
|
36
|
+
#include "SessionSettings.h"
|
37
|
+
|
38
|
+
#include <atomic>
|
39
|
+
#include <map>
|
40
|
+
#include <set>
|
41
|
+
#include <string>
|
42
|
+
|
43
|
+
namespace FIX {
|
44
|
+
class Client;
|
45
|
+
|
46
|
+
/**
|
47
|
+
* Base for classes which act as an initiator for establishing connections.
|
48
|
+
*
|
49
|
+
* Most users will not need to implement one of these. The default
|
50
|
+
* SocketInitiator implementation will be used in most cases.
|
51
|
+
*/
|
52
|
+
class Initiator {
|
53
|
+
public:
|
54
|
+
Initiator(Application &, MessageStoreFactory &, const SessionSettings &) EXCEPT(ConfigError);
|
55
|
+
Initiator(Application &, MessageStoreFactory &, const SessionSettings &, LogFactory &) EXCEPT(ConfigError);
|
56
|
+
|
57
|
+
virtual ~Initiator();
|
58
|
+
|
59
|
+
/// Start initiator.
|
60
|
+
void start() EXCEPT(ConfigError, RuntimeError);
|
61
|
+
/// Block on the initiator
|
62
|
+
void block() EXCEPT(ConfigError, RuntimeError);
|
63
|
+
/// Poll the initiator
|
64
|
+
bool poll() EXCEPT(ConfigError, RuntimeError);
|
65
|
+
|
66
|
+
/// Stop initiator.
|
67
|
+
void stop(bool force = false);
|
68
|
+
|
69
|
+
/// Check to see if any sessions are currently logged on
|
70
|
+
bool isLoggedOn() const;
|
71
|
+
|
72
|
+
Session *getSession(const SessionID &sessionID, Responder &);
|
73
|
+
|
74
|
+
const std::set<SessionID> &getSessions() const { return m_sessionIDs; }
|
75
|
+
Session *getSession(const SessionID &sessionID) const;
|
76
|
+
const Dictionary *const getSessionSettings(const SessionID &sessionID) const;
|
77
|
+
|
78
|
+
bool has(const SessionID &id) const { return m_sessions.find(id) != m_sessions.end(); }
|
79
|
+
|
80
|
+
bool isStopped() const { return m_stop; }
|
81
|
+
|
82
|
+
public:
|
83
|
+
Application &getApplication() const { return m_application; }
|
84
|
+
MessageStoreFactory &getMessageStoreFactory() const { return m_messageStoreFactory; }
|
85
|
+
|
86
|
+
Log *getLog() {
|
87
|
+
if (m_pLog) {
|
88
|
+
return m_pLog;
|
89
|
+
}
|
90
|
+
return &m_nullLog;
|
91
|
+
}
|
92
|
+
|
93
|
+
protected:
|
94
|
+
void setPending(const SessionID &);
|
95
|
+
void setConnected(const SessionID &);
|
96
|
+
void setDisconnected(const SessionID &);
|
97
|
+
|
98
|
+
bool isPending(const SessionID &) const;
|
99
|
+
bool isConnected(const SessionID &) const;
|
100
|
+
bool isDisconnected(const SessionID &) const;
|
101
|
+
void connect();
|
102
|
+
|
103
|
+
private:
|
104
|
+
void initialize() EXCEPT(ConfigError);
|
105
|
+
|
106
|
+
/// Implemented to configure acceptor
|
107
|
+
virtual void onConfigure(const SessionSettings &) EXCEPT(ConfigError) {};
|
108
|
+
/// Implemented to initialize initiator
|
109
|
+
virtual void onInitialize(const SessionSettings &) EXCEPT(RuntimeError) {};
|
110
|
+
/// Implemented to start connecting to targets.
|
111
|
+
virtual void onStart() = 0;
|
112
|
+
/// Implemented to connect and poll for events.
|
113
|
+
virtual bool onPoll() = 0;
|
114
|
+
/// Implemented to stop a running initiator.
|
115
|
+
virtual void onStop() = 0;
|
116
|
+
/// Implemented to connect a session to its target.
|
117
|
+
virtual void doConnect(const SessionID &, const Dictionary &) = 0;
|
118
|
+
|
119
|
+
static THREAD_PROC startThread(void *p);
|
120
|
+
|
121
|
+
typedef std::set<SessionID> SessionIDs;
|
122
|
+
typedef std::map<SessionID, int> SessionState;
|
123
|
+
typedef std::map<SessionID, Session *> Sessions;
|
124
|
+
|
125
|
+
Sessions m_sessions;
|
126
|
+
SessionIDs m_sessionIDs;
|
127
|
+
SessionIDs m_pending;
|
128
|
+
SessionIDs m_connected;
|
129
|
+
SessionIDs m_disconnected;
|
130
|
+
SessionState m_sessionState;
|
131
|
+
|
132
|
+
thread_id m_threadid;
|
133
|
+
Application &m_application;
|
134
|
+
MessageStoreFactory &m_messageStoreFactory;
|
135
|
+
|
136
|
+
protected:
|
137
|
+
SessionSettings m_settings;
|
138
|
+
|
139
|
+
private:
|
140
|
+
LogFactory *m_pLogFactory;
|
141
|
+
Log *m_pLog;
|
142
|
+
NullLog m_nullLog;
|
143
|
+
std::atomic<bool> m_processing;
|
144
|
+
std::atomic<bool> m_firstPoll;
|
145
|
+
std::atomic<bool> m_stop;
|
146
|
+
mutable Mutex m_mutex;
|
147
|
+
};
|
148
|
+
/*! @} */
|
149
|
+
} // namespace FIX
|
150
|
+
|
151
|
+
#endif // FIX_INITIATOR_H
|
@@ -0,0 +1,71 @@
|
|
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 "Log.h"
|
27
|
+
|
28
|
+
namespace FIX {
|
29
|
+
Mutex ScreenLog::s_mutex;
|
30
|
+
|
31
|
+
Log *ScreenLogFactory::create() {
|
32
|
+
bool incoming, outgoing, event;
|
33
|
+
init(m_settings.get(), incoming, outgoing, event);
|
34
|
+
return new ScreenLog(incoming, outgoing, event);
|
35
|
+
}
|
36
|
+
|
37
|
+
Log *ScreenLogFactory::create(const SessionID &sessionID) {
|
38
|
+
Dictionary settings;
|
39
|
+
if (m_settings.has(sessionID)) {
|
40
|
+
settings = m_settings.get(sessionID);
|
41
|
+
}
|
42
|
+
|
43
|
+
bool incoming, outgoing, event;
|
44
|
+
init(settings, incoming, outgoing, event);
|
45
|
+
return new ScreenLog(sessionID, incoming, outgoing, event);
|
46
|
+
}
|
47
|
+
|
48
|
+
void ScreenLogFactory::init(const Dictionary &settings, bool &incoming, bool &outgoing, bool &event) const {
|
49
|
+
if (m_useSettings) {
|
50
|
+
incoming = true;
|
51
|
+
outgoing = true;
|
52
|
+
event = true;
|
53
|
+
|
54
|
+
if (settings.has(SCREEN_LOG_SHOW_INCOMING)) {
|
55
|
+
incoming = settings.getBool(SCREEN_LOG_SHOW_INCOMING);
|
56
|
+
}
|
57
|
+
if (settings.has(SCREEN_LOG_SHOW_OUTGOING)) {
|
58
|
+
outgoing = settings.getBool(SCREEN_LOG_SHOW_OUTGOING);
|
59
|
+
}
|
60
|
+
if (settings.has(SCREEN_LOG_SHOW_EVENTS)) {
|
61
|
+
event = settings.getBool(SCREEN_LOG_SHOW_EVENTS);
|
62
|
+
}
|
63
|
+
} else {
|
64
|
+
incoming = m_incoming;
|
65
|
+
outgoing = m_outgoing;
|
66
|
+
event = m_event;
|
67
|
+
}
|
68
|
+
}
|
69
|
+
|
70
|
+
void ScreenLogFactory::destroy(Log *pLog) { delete pLog; }
|
71
|
+
} // namespace FIX
|