quickfix_ruby 1.14.3

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 (149) hide show
  1. checksums.yaml +7 -0
  2. data/ext/quickfix/Acceptor.cpp +248 -0
  3. data/ext/quickfix/Acceptor.h +127 -0
  4. data/ext/quickfix/Allocator.h +9 -0
  5. data/ext/quickfix/Application.h +127 -0
  6. data/ext/quickfix/AtomicCount.h +109 -0
  7. data/ext/quickfix/DOMDocument.h +74 -0
  8. data/ext/quickfix/DataDictionary.cpp +618 -0
  9. data/ext/quickfix/DataDictionary.h +539 -0
  10. data/ext/quickfix/DataDictionaryProvider.cpp +71 -0
  11. data/ext/quickfix/DataDictionaryProvider.h +70 -0
  12. data/ext/quickfix/DatabaseConnectionID.h +105 -0
  13. data/ext/quickfix/DatabaseConnectionPool.h +91 -0
  14. data/ext/quickfix/Dictionary.cpp +162 -0
  15. data/ext/quickfix/Dictionary.h +94 -0
  16. data/ext/quickfix/Event.h +95 -0
  17. data/ext/quickfix/Exceptions.h +299 -0
  18. data/ext/quickfix/Field.h +672 -0
  19. data/ext/quickfix/FieldConvertors.h +863 -0
  20. data/ext/quickfix/FieldMap.cpp +238 -0
  21. data/ext/quickfix/FieldMap.h +244 -0
  22. data/ext/quickfix/FieldNumbers.h +46 -0
  23. data/ext/quickfix/FieldTypes.cpp +64 -0
  24. data/ext/quickfix/FieldTypes.h +698 -0
  25. data/ext/quickfix/Fields.h +31 -0
  26. data/ext/quickfix/FileLog.cpp +200 -0
  27. data/ext/quickfix/FileLog.h +112 -0
  28. data/ext/quickfix/FileStore.cpp +332 -0
  29. data/ext/quickfix/FileStore.h +129 -0
  30. data/ext/quickfix/FixFieldNumbers.h +1537 -0
  31. data/ext/quickfix/FixFields.h +1538 -0
  32. data/ext/quickfix/FixValues.h +3281 -0
  33. data/ext/quickfix/FlexLexer.h +188 -0
  34. data/ext/quickfix/Group.cpp +64 -0
  35. data/ext/quickfix/Group.h +73 -0
  36. data/ext/quickfix/HtmlBuilder.h +186 -0
  37. data/ext/quickfix/HttpConnection.cpp +739 -0
  38. data/ext/quickfix/HttpConnection.h +78 -0
  39. data/ext/quickfix/HttpMessage.cpp +149 -0
  40. data/ext/quickfix/HttpMessage.h +133 -0
  41. data/ext/quickfix/HttpParser.cpp +49 -0
  42. data/ext/quickfix/HttpParser.h +54 -0
  43. data/ext/quickfix/HttpServer.cpp +169 -0
  44. data/ext/quickfix/HttpServer.h +78 -0
  45. data/ext/quickfix/Initiator.cpp +289 -0
  46. data/ext/quickfix/Initiator.h +149 -0
  47. data/ext/quickfix/Log.cpp +77 -0
  48. data/ext/quickfix/Log.h +179 -0
  49. data/ext/quickfix/Message.cpp +580 -0
  50. data/ext/quickfix/Message.h +370 -0
  51. data/ext/quickfix/MessageCracker.h +188 -0
  52. data/ext/quickfix/MessageSorters.cpp +105 -0
  53. data/ext/quickfix/MessageSorters.h +156 -0
  54. data/ext/quickfix/MessageStore.cpp +146 -0
  55. data/ext/quickfix/MessageStore.h +174 -0
  56. data/ext/quickfix/Mutex.h +131 -0
  57. data/ext/quickfix/MySQLConnection.h +194 -0
  58. data/ext/quickfix/MySQLLog.cpp +275 -0
  59. data/ext/quickfix/MySQLLog.h +145 -0
  60. data/ext/quickfix/MySQLStore.cpp +331 -0
  61. data/ext/quickfix/MySQLStore.h +142 -0
  62. data/ext/quickfix/NullStore.cpp +54 -0
  63. data/ext/quickfix/NullStore.h +99 -0
  64. data/ext/quickfix/OdbcConnection.h +266 -0
  65. data/ext/quickfix/OdbcLog.cpp +252 -0
  66. data/ext/quickfix/OdbcLog.h +117 -0
  67. data/ext/quickfix/OdbcStore.cpp +338 -0
  68. data/ext/quickfix/OdbcStore.h +113 -0
  69. data/ext/quickfix/PUGIXML_DOMDocument.cpp +112 -0
  70. data/ext/quickfix/PUGIXML_DOMDocument.h +81 -0
  71. data/ext/quickfix/Parser.cpp +103 -0
  72. data/ext/quickfix/Parser.h +57 -0
  73. data/ext/quickfix/PostgreSQLConnection.h +176 -0
  74. data/ext/quickfix/PostgreSQLLog.cpp +276 -0
  75. data/ext/quickfix/PostgreSQLLog.h +144 -0
  76. data/ext/quickfix/PostgreSQLStore.cpp +334 -0
  77. data/ext/quickfix/PostgreSQLStore.h +141 -0
  78. data/ext/quickfix/Queue.h +75 -0
  79. data/ext/quickfix/QuickfixRuby.cpp +252066 -0
  80. data/ext/quickfix/QuickfixRuby.h +34 -0
  81. data/ext/quickfix/Responder.h +43 -0
  82. data/ext/quickfix/Session.cpp +1487 -0
  83. data/ext/quickfix/Session.h +335 -0
  84. data/ext/quickfix/SessionFactory.cpp +274 -0
  85. data/ext/quickfix/SessionFactory.h +86 -0
  86. data/ext/quickfix/SessionID.h +170 -0
  87. data/ext/quickfix/SessionSettings.cpp +189 -0
  88. data/ext/quickfix/SessionSettings.h +171 -0
  89. data/ext/quickfix/SessionState.h +231 -0
  90. data/ext/quickfix/Settings.cpp +100 -0
  91. data/ext/quickfix/Settings.h +53 -0
  92. data/ext/quickfix/SharedArray.h +150 -0
  93. data/ext/quickfix/SocketAcceptor.cpp +222 -0
  94. data/ext/quickfix/SocketAcceptor.h +75 -0
  95. data/ext/quickfix/SocketConnection.cpp +238 -0
  96. data/ext/quickfix/SocketConnection.h +103 -0
  97. data/ext/quickfix/SocketConnector.cpp +116 -0
  98. data/ext/quickfix/SocketConnector.h +67 -0
  99. data/ext/quickfix/SocketInitiator.cpp +260 -0
  100. data/ext/quickfix/SocketInitiator.h +81 -0
  101. data/ext/quickfix/SocketMonitor.cpp +335 -0
  102. data/ext/quickfix/SocketMonitor.h +111 -0
  103. data/ext/quickfix/SocketServer.cpp +177 -0
  104. data/ext/quickfix/SocketServer.h +100 -0
  105. data/ext/quickfix/ThreadedSocketAcceptor.cpp +258 -0
  106. data/ext/quickfix/ThreadedSocketAcceptor.h +98 -0
  107. data/ext/quickfix/ThreadedSocketConnection.cpp +209 -0
  108. data/ext/quickfix/ThreadedSocketConnection.h +82 -0
  109. data/ext/quickfix/ThreadedSocketInitiator.cpp +268 -0
  110. data/ext/quickfix/ThreadedSocketInitiator.h +84 -0
  111. data/ext/quickfix/TimeRange.cpp +173 -0
  112. data/ext/quickfix/TimeRange.h +258 -0
  113. data/ext/quickfix/Utility.cpp +537 -0
  114. data/ext/quickfix/Utility.h +219 -0
  115. data/ext/quickfix/Values.h +62 -0
  116. data/ext/quickfix/config.h +0 -0
  117. data/ext/quickfix/config_windows.h +0 -0
  118. data/ext/quickfix/extconf.rb +12 -0
  119. data/ext/quickfix/index.h +37 -0
  120. data/ext/quickfix/pugiconfig.hpp +72 -0
  121. data/ext/quickfix/pugixml.cpp +10765 -0
  122. data/ext/quickfix/pugixml.hpp +1341 -0
  123. data/ext/quickfix/strptime.h +7 -0
  124. data/lib/quickfix40.rb +274 -0
  125. data/lib/quickfix41.rb +351 -0
  126. data/lib/quickfix42.rb +1184 -0
  127. data/lib/quickfix43.rb +3504 -0
  128. data/lib/quickfix44.rb +10721 -0
  129. data/lib/quickfix50.rb +13426 -0
  130. data/lib/quickfix50sp1.rb +15629 -0
  131. data/lib/quickfix50sp2.rb +17068 -0
  132. data/lib/quickfix_fields.rb +19853 -0
  133. data/lib/quickfix_ruby.rb +82 -0
  134. data/lib/quickfixt11.rb +70 -0
  135. data/spec/FIX40.xml +862 -0
  136. data/spec/FIX41.xml +1285 -0
  137. data/spec/FIX42.xml +2746 -0
  138. data/spec/FIX43.xml +4229 -0
  139. data/spec/FIX44.xml +6596 -0
  140. data/spec/FIX50.xml +8137 -0
  141. data/spec/FIX50SP1.xml +9496 -0
  142. data/spec/FIX50SP2.xml +10011 -0
  143. data/spec/FIXT11.xml +313 -0
  144. data/test/test_DataDictionaryTestCase.rb +268 -0
  145. data/test/test_DictionaryTestCase.rb +112 -0
  146. data/test/test_FieldBaseTestCase.rb +24 -0
  147. data/test/test_MessageTestCase.rb +368 -0
  148. data/test/test_SessionSettingsTestCase.rb +41 -0
  149. metadata +193 -0
