quickfix_ruby 1.14.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/ext/quickfix/Acceptor.cpp +248 -0
- data/ext/quickfix/Acceptor.h +127 -0
- data/ext/quickfix/Allocator.h +9 -0
- data/ext/quickfix/Application.h +127 -0
- data/ext/quickfix/AtomicCount.h +109 -0
- data/ext/quickfix/DOMDocument.h +74 -0
- data/ext/quickfix/DataDictionary.cpp +618 -0
- data/ext/quickfix/DataDictionary.h +539 -0
- data/ext/quickfix/DataDictionaryProvider.cpp +71 -0
- data/ext/quickfix/DataDictionaryProvider.h +70 -0
- data/ext/quickfix/DatabaseConnectionID.h +105 -0
- data/ext/quickfix/DatabaseConnectionPool.h +91 -0
- data/ext/quickfix/Dictionary.cpp +162 -0
- data/ext/quickfix/Dictionary.h +94 -0
- data/ext/quickfix/Event.h +95 -0
- data/ext/quickfix/Exceptions.h +299 -0
- data/ext/quickfix/Field.h +672 -0
- data/ext/quickfix/FieldConvertors.h +863 -0
- data/ext/quickfix/FieldMap.cpp +238 -0
- data/ext/quickfix/FieldMap.h +244 -0
- data/ext/quickfix/FieldNumbers.h +46 -0
- data/ext/quickfix/FieldTypes.cpp +64 -0
- data/ext/quickfix/FieldTypes.h +698 -0
- data/ext/quickfix/Fields.h +31 -0
- data/ext/quickfix/FileLog.cpp +200 -0
- data/ext/quickfix/FileLog.h +112 -0
- data/ext/quickfix/FileStore.cpp +332 -0
- data/ext/quickfix/FileStore.h +129 -0
- data/ext/quickfix/FixFieldNumbers.h +1537 -0
- data/ext/quickfix/FixFields.h +1538 -0
- data/ext/quickfix/FixValues.h +3281 -0
- data/ext/quickfix/FlexLexer.h +188 -0
- data/ext/quickfix/Group.cpp +64 -0
- data/ext/quickfix/Group.h +73 -0
- data/ext/quickfix/HtmlBuilder.h +186 -0
- data/ext/quickfix/HttpConnection.cpp +739 -0
- data/ext/quickfix/HttpConnection.h +78 -0
- data/ext/quickfix/HttpMessage.cpp +149 -0
- data/ext/quickfix/HttpMessage.h +133 -0
- data/ext/quickfix/HttpParser.cpp +49 -0
- data/ext/quickfix/HttpParser.h +54 -0
- data/ext/quickfix/HttpServer.cpp +169 -0
- data/ext/quickfix/HttpServer.h +78 -0
- data/ext/quickfix/Initiator.cpp +289 -0
- data/ext/quickfix/Initiator.h +149 -0
- data/ext/quickfix/Log.cpp +77 -0
- data/ext/quickfix/Log.h +179 -0
- data/ext/quickfix/Message.cpp +580 -0
- data/ext/quickfix/Message.h +370 -0
- data/ext/quickfix/MessageCracker.h +188 -0
- data/ext/quickfix/MessageSorters.cpp +105 -0
- data/ext/quickfix/MessageSorters.h +156 -0
- data/ext/quickfix/MessageStore.cpp +146 -0
- data/ext/quickfix/MessageStore.h +174 -0
- data/ext/quickfix/Mutex.h +131 -0
- data/ext/quickfix/MySQLConnection.h +194 -0
- data/ext/quickfix/MySQLLog.cpp +275 -0
- data/ext/quickfix/MySQLLog.h +145 -0
- data/ext/quickfix/MySQLStore.cpp +331 -0
- data/ext/quickfix/MySQLStore.h +142 -0
- data/ext/quickfix/NullStore.cpp +54 -0
- data/ext/quickfix/NullStore.h +99 -0
- data/ext/quickfix/OdbcConnection.h +266 -0
- data/ext/quickfix/OdbcLog.cpp +252 -0
- data/ext/quickfix/OdbcLog.h +117 -0
- data/ext/quickfix/OdbcStore.cpp +338 -0
- data/ext/quickfix/OdbcStore.h +113 -0
- data/ext/quickfix/PUGIXML_DOMDocument.cpp +112 -0
- data/ext/quickfix/PUGIXML_DOMDocument.h +81 -0
- data/ext/quickfix/Parser.cpp +103 -0
- data/ext/quickfix/Parser.h +57 -0
- data/ext/quickfix/PostgreSQLConnection.h +176 -0
- data/ext/quickfix/PostgreSQLLog.cpp +276 -0
- data/ext/quickfix/PostgreSQLLog.h +144 -0
- data/ext/quickfix/PostgreSQLStore.cpp +334 -0
- data/ext/quickfix/PostgreSQLStore.h +141 -0
- data/ext/quickfix/Queue.h +75 -0
- data/ext/quickfix/QuickfixRuby.cpp +252066 -0
- data/ext/quickfix/QuickfixRuby.h +34 -0
- data/ext/quickfix/Responder.h +43 -0
- data/ext/quickfix/Session.cpp +1487 -0
- data/ext/quickfix/Session.h +335 -0
- data/ext/quickfix/SessionFactory.cpp +274 -0
- data/ext/quickfix/SessionFactory.h +86 -0
- data/ext/quickfix/SessionID.h +170 -0
- data/ext/quickfix/SessionSettings.cpp +189 -0
- data/ext/quickfix/SessionSettings.h +171 -0
- data/ext/quickfix/SessionState.h +231 -0
- data/ext/quickfix/Settings.cpp +100 -0
- data/ext/quickfix/Settings.h +53 -0
- data/ext/quickfix/SharedArray.h +150 -0
- data/ext/quickfix/SocketAcceptor.cpp +222 -0
- data/ext/quickfix/SocketAcceptor.h +75 -0
- data/ext/quickfix/SocketConnection.cpp +238 -0
- data/ext/quickfix/SocketConnection.h +103 -0
- data/ext/quickfix/SocketConnector.cpp +116 -0
- data/ext/quickfix/SocketConnector.h +67 -0
- data/ext/quickfix/SocketInitiator.cpp +260 -0
- data/ext/quickfix/SocketInitiator.h +81 -0
- data/ext/quickfix/SocketMonitor.cpp +335 -0
- data/ext/quickfix/SocketMonitor.h +111 -0
- data/ext/quickfix/SocketServer.cpp +177 -0
- data/ext/quickfix/SocketServer.h +100 -0
- data/ext/quickfix/ThreadedSocketAcceptor.cpp +258 -0
- data/ext/quickfix/ThreadedSocketAcceptor.h +98 -0
- data/ext/quickfix/ThreadedSocketConnection.cpp +209 -0
- data/ext/quickfix/ThreadedSocketConnection.h +82 -0
- data/ext/quickfix/ThreadedSocketInitiator.cpp +268 -0
- data/ext/quickfix/ThreadedSocketInitiator.h +84 -0
- data/ext/quickfix/TimeRange.cpp +173 -0
- data/ext/quickfix/TimeRange.h +258 -0
- data/ext/quickfix/Utility.cpp +537 -0
- data/ext/quickfix/Utility.h +219 -0
- data/ext/quickfix/Values.h +62 -0
- data/ext/quickfix/config.h +0 -0
- data/ext/quickfix/config_windows.h +0 -0
- data/ext/quickfix/extconf.rb +12 -0
- data/ext/quickfix/index.h +37 -0
- data/ext/quickfix/pugiconfig.hpp +72 -0
- data/ext/quickfix/pugixml.cpp +10765 -0
- data/ext/quickfix/pugixml.hpp +1341 -0
- data/ext/quickfix/strptime.h +7 -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 +10721 -0
- data/lib/quickfix50.rb +13426 -0
- data/lib/quickfix50sp1.rb +15629 -0
- data/lib/quickfix50sp2.rb +17068 -0
- data/lib/quickfix_fields.rb +19853 -0
- data/lib/quickfix_ruby.rb +82 -0
- data/lib/quickfixt11.rb +70 -0
- data/spec/FIX40.xml +862 -0
- data/spec/FIX41.xml +1285 -0
- data/spec/FIX42.xml +2746 -0
- data/spec/FIX43.xml +4229 -0
- data/spec/FIX44.xml +6596 -0
- data/spec/FIX50.xml +8137 -0
- data/spec/FIX50SP1.xml +9496 -0
- data/spec/FIX50SP2.xml +10011 -0
- data/spec/FIXT11.xml +313 -0
- data/test/test_DataDictionaryTestCase.rb +268 -0
- data/test/test_DictionaryTestCase.rb +112 -0
- data/test/test_FieldBaseTestCase.rb +24 -0
- data/test/test_MessageTestCase.rb +368 -0
- data/test/test_SessionSettingsTestCase.rb +41 -0
- metadata +193 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 273ec93036845c75bb3992748ac4a18b5a27721c
|
4
|
+
data.tar.gz: 67cdb7e016febd27f95b432b64a7bb6898d150da
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: fdf77c96cbcff9b6ed2310b101cdde95d2aa23b82b3a63525ebf53e60b5f2e943d1b914e72128a462081719e127f307e07906e22502d035ab4552138ed52fa71
|
7
|
+
data.tar.gz: 5a416f856999eaffe2485505634a7f05ade0a92263de45ed98b2b7215c30784a95b3d95347b609f77401e4c5514e5470fc722422142c3428008f900d1f92f1bd
|
@@ -0,0 +1,248 @@
|
|
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 "Utility.h"
|
28
|
+
#include "Session.h"
|
29
|
+
#include "SessionFactory.h"
|
30
|
+
#include "HttpServer.h"
|
31
|
+
#include <algorithm>
|
32
|
+
#include <fstream>
|
33
|
+
|
34
|
+
namespace FIX
|
35
|
+
{
|
36
|
+
Acceptor::Acceptor( Application& application,
|
37
|
+
MessageStoreFactory& messageStoreFactory,
|
38
|
+
const SessionSettings& settings )
|
39
|
+
throw( ConfigError )
|
40
|
+
: m_threadid( 0 ),
|
41
|
+
m_application( application ),
|
42
|
+
m_messageStoreFactory( messageStoreFactory ),
|
43
|
+
m_settings( settings ),
|
44
|
+
m_pLogFactory( 0 ),
|
45
|
+
m_pLog( 0 ),
|
46
|
+
m_firstPoll( true ),
|
47
|
+
m_stop( true )
|
48
|
+
{
|
49
|
+
initialize();
|
50
|
+
}
|
51
|
+
|
52
|
+
Acceptor::Acceptor( Application& application,
|
53
|
+
MessageStoreFactory& messageStoreFactory,
|
54
|
+
const SessionSettings& settings,
|
55
|
+
LogFactory& logFactory )
|
56
|
+
throw( ConfigError )
|
57
|
+
: m_threadid( 0 ),
|
58
|
+
m_application( application ),
|
59
|
+
m_messageStoreFactory( messageStoreFactory ),
|
60
|
+
m_settings( settings ),
|
61
|
+
m_pLogFactory( &logFactory ),
|
62
|
+
m_pLog( logFactory.create() ),
|
63
|
+
m_firstPoll( true ),
|
64
|
+
m_stop( true )
|
65
|
+
{
|
66
|
+
initialize();
|
67
|
+
}
|
68
|
+
|
69
|
+
void Acceptor::initialize() throw ( ConfigError )
|
70
|
+
{
|
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
|
+
SessionFactory factory( m_application, m_messageStoreFactory,
|
78
|
+
m_pLogFactory );
|
79
|
+
|
80
|
+
for ( i = sessions.begin(); i != sessions.end(); ++i )
|
81
|
+
{
|
82
|
+
if ( m_settings.get( *i ).getString( CONNECTION_TYPE ) == "acceptor" )
|
83
|
+
{
|
84
|
+
m_sessionIDs.insert( *i );
|
85
|
+
m_sessions[ *i ] = factory.create( *i, m_settings.get( *i ) );
|
86
|
+
}
|
87
|
+
}
|
88
|
+
|
89
|
+
if ( !m_sessions.size() )
|
90
|
+
throw ConfigError( "No sessions defined for acceptor" );
|
91
|
+
}
|
92
|
+
|
93
|
+
Acceptor::~Acceptor()
|
94
|
+
{
|
95
|
+
Sessions::iterator i;
|
96
|
+
for ( i = m_sessions.begin(); i != m_sessions.end(); ++i )
|
97
|
+
delete i->second;
|
98
|
+
|
99
|
+
if( m_pLogFactory && m_pLog )
|
100
|
+
m_pLogFactory->destroy( m_pLog );
|
101
|
+
}
|
102
|
+
|
103
|
+
Session* Acceptor::getSession
|
104
|
+
( const std::string& msg, Responder& responder )
|
105
|
+
{
|
106
|
+
Message message;
|
107
|
+
if ( !message.setStringHeader( msg ) )
|
108
|
+
return 0;
|
109
|
+
|
110
|
+
BeginString beginString;
|
111
|
+
SenderCompID clSenderCompID;
|
112
|
+
TargetCompID clTargetCompID;
|
113
|
+
MsgType msgType;
|
114
|
+
try
|
115
|
+
{
|
116
|
+
message.getHeader().getField( beginString );
|
117
|
+
message.getHeader().getField( clSenderCompID );
|
118
|
+
message.getHeader().getField( clTargetCompID );
|
119
|
+
message.getHeader().getField( msgType );
|
120
|
+
if ( msgType != "A" ) return 0;
|
121
|
+
|
122
|
+
SenderCompID senderCompID( clTargetCompID );
|
123
|
+
TargetCompID targetCompID( clSenderCompID );
|
124
|
+
SessionID sessionID( beginString, senderCompID, targetCompID );
|
125
|
+
|
126
|
+
Sessions::iterator i = m_sessions.find( sessionID );
|
127
|
+
if ( i != m_sessions.end() )
|
128
|
+
{
|
129
|
+
i->second->setResponder( &responder );
|
130
|
+
return i->second;
|
131
|
+
}
|
132
|
+
}
|
133
|
+
catch ( FieldNotFound& ) {}
|
134
|
+
return 0;
|
135
|
+
}
|
136
|
+
|
137
|
+
Session* Acceptor::getSession( const SessionID& sessionID ) const
|
138
|
+
{
|
139
|
+
Sessions::const_iterator i = m_sessions.find( sessionID );
|
140
|
+
if( i != m_sessions.end() )
|
141
|
+
return i->second;
|
142
|
+
else
|
143
|
+
return 0;
|
144
|
+
}
|
145
|
+
|
146
|
+
const Dictionary* const Acceptor::getSessionSettings( const SessionID& sessionID ) const
|
147
|
+
{
|
148
|
+
try
|
149
|
+
{
|
150
|
+
return &m_settings.get( sessionID );
|
151
|
+
}
|
152
|
+
catch( ConfigError& )
|
153
|
+
{
|
154
|
+
return 0;
|
155
|
+
}
|
156
|
+
}
|
157
|
+
|
158
|
+
void Acceptor::start() throw ( ConfigError, RuntimeError )
|
159
|
+
{
|
160
|
+
m_stop = false;
|
161
|
+
onConfigure( m_settings );
|
162
|
+
onInitialize( m_settings );
|
163
|
+
|
164
|
+
HttpServer::startGlobal( m_settings );
|
165
|
+
|
166
|
+
if( !thread_spawn( &startThread, this, m_threadid ) )
|
167
|
+
throw RuntimeError("Unable to spawn thread");
|
168
|
+
}
|
169
|
+
|
170
|
+
void Acceptor::block() throw ( ConfigError, RuntimeError )
|
171
|
+
{
|
172
|
+
m_stop = false;
|
173
|
+
onConfigure( m_settings );
|
174
|
+
onInitialize( m_settings );
|
175
|
+
|
176
|
+
startThread(this);
|
177
|
+
}
|
178
|
+
|
179
|
+
bool Acceptor::poll( double timeout ) throw ( ConfigError, RuntimeError )
|
180
|
+
{
|
181
|
+
if( m_firstPoll )
|
182
|
+
{
|
183
|
+
m_stop = false;
|
184
|
+
onConfigure( m_settings );
|
185
|
+
onInitialize( m_settings );
|
186
|
+
m_firstPoll = false;
|
187
|
+
}
|
188
|
+
|
189
|
+
return onPoll( timeout );
|
190
|
+
}
|
191
|
+
|
192
|
+
void Acceptor::stop( bool force )
|
193
|
+
{
|
194
|
+
if( isStopped() ) return;
|
195
|
+
|
196
|
+
HttpServer::stopGlobal();
|
197
|
+
|
198
|
+
std::vector<Session*> enabledSessions;
|
199
|
+
|
200
|
+
Sessions sessions = m_sessions;
|
201
|
+
Sessions::iterator i = sessions.begin();
|
202
|
+
for ( ; i != sessions.end(); ++i )
|
203
|
+
{
|
204
|
+
Session* pSession = Session::lookupSession(i->first);
|
205
|
+
if( pSession && pSession->isEnabled() )
|
206
|
+
{
|
207
|
+
enabledSessions.push_back( pSession );
|
208
|
+
pSession->logout();
|
209
|
+
Session::unregisterSession( pSession->getSessionID() );
|
210
|
+
}
|
211
|
+
}
|
212
|
+
|
213
|
+
if( !force )
|
214
|
+
{
|
215
|
+
for ( int second = 1; second <= 10 && isLoggedOn(); ++second )
|
216
|
+
process_sleep( 1 );
|
217
|
+
}
|
218
|
+
|
219
|
+
m_stop = true;
|
220
|
+
onStop();
|
221
|
+
if( m_threadid )
|
222
|
+
thread_join( m_threadid );
|
223
|
+
m_threadid = 0;
|
224
|
+
|
225
|
+
std::vector<Session*>::iterator session = enabledSessions.begin();
|
226
|
+
for( ; session != enabledSessions.end(); ++session )
|
227
|
+
(*session)->logon();
|
228
|
+
}
|
229
|
+
|
230
|
+
bool Acceptor::isLoggedOn()
|
231
|
+
{
|
232
|
+
Sessions sessions = m_sessions;
|
233
|
+
Sessions::iterator i = sessions.begin();
|
234
|
+
for ( ; i != sessions.end(); ++i )
|
235
|
+
{
|
236
|
+
if( i->second->isLoggedOn() )
|
237
|
+
return true;
|
238
|
+
}
|
239
|
+
return false;
|
240
|
+
}
|
241
|
+
|
242
|
+
THREAD_PROC Acceptor::startThread( void* p )
|
243
|
+
{
|
244
|
+
Acceptor * pAcceptor = static_cast < Acceptor* > ( p );
|
245
|
+
pAcceptor->onStart();
|
246
|
+
return 0;
|
247
|
+
}
|
248
|
+
}
|
@@ -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 "MessageStore.h"
|
31
|
+
#include "Log.h"
|
32
|
+
#include "Responder.h"
|
33
|
+
#include "SessionSettings.h"
|
34
|
+
#include "Exceptions.h"
|
35
|
+
#include <map>
|
36
|
+
#include <string>
|
37
|
+
|
38
|
+
namespace FIX
|
39
|
+
{
|
40
|
+
class Client;
|
41
|
+
class Session;
|
42
|
+
|
43
|
+
/**
|
44
|
+
* Base for classes which act as an acceptor for incoming connections.
|
45
|
+
*
|
46
|
+
* Most users will not need to implement one of these. The default
|
47
|
+
* SocketAcceptor implementation will be used in most cases.
|
48
|
+
*/
|
49
|
+
class Acceptor
|
50
|
+
{
|
51
|
+
public:
|
52
|
+
Acceptor( Application&, MessageStoreFactory&,
|
53
|
+
const SessionSettings& ) throw( ConfigError );
|
54
|
+
Acceptor( Application&, MessageStoreFactory&,
|
55
|
+
const SessionSettings&, LogFactory& ) throw( ConfigError );
|
56
|
+
|
57
|
+
virtual ~Acceptor();
|
58
|
+
|
59
|
+
Log* getLog()
|
60
|
+
{
|
61
|
+
if( m_pLog ) return m_pLog;
|
62
|
+
return &m_nullLog;
|
63
|
+
}
|
64
|
+
|
65
|
+
/// Start acceptor.
|
66
|
+
void start() throw ( ConfigError, RuntimeError );
|
67
|
+
/// Block on the acceptor
|
68
|
+
void block() throw ( ConfigError, RuntimeError );
|
69
|
+
/// Poll the acceptor
|
70
|
+
bool poll( double timeout = 0.0 ) throw ( ConfigError, RuntimeError );
|
71
|
+
|
72
|
+
/// Stop acceptor.
|
73
|
+
void stop( bool force = false );
|
74
|
+
|
75
|
+
/// Check to see if any sessions are currently logged on
|
76
|
+
bool isLoggedOn();
|
77
|
+
|
78
|
+
Session* getSession( const std::string& msg, Responder& );
|
79
|
+
|
80
|
+
const std::set<SessionID>& getSessions() const { return m_sessionIDs; }
|
81
|
+
Session* getSession( const SessionID& sessionID ) const;
|
82
|
+
const Dictionary* const getSessionSettings( const SessionID& sessionID ) const;
|
83
|
+
|
84
|
+
bool has( const SessionID& id )
|
85
|
+
{ return m_sessions.find( id ) != m_sessions.end(); }
|
86
|
+
|
87
|
+
bool isStopped() { return m_stop; }
|
88
|
+
|
89
|
+
Application& getApplication() { return m_application; }
|
90
|
+
MessageStoreFactory& getMessageStoreFactory()
|
91
|
+
{ return m_messageStoreFactory; }
|
92
|
+
|
93
|
+
private:
|
94
|
+
void initialize() throw ( ConfigError );
|
95
|
+
|
96
|
+
/// Implemented to configure acceptor
|
97
|
+
virtual void onConfigure( const SessionSettings& ) throw ( ConfigError ) {};
|
98
|
+
/// Implemented to initialize acceptor
|
99
|
+
virtual void onInitialize( const SessionSettings& ) throw ( RuntimeError ) {};
|
100
|
+
/// Implemented to start listening for connections.
|
101
|
+
virtual void onStart() = 0;
|
102
|
+
/// Implemented to connect and poll for events.
|
103
|
+
virtual bool onPoll( double second ) = 0;
|
104
|
+
/// Implemented to stop a running acceptor.
|
105
|
+
virtual void onStop() = 0;
|
106
|
+
|
107
|
+
static THREAD_PROC startThread( void* p );
|
108
|
+
|
109
|
+
typedef std::set < SessionID > SessionIDs;
|
110
|
+
typedef std::map < SessionID, Session* > Sessions;
|
111
|
+
|
112
|
+
thread_id m_threadid;
|
113
|
+
Sessions m_sessions;
|
114
|
+
SessionIDs m_sessionIDs;
|
115
|
+
Application& m_application;
|
116
|
+
MessageStoreFactory& m_messageStoreFactory;
|
117
|
+
SessionSettings m_settings;
|
118
|
+
LogFactory* m_pLogFactory;
|
119
|
+
Log* m_pLog;
|
120
|
+
NullLog m_nullLog;
|
121
|
+
bool m_firstPoll;
|
122
|
+
bool m_stop;
|
123
|
+
};
|
124
|
+
/*! @} */
|
125
|
+
}
|
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,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_APPLICATION_H
|
23
|
+
#define FIX_APPLICATION_H
|
24
|
+
|
25
|
+
#include "Message.h"
|
26
|
+
#include "SessionID.h"
|
27
|
+
#include "Mutex.h"
|
28
|
+
|
29
|
+
namespace FIX
|
30
|
+
{
|
31
|
+
/**
|
32
|
+
* This interface must be implemented to define what your %FIX application
|
33
|
+
* does.
|
34
|
+
*
|
35
|
+
* These methods notify your application about events that happen on
|
36
|
+
* active %FIX sessions. There is no guarantee how many threads will be calling
|
37
|
+
* these functions. If the application is sharing resources among multiple sessions,
|
38
|
+
* you must synchronize those resources. You can also use the SynchronizedApplication
|
39
|
+
* class to automatically synchronize all function calls into your application.
|
40
|
+
* The various MessageCracker classes can be used to parse the generic message
|
41
|
+
* structure into specific %FIX messages.
|
42
|
+
*/
|
43
|
+
class Application
|
44
|
+
{
|
45
|
+
public:
|
46
|
+
virtual ~Application() {};
|
47
|
+
/// Notification of a session begin created
|
48
|
+
virtual void onCreate( const SessionID& ) = 0;
|
49
|
+
/// Notification of a session successfully logging on
|
50
|
+
virtual void onLogon( const SessionID& ) = 0;
|
51
|
+
/// Notification of a session logging off or disconnecting
|
52
|
+
virtual void onLogout( const SessionID& ) = 0;
|
53
|
+
/// Notification of admin message being sent to target
|
54
|
+
virtual void toAdmin( Message&, const SessionID& ) = 0;
|
55
|
+
/// Notification of app message being sent to target
|
56
|
+
virtual void toApp( Message&, const SessionID& )
|
57
|
+
throw( DoNotSend ) = 0;
|
58
|
+
/// Notification of admin message being received from target
|
59
|
+
virtual void fromAdmin( const Message&, const SessionID& )
|
60
|
+
throw( FieldNotFound, IncorrectDataFormat, IncorrectTagValue, RejectLogon ) = 0;
|
61
|
+
/// Notification of app message being received from target
|
62
|
+
virtual void fromApp( const Message&, const SessionID& )
|
63
|
+
throw( FieldNotFound, IncorrectDataFormat, IncorrectTagValue, UnsupportedMessageType ) = 0;
|
64
|
+
};
|
65
|
+
|
66
|
+
/**
|
67
|
+
* This is a special implementation of the Application interface that takes
|
68
|
+
* in another Application interface and synchronizes all of its callbacks. This
|
69
|
+
* will guarantee that only one thread will access the applications code at a time.
|
70
|
+
*
|
71
|
+
* This class is a great convenience for writing applications where you
|
72
|
+
* don't want to worry about synchronization. There is of course a tradeoff
|
73
|
+
* in that you may be synchronizing more than you need to. There is also a very
|
74
|
+
* minor performance penalty due to the extra virtual table lookup.
|
75
|
+
*/
|
76
|
+
class SynchronizedApplication : public Application
|
77
|
+
{
|
78
|
+
public:
|
79
|
+
SynchronizedApplication( Application& app ) : m_app( app ) {}
|
80
|
+
|
81
|
+
void onCreate( const SessionID& sessionID )
|
82
|
+
{ Locker l( m_mutex ); app().onCreate( sessionID ); }
|
83
|
+
void onLogon( const SessionID& sessionID )
|
84
|
+
{ Locker l( m_mutex ); app().onLogon( sessionID ); }
|
85
|
+
void onLogout( const SessionID& sessionID )
|
86
|
+
{ Locker l( m_mutex ); app().onLogout( sessionID ); }
|
87
|
+
void toAdmin( Message& message, const SessionID& sessionID )
|
88
|
+
{ Locker l( m_mutex ); app().toAdmin( message, sessionID ); }
|
89
|
+
void toApp( Message& message, const SessionID& sessionID )
|
90
|
+
throw( DoNotSend )
|
91
|
+
{ Locker l( m_mutex ); app().toApp( message, sessionID ); }
|
92
|
+
void fromAdmin( const Message& message, const SessionID& sessionID )
|
93
|
+
throw( FieldNotFound, IncorrectDataFormat, IncorrectTagValue, RejectLogon )
|
94
|
+
{ Locker l( m_mutex ); app().fromAdmin( message, sessionID ); }
|
95
|
+
void fromApp( const Message& message, const SessionID& sessionID )
|
96
|
+
throw( FieldNotFound, IncorrectDataFormat, IncorrectTagValue, UnsupportedMessageType )
|
97
|
+
{ Locker l( m_mutex ); app().fromApp( message, sessionID ); }
|
98
|
+
|
99
|
+
Mutex m_mutex;
|
100
|
+
|
101
|
+
Application& app() { return m_app; }
|
102
|
+
Application& m_app;
|
103
|
+
};
|
104
|
+
|
105
|
+
/**
|
106
|
+
* An empty implementation of an Application. This can be used if you
|
107
|
+
* do not want to provide an implementation for all the callback methods.
|
108
|
+
* It is also useful for unit tests writing unit tests where the callback
|
109
|
+
* values of some or all methods are not of interest.
|
110
|
+
*/
|
111
|
+
class NullApplication : public Application
|
112
|
+
{
|
113
|
+
void onCreate( const SessionID& ) {}
|
114
|
+
void onLogon( const SessionID& ) {}
|
115
|
+
void onLogout( const SessionID& ) {}
|
116
|
+
void toAdmin( Message&, const SessionID& ) {}
|
117
|
+
void toApp( Message&, const SessionID& )
|
118
|
+
throw( DoNotSend ) {}
|
119
|
+
void fromAdmin( const Message&, const SessionID& )
|
120
|
+
throw( FieldNotFound, IncorrectDataFormat, IncorrectTagValue, RejectLogon ) {}
|
121
|
+
void fromApp( const Message&, const SessionID& )
|
122
|
+
throw( FieldNotFound, IncorrectDataFormat, IncorrectTagValue, UnsupportedMessageType ) {}
|
123
|
+
};
|
124
|
+
/*! @} */
|
125
|
+
}
|
126
|
+
|
127
|
+
#endif //FIX_APPLICATION_H
|
@@ -0,0 +1,109 @@
|
|
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 ATOMIC_COUNT
|
23
|
+
#define ATOMIC_COUNT
|
24
|
+
|
25
|
+
#include "Mutex.h"
|
26
|
+
|
27
|
+
namespace FIX
|
28
|
+
{
|
29
|
+
/// Atomic count class - consider using interlocked functions
|
30
|
+
|
31
|
+
#ifdef ENABLE_BOOST_ATOMIC_COUNT
|
32
|
+
|
33
|
+
#include <boost/smart_ptr/detail/atomic_count.hpp>
|
34
|
+
typedef boost::detail::atomic_count atomic_count;
|
35
|
+
|
36
|
+
#elif _MSC_VER
|
37
|
+
|
38
|
+
//atomic counter based on interlocked functions for Win32
|
39
|
+
class atomic_count
|
40
|
+
{
|
41
|
+
public:
|
42
|
+
explicit atomic_count( long v ): m_counter( v )
|
43
|
+
{
|
44
|
+
}
|
45
|
+
|
46
|
+
long operator++()
|
47
|
+
{
|
48
|
+
return ::InterlockedIncrement( &m_counter );
|
49
|
+
}
|
50
|
+
|
51
|
+
long operator--()
|
52
|
+
{
|
53
|
+
return ::InterlockedDecrement( &m_counter );
|
54
|
+
}
|
55
|
+
|
56
|
+
operator long() const
|
57
|
+
{
|
58
|
+
return static_cast<long const volatile &>( m_counter );
|
59
|
+
}
|
60
|
+
|
61
|
+
private:
|
62
|
+
|
63
|
+
atomic_count( atomic_count const & );
|
64
|
+
atomic_count & operator=( atomic_count const & );
|
65
|
+
|
66
|
+
long volatile m_counter;
|
67
|
+
};
|
68
|
+
|
69
|
+
#else
|
70
|
+
// general purpose atomic counter using mutexes
|
71
|
+
class atomic_count
|
72
|
+
{
|
73
|
+
public:
|
74
|
+
explicit atomic_count( long v ): m_counter( v )
|
75
|
+
{
|
76
|
+
}
|
77
|
+
|
78
|
+
long operator++()
|
79
|
+
{
|
80
|
+
Locker _lock(m_mutex);
|
81
|
+
return ++m_counter;
|
82
|
+
}
|
83
|
+
|
84
|
+
long operator--()
|
85
|
+
{
|
86
|
+
Locker _lock(m_mutex);
|
87
|
+
return --m_counter;
|
88
|
+
}
|
89
|
+
|
90
|
+
operator long() const
|
91
|
+
{
|
92
|
+
return static_cast<long const volatile &>( m_counter );
|
93
|
+
}
|
94
|
+
|
95
|
+
private:
|
96
|
+
|
97
|
+
atomic_count( atomic_count const & );
|
98
|
+
atomic_count & operator=( atomic_count const & );
|
99
|
+
|
100
|
+
Mutex m_mutex;
|
101
|
+
long m_counter;
|
102
|
+
};
|
103
|
+
|
104
|
+
#endif
|
105
|
+
|
106
|
+
}
|
107
|
+
|
108
|
+
#endif
|
109
|
+
|
@@ -0,0 +1,74 @@
|
|
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 <string>
|
26
|
+
#include <map>
|
27
|
+
#include <iostream>
|
28
|
+
#include <memory>
|
29
|
+
|
30
|
+
namespace FIX
|
31
|
+
{
|
32
|
+
/// Interface that represents attribute from underlying XML parser.
|
33
|
+
class DOMAttributes
|
34
|
+
{
|
35
|
+
public:
|
36
|
+
typedef std::map<std::string, std::string> map;
|
37
|
+
|
38
|
+
virtual ~DOMAttributes() {}
|
39
|
+
|
40
|
+
virtual bool get( const std::string&, std::string& ) = 0;
|
41
|
+
virtual map toMap() = 0;
|
42
|
+
};
|
43
|
+
typedef std::auto_ptr<DOMAttributes> DOMAttributesPtr;
|
44
|
+
|
45
|
+
/// Interface that represents node from underlying XML parser.
|
46
|
+
class DOMNode
|
47
|
+
{
|
48
|
+
public:
|
49
|
+
virtual ~DOMNode() {}
|
50
|
+
|
51
|
+
virtual std::auto_ptr<DOMNode> getFirstChildNode() = 0;
|
52
|
+
virtual std::auto_ptr<DOMNode> getNextSiblingNode() = 0;
|
53
|
+
virtual std::auto_ptr<DOMAttributes> getAttributes() = 0;
|
54
|
+
virtual std::string getName() = 0;
|
55
|
+
virtual std::string getText() = 0;
|
56
|
+
};
|
57
|
+
typedef std::auto_ptr<DOMNode> DOMNodePtr;
|
58
|
+
|
59
|
+
/// Interface that represents document of underlying XML parser.
|
60
|
+
class DOMDocument
|
61
|
+
{
|
62
|
+
public:
|
63
|
+
virtual ~DOMDocument() {}
|
64
|
+
|
65
|
+
virtual bool load( std::istream& ) = 0;
|
66
|
+
virtual bool load( const std::string& ) = 0;
|
67
|
+
virtual bool xml( std::ostream& ) = 0;
|
68
|
+
|
69
|
+
virtual std::auto_ptr<DOMNode> getNode( const std::string& ) = 0;
|
70
|
+
};
|
71
|
+
typedef std::auto_ptr<DOMDocument> DOMDocumentPtr;
|
72
|
+
}
|
73
|
+
|
74
|
+
#endif
|