@@ -0,0 +1,289 @@
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 "Initiator.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
+ Initiator::Initiator( Application& application,
37
+ MessageStoreFactory& messageStoreFactory,
38
+ const SessionSettings& settings ) throw( 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_firstPoll( true ),
46
+ m_stop( true )
47
+ { initialize(); }
48
+
49
+ Initiator::Initiator( Application& application,
50
+ MessageStoreFactory& messageStoreFactory,
51
+ const SessionSettings& settings,
52
+ LogFactory& logFactory ) throw( ConfigError )
53
+ : m_threadid( 0 ),
54
+ m_application( application ),
55
+ m_messageStoreFactory( messageStoreFactory ),
56
+ m_settings( settings ),
57
+ m_pLogFactory( &logFactory ),
58
+ m_pLog( logFactory.create() ),
59
+ m_firstPoll( true ),
60
+ m_stop( true )
61
+ { initialize(); }
62
+
63
+ void Initiator::initialize() throw ( ConfigError )
64
+ {
65
+ std::set < SessionID > sessions = m_settings.getSessions();
66
+ std::set < SessionID > ::iterator i;
67
+
68
+ if ( !sessions.size() )
69
+ throw ConfigError( "No sessions defined" );
70
+
71
+ SessionFactory factory( m_application, m_messageStoreFactory,
72
+ m_pLogFactory );
73
+
74
+ for ( i = sessions.begin(); i != sessions.end(); ++i )
75
+ {
76
+ if ( m_settings.get( *i ).getString( "ConnectionType" ) == "initiator" )
77
+ {
78
+ m_sessionIDs.insert( *i );
79
+ m_sessions[ *i ] = factory.create( *i, m_settings.get( *i ) );
80
+ setDisconnected( *i );
81
+ }
82
+ }
83
+
84
+ if ( !m_sessions.size() )
85
+ throw ConfigError( "No sessions defined for initiator" );
86
+ }
87
+
88
+ Initiator::~Initiator()
89
+ {
90
+ Sessions::iterator i;
91
+ for ( i = m_sessions.begin(); i != m_sessions.end(); ++i )
92
+ delete i->second;
93
+
94
+ if( m_pLogFactory && m_pLog )
95
+ m_pLogFactory->destroy( m_pLog );
96
+ }
97
+
98
+ Session* Initiator::getSession( const SessionID& sessionID,
99
+ Responder& responder )
100
+ {
101
+ Sessions::iterator i = m_sessions.find( sessionID );
102
+ if ( i != m_sessions.end() )
103
+ {
104
+ i->second->setResponder( &responder );
105
+ return i->second;
106
+ }
107
+ return 0;
108
+ }
109
+
110
+ Session* Initiator::getSession( const SessionID& sessionID ) const
111
+ {
112
+ Sessions::const_iterator i = m_sessions.find( sessionID );
113
+ if( i != m_sessions.end() )
114
+ return i->second;
115
+ else
116
+ return 0;
117
+ }
118
+
119
+ const Dictionary* const Initiator::getSessionSettings( const SessionID& sessionID ) const
120
+ {
121
+ try
122
+ {
123
+ return &m_settings.get( sessionID );
124
+ }
125
+ catch( ConfigError& )
126
+ {
127
+ return 0;
128
+ }
129
+ }
130
+
131
+ void Initiator::connect()
132
+ {
133
+ Locker l(m_mutex);
134
+
135
+ SessionIDs disconnected = m_disconnected;
136
+ SessionIDs::iterator i = disconnected.begin();
137
+ for ( ; i != disconnected.end(); ++i )
138
+ {
139
+ Session* pSession = Session::lookupSession( *i );
140
+ if ( pSession->isEnabled() && pSession->isSessionTime(UtcTimeStamp()) )
141
+ doConnect( *i, m_settings.get( *i ));
142
+ }
143
+ }
144
+
145
+ void Initiator::setPending( const SessionID& sessionID )
146
+ {
147
+ Locker l(m_mutex);
148
+
149
+ m_pending.insert( sessionID );
150
+ m_connected.erase( sessionID );
151
+ m_disconnected.erase( sessionID );
152
+ }
153
+
154
+ void Initiator::setConnected( const SessionID& sessionID )
155
+ {
156
+ Locker l(m_mutex);
157
+
158
+ m_pending.erase( sessionID );
159
+ m_connected.insert( sessionID );
160
+ m_disconnected.erase( sessionID );
161
+ }
162
+
163
+ void Initiator::setDisconnected( const SessionID& sessionID )
164
+ {
165
+ Locker l(m_mutex);
166
+
167
+ m_pending.erase( sessionID );
168
+ m_connected.erase( sessionID );
169
+ m_disconnected.insert( sessionID );
170
+ }
171
+
172
+ bool Initiator::isPending( const SessionID& sessionID )
173
+ {
174
+ Locker l(m_mutex);
175
+ return m_pending.find( sessionID ) != m_pending.end();
176
+ }
177
+
178
+ bool Initiator::isConnected( const SessionID& sessionID )
179
+ {
180
+ Locker l(m_mutex);
181
+ return m_connected.find( sessionID ) != m_connected.end();
182
+ }
183
+
184
+ bool Initiator::isDisconnected( const SessionID& sessionID )
185
+ {
186
+ Locker l(m_mutex);
187
+ return m_disconnected.find( sessionID ) != m_disconnected.end();
188
+ }
189
+
190
+ void Initiator::start() throw ( ConfigError, RuntimeError )
191
+ {
192
+ m_stop = false;
193
+ onConfigure( m_settings );
194
+ onInitialize( m_settings );
195
+
196
+ HttpServer::startGlobal( m_settings );
197
+
198
+ if( !thread_spawn( &startThread, this, m_threadid ) )
199
+ throw RuntimeError("Unable to spawn thread");
200
+ }
201
+
202
+
203
+ void Initiator::block() throw ( ConfigError, RuntimeError )
204
+ {
205
+ m_stop = false;
206
+ onConfigure( m_settings );
207
+ onInitialize( m_settings );
208
+
209
+ startThread(this);
210
+ }
211
+
212
+ bool Initiator::poll( double timeout ) throw ( ConfigError, RuntimeError )
213
+ {
214
+ if( m_firstPoll )
215
+ {
216
+ m_stop = false;
217
+ onConfigure( m_settings );
218
+ onInitialize( m_settings );
219
+ connect();
220
+ m_firstPoll = false;
221
+ }
222
+
223
+ return onPoll( timeout );
224
+ }
225
+
226
+ void Initiator::stop( bool force )
227
+ {
228
+ if( isStopped() ) return;
229
+
230
+ HttpServer::stopGlobal();
231
+
232
+ std::vector<Session*> enabledSessions;
233
+
234
+ SessionIDs connected = m_connected;
235
+ SessionIDs::iterator i = connected.begin();
236
+ for ( ; i != connected.end(); ++i )
237
+ {
238
+ Session* pSession = Session::lookupSession(*i);
239
+ if( pSession && pSession->isEnabled() )
240
+ {
241
+ enabledSessions.push_back( pSession );
242
+ pSession->logout();
243
+ }
244
+ }
245
+
246
+ if( !force )
247
+ {
248
+ for ( int second = 1; second <= 10 && isLoggedOn(); ++second )
249
+ process_sleep( 1 );
250
+ }
251
+
252
+ {
253
+ Locker l(m_mutex);
254
+ for ( i = connected.begin(); i != connected.end(); ++i )
255
+ setDisconnected( Session::lookupSession(*i)->getSessionID() );
256
+ }
257
+
258
+ m_stop = true;
259
+ onStop();
260
+ if( m_threadid )
261
+ thread_join( m_threadid );
262
+ m_threadid = 0;
263
+
264
+ std::vector<Session*>::iterator session = enabledSessions.begin();
265
+ for( ; session != enabledSessions.end(); ++session )
266
+ (*session)->logon();
267
+ }
268
+
269
+ bool Initiator::isLoggedOn()
270
+ {
271
+ Locker l(m_mutex);
272
+
273
+ SessionIDs connected = m_connected;
274
+ SessionIDs::iterator i = connected.begin();
275
+ for ( ; i != connected.end(); ++i )
276
+ {
277
+ if( Session::lookupSession(*i)->isLoggedOn() )
278
+ return true;
279
+ }
280
+ return false;
281
+ }
282
+
283
+ THREAD_PROC Initiator::startThread( void* p )
284
+ {
285
+ Initiator * pInitiator = static_cast < Initiator* > ( p );
286
+ pInitiator->onStart();
287
+ return 0;
288
+ }
289
+ }
@@ -0,0 +1,149 @@
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 "MessageStore.h"
31
+ #include "Log.h"
32
+ #include "Responder.h"
33
+ #include "SessionSettings.h"
34
+ #include "Exceptions.h"
35
+ #include "Mutex.h"
36
+ #include "Session.h"
37
+ #include <set>
38
+ #include <map>
39
+ #include <string>
40
+
41
+ namespace FIX
42
+ {
43
+ class Client;
44
+
45
+ /**
46
+ * Base for classes which act as an initiator for establishing connections.
47
+ *
48
+ * Most users will not need to implement one of these. The default
49
+ * SocketInitiator implementation will be used in most cases.
50
+ */
51
+ class Initiator
52
+ {
53
+ public:
54
+ Initiator( Application&, MessageStoreFactory&,
55
+ const SessionSettings& ) throw( ConfigError );
56
+ Initiator( Application&, MessageStoreFactory&,
57
+ const SessionSettings&, LogFactory& ) throw( ConfigError );
58
+
59
+ virtual ~Initiator();
60
+
61
+ /// Start initiator.
62
+ void start() throw ( ConfigError, RuntimeError );
63
+ /// Block on the initiator
64
+ void block() throw ( ConfigError, RuntimeError );
65
+ /// Poll the initiator
66
+ bool poll( double timeout = 0.0 ) throw ( ConfigError, RuntimeError );
67
+
68
+ /// Stop initiator.
69
+ void stop( bool force = false );
70
+
71
+ /// Check to see if any sessions are currently logged on
72
+ bool isLoggedOn();
73
+
74
+ Session* getSession( const SessionID& sessionID, Responder& );
75
+
76
+ const std::set<SessionID>& getSessions() const { return m_sessionIDs; }
77
+ Session* getSession( const SessionID& sessionID ) const;
78
+ const Dictionary* const getSessionSettings( const SessionID& sessionID ) const;
79
+
80
+ bool has( const SessionID& id )
81
+ { return m_sessions.find( id ) != m_sessions.end(); }
82
+
83
+ bool isStopped() { return m_stop; }
84
+
85
+ public:
86
+ Application& getApplication() { return m_application; }
87
+ MessageStoreFactory& getMessageStoreFactory()
88
+ { return m_messageStoreFactory; }
89
+
90
+ Log* getLog()
91
+ {
92
+ if( m_pLog ) return m_pLog;
93
+ return &m_nullLog;
94
+ }
95
+
96
+ protected:
97
+ void setPending( const SessionID& );
98
+ void setConnected( const SessionID& );
99
+ void setDisconnected( const SessionID& );
100
+
101
+ bool isPending( const SessionID& );
102
+ bool isConnected( const SessionID& );
103
+ bool isDisconnected( const SessionID& );
104
+ void connect();
105
+
106
+ private:
107
+ void initialize() throw ( ConfigError );
108
+
109
+ /// Implemented to configure acceptor
110
+ virtual void onConfigure( const SessionSettings& ) throw ( ConfigError ) {};
111
+ /// Implemented to initialize initiator
112
+ virtual void onInitialize( const SessionSettings& ) throw ( RuntimeError ) {};
113
+ /// Implemented to start connecting to targets.
114
+ virtual void onStart() = 0;
115
+ /// Implemented to connect and poll for events.
116
+ virtual bool onPoll( double timeout ) = 0;
117
+ /// Implemented to stop a running initiator.
118
+ virtual void onStop() = 0;
119
+ /// Implemented to connect a session to its target.
120
+ virtual void doConnect( const SessionID&, const Dictionary& ) = 0;
121
+
122
+ static THREAD_PROC startThread( void* p );
123
+
124
+ typedef std::set < SessionID > SessionIDs;
125
+ typedef std::map < SessionID, int > SessionState;
126
+ typedef std::map < SessionID, Session* > Sessions;
127
+
128
+ Sessions m_sessions;
129
+ SessionIDs m_sessionIDs;
130
+ SessionIDs m_pending;
131
+ SessionIDs m_connected;
132
+ SessionIDs m_disconnected;
133
+ SessionState m_sessionState;
134
+
135
+ thread_id m_threadid;
136
+ Application& m_application;
137
+ MessageStoreFactory& m_messageStoreFactory;
138
+ SessionSettings m_settings;
139
+ LogFactory* m_pLogFactory;
140
+ Log* m_pLog;
141
+ NullLog m_nullLog;
142
+ bool m_firstPoll;
143
+ bool m_stop;
144
+ Mutex m_mutex;
145
+ };
146
+ /*! @} */
147
+ }
148
+
149
+ #endif // FIX_INITIATOR_H
@@ -0,0 +1,77 @@
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
+ {
30
+ Mutex ScreenLog::s_mutex;
31
+
32
+ Log* ScreenLogFactory::create()
33
+ {
34
+ bool incoming, outgoing, event;
35
+ init( m_settings.get(), incoming, outgoing, event );
36
+ return new ScreenLog( incoming, outgoing, event );
37
+ }
38
+
39
+ Log* ScreenLogFactory::create( const SessionID& sessionID )
40
+ {
41
+ Dictionary settings;
42
+ if( m_settings.has(sessionID) )
43
+ settings = m_settings.get( sessionID );
44
+
45
+ bool incoming, outgoing, event;
46
+ init( settings, incoming, outgoing, event );
47
+ return new ScreenLog( sessionID, incoming, outgoing, event );
48
+ }
49
+
50
+ void ScreenLogFactory::init( const Dictionary& settings, bool& incoming, bool& outgoing, bool& event )
51
+ {
52
+ if( m_useSettings )
53
+ {
54
+ incoming = true;
55
+ outgoing = true;
56
+ event = true;
57
+
58
+ if( settings.has(SCREEN_LOG_SHOW_INCOMING) )
59
+ incoming = settings.getBool(SCREEN_LOG_SHOW_INCOMING);
60
+ if( settings.has(SCREEN_LOG_SHOW_OUTGOING) )
61
+ outgoing = settings.getBool(SCREEN_LOG_SHOW_OUTGOING);
62
+ if( settings.has(SCREEN_LOG_SHOW_EVENTS) )
63
+ event = settings.getBool(SCREEN_LOG_SHOW_EVENTS);
64
+ }
65
+ else
66
+ {
67
+ incoming = m_incoming;
68
+ outgoing = m_outgoing;
69
+ event = m_event;
70
+ }
71
+ }
72
+
73
+ void ScreenLogFactory::destroy( Log* pLog )
74
+ {
75
+ delete pLog;
76
+ }
77
+ } //namespace FIX
@@ -0,0 +1,179 @@
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_LOG_H
23
+ #define FIX_LOG_H
24
+
25
+ #ifdef _MSC_VER
26
+ #pragma warning( disable : 4503 4355 4786 4290 )
27
+ #endif
28
+
29
+ #include "Message.h"
30
+ #include "Mutex.h"
31
+ #include "SessionSettings.h"
32
+ #include <map>
33
+ #include <vector>
34
+
35
+ namespace FIX
36
+ {
37
+ class Log;
38
+
39
+ /**
40
+ * This interface must be implemented to create a Log.
41
+ */
42
+ class LogFactory
43
+ {
44
+ public:
45
+ virtual ~LogFactory() {}
46
+ virtual Log* create() = 0;
47
+ virtual Log* create( const SessionID& ) = 0;
48
+ virtual void destroy( Log* ) = 0;
49
+ };
50
+
51
+ /**
52
+ * Creates a screen based implementation of Log.
53
+ *
54
+ * This displays all log events onto the standard output
55
+ */
56
+ class ScreenLogFactory : public LogFactory
57
+ {
58
+ public:
59
+ ScreenLogFactory( const SessionSettings& settings )
60
+ : m_useSettings( true ), m_settings( settings ) {};
61
+ ScreenLogFactory( bool incoming, bool outgoing, bool event )
62
+ : m_incoming( incoming ), m_outgoing( outgoing ), m_event( event ), m_useSettings( false ) {}
63
+
64
+ Log* create();
65
+ Log* create( const SessionID& );
66
+ void destroy( Log* log );
67
+
68
+ private:
69
+ void init( const Dictionary& settings, bool& incoming, bool& outgoing, bool& event );
70
+
71
+ bool m_incoming;
72
+ bool m_outgoing;
73
+ bool m_event;
74
+ bool m_useSettings;
75
+ SessionSettings m_settings;
76
+ };
77
+
78
+ /**
79
+ * This interface must be implemented to log messages and events
80
+ */
81
+ class Log
82
+ {
83
+ public:
84
+ virtual ~Log() {}
85
+
86
+ virtual void clear() = 0;
87
+ virtual void backup() = 0;
88
+ virtual void onIncoming( const std::string& ) = 0;
89
+ virtual void onOutgoing( const std::string& ) = 0;
90
+ virtual void onEvent( const std::string& ) = 0;
91
+ };
92
+ /*! @} */
93
+
94
+ /**
95
+ * Null implementation of Log
96
+ *
97
+ * This is only for internal use. Used when no log factory is
98
+ * passed to the initiator or acceptor.
99
+ */
100
+ class NullLog : public Log
101
+ {
102
+ public:
103
+ void clear() {}
104
+ void backup() {}
105
+ void onIncoming( const std::string& ) {}
106
+ void onOutgoing( const std::string& ) {}
107
+ void onEvent( const std::string& ) {}
108
+ };
109
+
110
+ /**
111
+ * Screen based implementation of Log.
112
+ *
113
+ * This will display all log information onto the standard output
114
+ */
115
+ class ScreenLog : public Log
116
+ {
117
+ public:
118
+ ScreenLog( bool incoming, bool outgoing, bool event )
119
+ : m_prefix( "GLOBAL" ),
120
+ m_incoming( incoming ), m_outgoing( outgoing ), m_event( event ), m_millisecondsInTimeStamp( true ) {}
121
+
122
+ ScreenLog( const SessionID& sessionID,
123
+ bool incoming, bool outgoing, bool event )
124
+ : m_prefix( sessionID.toString() ),
125
+ m_incoming( incoming ), m_outgoing( outgoing ), m_event( event ), m_millisecondsInTimeStamp( true ) {}
126
+
127
+ void clear() {}
128
+ void backup() {}
129
+
130
+ void onIncoming( const std::string& value )
131
+ {
132
+ if ( !m_incoming ) return ;
133
+ Locker l( s_mutex );
134
+ m_time.setCurrent();
135
+ std::cout << "<" << UtcTimeStampConvertor::convert(m_time, m_millisecondsInTimeStamp)
136
+ << ", " << m_prefix
137
+ << ", " << "incoming>" << std::endl
138
+ << " (" << value << ")" << std::endl;
139
+ }
140
+
141
+ void onOutgoing( const std::string& value )
142
+ {
143
+ if ( !m_outgoing ) return ;
144
+ Locker l( s_mutex );
145
+ m_time.setCurrent();
146
+ std::cout << "<" << UtcTimeStampConvertor::convert(m_time, m_millisecondsInTimeStamp)
147
+ << ", " << m_prefix
148
+ << ", " << "outgoing>" << std::endl
149
+ << " (" << value << ")" << std::endl;
150
+ }
151
+
152
+ void onEvent( const std::string& value )
153
+ {
154
+ if ( !m_event ) return ;
155
+ Locker l( s_mutex );
156
+ m_time.setCurrent();
157
+ std::cout << "<" << UtcTimeStampConvertor::convert(m_time, m_millisecondsInTimeStamp)
158
+ << ", " << m_prefix
159
+ << ", " << "event>" << std::endl
160
+ << " (" << value << ")" << std::endl;
161
+ }
162
+
163
+ bool getMillisecondsInTimeStamp() const
164
+ { return m_millisecondsInTimeStamp; }
165
+ void setMillisecondsInTimeStamp ( bool value )
166
+ { m_millisecondsInTimeStamp = value; }
167
+
168
+ private:
169
+ std::string m_prefix;
170
+ UtcTimeStamp m_time;
171
+ bool m_incoming;
172
+ bool m_outgoing;
173
+ bool m_event;
174
+ static Mutex s_mutex;
175
+ bool m_millisecondsInTimeStamp;
176
+ };
177
+ }
178
+
179
+ #endif //FIX_LOG_H