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.
- 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
|
@@ -0,0 +1,156 @@
|
|
|
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_MESSAGESORTERS_H
|
|
23
|
+
#define FIX_MESSAGESORTERS_H
|
|
24
|
+
|
|
25
|
+
#ifdef _MSC_VER
|
|
26
|
+
#pragma warning( disable : 4503 4355 4786 4290 )
|
|
27
|
+
#endif
|
|
28
|
+
|
|
29
|
+
#include "FieldNumbers.h"
|
|
30
|
+
#include "SharedArray.h"
|
|
31
|
+
#include <stdarg.h>
|
|
32
|
+
#include <functional>
|
|
33
|
+
#include <map>
|
|
34
|
+
|
|
35
|
+
namespace FIX
|
|
36
|
+
{
|
|
37
|
+
/// Sorts fields in correct header order.
|
|
38
|
+
struct header_order
|
|
39
|
+
{
|
|
40
|
+
static bool compare( const int x, const int y )
|
|
41
|
+
{
|
|
42
|
+
int orderedX = getOrderedPosition( x );
|
|
43
|
+
int orderedY = getOrderedPosition( y );
|
|
44
|
+
|
|
45
|
+
if ( orderedX && orderedY )
|
|
46
|
+
return orderedX < orderedY;
|
|
47
|
+
else
|
|
48
|
+
if ( orderedX )
|
|
49
|
+
return true;
|
|
50
|
+
else
|
|
51
|
+
if ( orderedY )
|
|
52
|
+
return false;
|
|
53
|
+
else
|
|
54
|
+
return x < y;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
static int getOrderedPosition( const int field )
|
|
58
|
+
{
|
|
59
|
+
switch ( field )
|
|
60
|
+
{
|
|
61
|
+
case FIELD::BeginString: return 1;
|
|
62
|
+
case FIELD::BodyLength: return 2;
|
|
63
|
+
case FIELD::MsgType: return 3;
|
|
64
|
+
default: return 0;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
/// Sorts fields in correct trailer order.
|
|
70
|
+
struct trailer_order
|
|
71
|
+
{
|
|
72
|
+
static bool compare( const int x, const int y )
|
|
73
|
+
{
|
|
74
|
+
if ( x == FIELD::CheckSum ) return false;
|
|
75
|
+
else
|
|
76
|
+
if ( y == FIELD::CheckSum ) return true;
|
|
77
|
+
else return x < y;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
/// Sorts fields in correct group order
|
|
82
|
+
struct group_order
|
|
83
|
+
{
|
|
84
|
+
static bool compare( const int x, const int y, int* order, int largest )
|
|
85
|
+
{
|
|
86
|
+
if ( x <= largest && y <= largest )
|
|
87
|
+
{
|
|
88
|
+
int iX = order[ x ];
|
|
89
|
+
int iY = order[ y ];
|
|
90
|
+
if ( iX == 0 && iY == 0 )
|
|
91
|
+
return x < y;
|
|
92
|
+
else if ( iX == 0 )
|
|
93
|
+
return false;
|
|
94
|
+
else if ( iY == 0 )
|
|
95
|
+
return true;
|
|
96
|
+
else
|
|
97
|
+
return iX < iY;
|
|
98
|
+
}
|
|
99
|
+
else if ( x <= largest ) return true;
|
|
100
|
+
else if ( y <= largest ) return false;
|
|
101
|
+
else return x < y;
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
typedef std::less < int > normal_order;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Sorts fields in header, normal, or trailer order.
|
|
109
|
+
*
|
|
110
|
+
* Used as a dynamic sorter to create Header, Trailer, and Message
|
|
111
|
+
* FieldMaps while maintaining the same base type.
|
|
112
|
+
*/
|
|
113
|
+
struct message_order
|
|
114
|
+
{
|
|
115
|
+
public:
|
|
116
|
+
enum cmp_mode { header, trailer, normal, group };
|
|
117
|
+
|
|
118
|
+
message_order( cmp_mode mode = normal )
|
|
119
|
+
: m_mode( mode ), m_delim( 0 ), m_largest( 0 ) {}
|
|
120
|
+
message_order( int first, ... );
|
|
121
|
+
message_order( const int order[] );
|
|
122
|
+
message_order( const message_order& copy )
|
|
123
|
+
{ *this = copy; }
|
|
124
|
+
|
|
125
|
+
bool operator() ( const int x, const int y ) const
|
|
126
|
+
{
|
|
127
|
+
switch ( m_mode )
|
|
128
|
+
{
|
|
129
|
+
case header:
|
|
130
|
+
return header_order::compare( x, y );
|
|
131
|
+
case trailer:
|
|
132
|
+
return trailer_order::compare( x, y );
|
|
133
|
+
case group:
|
|
134
|
+
return group_order::compare( x, y, m_groupOrder, m_largest );
|
|
135
|
+
case normal: default:
|
|
136
|
+
return x < y;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
message_order& operator=( const message_order& rhs );
|
|
141
|
+
|
|
142
|
+
operator bool() const
|
|
143
|
+
{ return !m_groupOrder.empty(); }
|
|
144
|
+
|
|
145
|
+
private:
|
|
146
|
+
void setOrder( int size, const int order[] );
|
|
147
|
+
|
|
148
|
+
cmp_mode m_mode;
|
|
149
|
+
int m_delim;
|
|
150
|
+
shared_array<int> m_groupOrder;
|
|
151
|
+
int m_largest;
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
#endif //FIX_MESSAGESORTERS_H
|
|
156
|
+
|
|
@@ -0,0 +1,146 @@
|
|
|
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 "MessageStore.h"
|
|
27
|
+
|
|
28
|
+
namespace FIX
|
|
29
|
+
{
|
|
30
|
+
MessageStore* MemoryStoreFactory::create( const SessionID& )
|
|
31
|
+
{
|
|
32
|
+
return new MemoryStore();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
void MemoryStoreFactory::destroy( MessageStore* pStore )
|
|
36
|
+
{
|
|
37
|
+
delete pStore;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
bool MemoryStore::set( int msgSeqNum, const std::string& msg )
|
|
41
|
+
throw( IOException )
|
|
42
|
+
{
|
|
43
|
+
m_messages[ msgSeqNum ] = msg;
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
void MemoryStore::get( int begin, int end,
|
|
48
|
+
std::vector < std::string > & messages ) const
|
|
49
|
+
throw( IOException )
|
|
50
|
+
{
|
|
51
|
+
messages.clear();
|
|
52
|
+
Messages::const_iterator find = m_messages.find( begin );
|
|
53
|
+
for ( ; find != m_messages.end() && find->first <= end; ++find )
|
|
54
|
+
messages.push_back( find->second );
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
MessageStore* MessageStoreFactoryExceptionWrapper::create( const SessionID& sessionID, bool& threw, ConfigError& ex )
|
|
58
|
+
{
|
|
59
|
+
threw = false;
|
|
60
|
+
try { return m_pFactory->create( sessionID ); }
|
|
61
|
+
catch ( ConfigError & e ) { threw = true; ex = e; return 0; }
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
void MessageStoreFactoryExceptionWrapper::destroy( MessageStore* pStore )
|
|
65
|
+
{
|
|
66
|
+
m_pFactory->destroy( pStore );
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
bool MessageStoreExceptionWrapper::set( int num, const std::string& msg, bool& threw, IOException& ex )
|
|
70
|
+
{
|
|
71
|
+
threw = false;
|
|
72
|
+
try { return m_pStore->set( num, msg ); }
|
|
73
|
+
catch ( IOException & e ) { threw = true; ex = e; return false; }
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
void MessageStoreExceptionWrapper::get( int begin, int end, std::vector < std::string > & msgs, bool& threw, IOException& ex ) const
|
|
77
|
+
{
|
|
78
|
+
threw = false;
|
|
79
|
+
try { m_pStore->get( begin, end, msgs ); }
|
|
80
|
+
catch ( IOException & e ) { threw = true; ex = e; }
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
int MessageStoreExceptionWrapper::getNextSenderMsgSeqNum( bool& threw, IOException& ex ) const
|
|
84
|
+
{
|
|
85
|
+
threw = false;
|
|
86
|
+
try { return m_pStore->getNextSenderMsgSeqNum(); }
|
|
87
|
+
catch ( IOException & e ) { threw = true; ex = e; return 0; }
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
int MessageStoreExceptionWrapper::getNextTargetMsgSeqNum( bool& threw, IOException& ex ) const
|
|
91
|
+
{
|
|
92
|
+
threw = false;
|
|
93
|
+
try { return m_pStore->getNextTargetMsgSeqNum(); }
|
|
94
|
+
catch ( IOException & e ) { threw = true; ex = e; return 0; }
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
void MessageStoreExceptionWrapper::setNextSenderMsgSeqNum( int num, bool& threw, IOException& ex )
|
|
98
|
+
{
|
|
99
|
+
threw = false;
|
|
100
|
+
try { m_pStore->setNextSenderMsgSeqNum( num ); }
|
|
101
|
+
catch ( IOException & e ) { threw = true; ex = e; }
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
void MessageStoreExceptionWrapper::setNextTargetMsgSeqNum( int num, bool& threw, IOException& ex )
|
|
105
|
+
{
|
|
106
|
+
threw = false;
|
|
107
|
+
try { m_pStore->setNextTargetMsgSeqNum( num ); }
|
|
108
|
+
catch ( IOException & e ) { threw = true; ex = e; }
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
void MessageStoreExceptionWrapper::incrNextSenderMsgSeqNum( bool& threw, IOException& ex )
|
|
112
|
+
{
|
|
113
|
+
threw = false;
|
|
114
|
+
try { m_pStore->incrNextSenderMsgSeqNum(); }
|
|
115
|
+
catch ( IOException & e ) { threw = true; ex = e; }
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
void MessageStoreExceptionWrapper::incrNextTargetMsgSeqNum( bool& threw, IOException& ex )
|
|
119
|
+
{
|
|
120
|
+
threw = false;
|
|
121
|
+
try { m_pStore->incrNextTargetMsgSeqNum(); }
|
|
122
|
+
catch ( IOException & e ) { threw = true; ex = e; }
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
UtcTimeStamp MessageStoreExceptionWrapper::getCreationTime( bool& threw, IOException& ex )
|
|
126
|
+
{
|
|
127
|
+
threw = false;
|
|
128
|
+
try { return m_pStore->getCreationTime(); }
|
|
129
|
+
catch ( IOException & e ) { threw = true; ex = e; return UtcTimeStamp(); }
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
void MessageStoreExceptionWrapper::reset( bool& threw, IOException& ex )
|
|
133
|
+
{
|
|
134
|
+
threw = false;
|
|
135
|
+
try { m_pStore->reset(); }
|
|
136
|
+
catch ( IOException & e ) { threw = true; ex = e; }
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
void MessageStoreExceptionWrapper::refresh( bool& threw, IOException& ex )
|
|
140
|
+
{
|
|
141
|
+
threw = false;
|
|
142
|
+
try { m_pStore->refresh(); }
|
|
143
|
+
catch ( IOException & e ) { threw = true; ex = e; }
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
} //namespace FIX
|
|
@@ -0,0 +1,174 @@
|
|
|
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_MESSAGESTORE_H
|
|
23
|
+
#define FIX_MESSAGESTORE_H
|
|
24
|
+
|
|
25
|
+
#ifdef _MSC_VER
|
|
26
|
+
#pragma warning( disable : 4503 4355 4786 4290 )
|
|
27
|
+
#endif
|
|
28
|
+
|
|
29
|
+
#include "Message.h"
|
|
30
|
+
#include <map>
|
|
31
|
+
#include <vector>
|
|
32
|
+
#include <string>
|
|
33
|
+
|
|
34
|
+
namespace FIX
|
|
35
|
+
{
|
|
36
|
+
class MessageStore;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* This interface must be implemented to create a MessageStore.
|
|
40
|
+
*/
|
|
41
|
+
class MessageStoreFactory
|
|
42
|
+
{
|
|
43
|
+
public:
|
|
44
|
+
virtual ~MessageStoreFactory() {}
|
|
45
|
+
virtual MessageStore* create( const SessionID& ) = 0;
|
|
46
|
+
virtual void destroy( MessageStore* ) = 0;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Creates a memory based implementation of MessageStore.
|
|
51
|
+
*
|
|
52
|
+
* This will lose all data on process termination. This class should only
|
|
53
|
+
* be used for test applications, never in production.
|
|
54
|
+
*/
|
|
55
|
+
class MemoryStoreFactory : public MessageStoreFactory
|
|
56
|
+
{
|
|
57
|
+
public:
|
|
58
|
+
MessageStore* create( const SessionID& );
|
|
59
|
+
void destroy( MessageStore* );
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* This interface must be implemented to store and retrieve messages and
|
|
64
|
+
* sequence numbers.
|
|
65
|
+
*/
|
|
66
|
+
class MessageStore
|
|
67
|
+
{
|
|
68
|
+
public:
|
|
69
|
+
virtual ~MessageStore() {}
|
|
70
|
+
|
|
71
|
+
virtual bool set( int, const std::string& )
|
|
72
|
+
throw ( IOException ) = 0;
|
|
73
|
+
virtual void get( int, int, std::vector < std::string > & ) const
|
|
74
|
+
throw ( IOException ) = 0;
|
|
75
|
+
|
|
76
|
+
virtual int getNextSenderMsgSeqNum() const throw ( IOException ) = 0;
|
|
77
|
+
virtual int getNextTargetMsgSeqNum() const throw ( IOException ) = 0;
|
|
78
|
+
virtual void setNextSenderMsgSeqNum( int ) throw ( IOException ) = 0;
|
|
79
|
+
virtual void setNextTargetMsgSeqNum( int ) throw ( IOException ) = 0;
|
|
80
|
+
virtual void incrNextSenderMsgSeqNum() throw ( IOException ) = 0;
|
|
81
|
+
virtual void incrNextTargetMsgSeqNum() throw ( IOException ) = 0;
|
|
82
|
+
|
|
83
|
+
virtual UtcTimeStamp getCreationTime() const throw ( IOException ) = 0;
|
|
84
|
+
|
|
85
|
+
virtual void reset() throw ( IOException ) = 0;
|
|
86
|
+
virtual void refresh() throw ( IOException ) = 0;
|
|
87
|
+
};
|
|
88
|
+
/*! @} */
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Memory based implementation of MessageStore.
|
|
92
|
+
*
|
|
93
|
+
* This will lose all data on process terminition. This class should only
|
|
94
|
+
* be used for test applications, never in production.
|
|
95
|
+
*/
|
|
96
|
+
class MemoryStore : public MessageStore
|
|
97
|
+
{
|
|
98
|
+
public:
|
|
99
|
+
MemoryStore() : m_nextSenderMsgSeqNum( 1 ), m_nextTargetMsgSeqNum( 1 ) {}
|
|
100
|
+
|
|
101
|
+
bool set( int, const std::string& ) throw ( IOException );
|
|
102
|
+
void get( int, int, std::vector < std::string > & ) const throw ( IOException );
|
|
103
|
+
|
|
104
|
+
int getNextSenderMsgSeqNum() const throw ( IOException )
|
|
105
|
+
{ return m_nextSenderMsgSeqNum; }
|
|
106
|
+
int getNextTargetMsgSeqNum() const throw ( IOException )
|
|
107
|
+
{ return m_nextTargetMsgSeqNum; }
|
|
108
|
+
void setNextSenderMsgSeqNum( int value ) throw ( IOException )
|
|
109
|
+
{ m_nextSenderMsgSeqNum = value; }
|
|
110
|
+
void setNextTargetMsgSeqNum( int value ) throw ( IOException )
|
|
111
|
+
{ m_nextTargetMsgSeqNum = value; }
|
|
112
|
+
void incrNextSenderMsgSeqNum() throw ( IOException )
|
|
113
|
+
{ ++m_nextSenderMsgSeqNum; }
|
|
114
|
+
void incrNextTargetMsgSeqNum() throw ( IOException )
|
|
115
|
+
{ ++m_nextTargetMsgSeqNum; }
|
|
116
|
+
|
|
117
|
+
void setCreationTime( const UtcTimeStamp& creationTime ) throw ( IOException )
|
|
118
|
+
{ m_creationTime = creationTime; }
|
|
119
|
+
UtcTimeStamp getCreationTime() const throw ( IOException )
|
|
120
|
+
{ return m_creationTime; }
|
|
121
|
+
|
|
122
|
+
void reset() throw ( IOException )
|
|
123
|
+
{
|
|
124
|
+
m_nextSenderMsgSeqNum = 1; m_nextTargetMsgSeqNum = 1;
|
|
125
|
+
m_messages.clear(); m_creationTime.setCurrent();
|
|
126
|
+
}
|
|
127
|
+
void refresh() throw ( IOException ) {}
|
|
128
|
+
|
|
129
|
+
private:
|
|
130
|
+
typedef std::map < int, std::string > Messages;
|
|
131
|
+
|
|
132
|
+
Messages m_messages;
|
|
133
|
+
int m_nextSenderMsgSeqNum;
|
|
134
|
+
int m_nextTargetMsgSeqNum;
|
|
135
|
+
UtcTimeStamp m_creationTime;
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
class MessageStoreFactoryExceptionWrapper
|
|
139
|
+
{
|
|
140
|
+
private:
|
|
141
|
+
MessageStoreFactory* m_pFactory;
|
|
142
|
+
public:
|
|
143
|
+
MessageStoreFactoryExceptionWrapper( MessageStoreFactory* pFactory )
|
|
144
|
+
: m_pFactory( pFactory ) {}
|
|
145
|
+
|
|
146
|
+
MessageStore* create( const SessionID&, bool&, ConfigError& );
|
|
147
|
+
void destroy( MessageStore* );
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
class MessageStoreExceptionWrapper
|
|
151
|
+
{
|
|
152
|
+
private:
|
|
153
|
+
MessageStore* m_pStore;
|
|
154
|
+
public:
|
|
155
|
+
MessageStoreExceptionWrapper( MessageStore* pStore ) : m_pStore( pStore ) {}
|
|
156
|
+
~MessageStoreExceptionWrapper() { delete m_pStore; }
|
|
157
|
+
|
|
158
|
+
bool set( int, const std::string&, bool&, IOException& );
|
|
159
|
+
void get( int, int, std::vector < std::string > &, bool&, IOException& ) const;
|
|
160
|
+
int getNextSenderMsgSeqNum( bool&, IOException& ) const;
|
|
161
|
+
int getNextTargetMsgSeqNum( bool&, IOException& ) const;
|
|
162
|
+
void setNextSenderMsgSeqNum( int, bool&, IOException& );
|
|
163
|
+
void setNextTargetMsgSeqNum( int, bool&, IOException& );
|
|
164
|
+
void incrNextSenderMsgSeqNum( bool&, IOException& );
|
|
165
|
+
void incrNextTargetMsgSeqNum( bool&, IOException& );
|
|
166
|
+
|
|
167
|
+
UtcTimeStamp getCreationTime( bool&, IOException& );
|
|
168
|
+
|
|
169
|
+
void reset( bool&, IOException& );
|
|
170
|
+
void refresh( bool&, IOException& );
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
#endif //FIX_MESSAGESTORE_H
|
|
@@ -0,0 +1,131 @@
|
|
|
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_MUTEX_H
|
|
23
|
+
#define FIX_MUTEX_H
|
|
24
|
+
|
|
25
|
+
#include "Utility.h"
|
|
26
|
+
|
|
27
|
+
namespace FIX
|
|
28
|
+
{
|
|
29
|
+
/// Portable implementation of a mutex.
|
|
30
|
+
class Mutex
|
|
31
|
+
{
|
|
32
|
+
public:
|
|
33
|
+
Mutex()
|
|
34
|
+
{
|
|
35
|
+
#ifdef _MSC_VER
|
|
36
|
+
InitializeCriticalSection( &m_mutex );
|
|
37
|
+
#else
|
|
38
|
+
m_count = 0;
|
|
39
|
+
m_threadID = 0;
|
|
40
|
+
//pthread_mutexattr_t attr;
|
|
41
|
+
//pthread_mutexattr_init(&attr);
|
|
42
|
+
//pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
|
|
43
|
+
//pthread_mutex_init(&m_mutex, &attr);
|
|
44
|
+
pthread_mutex_init( &m_mutex, 0 );
|
|
45
|
+
#endif
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
~Mutex()
|
|
49
|
+
{
|
|
50
|
+
#ifdef _MSC_VER
|
|
51
|
+
DeleteCriticalSection( &m_mutex );
|
|
52
|
+
#else
|
|
53
|
+
pthread_mutex_destroy( &m_mutex );
|
|
54
|
+
#endif
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
void lock()
|
|
58
|
+
{
|
|
59
|
+
#ifdef _MSC_VER
|
|
60
|
+
EnterCriticalSection( &m_mutex );
|
|
61
|
+
#else
|
|
62
|
+
if ( m_count && m_threadID == pthread_self() )
|
|
63
|
+
{ ++m_count; return ; }
|
|
64
|
+
pthread_mutex_lock( &m_mutex );
|
|
65
|
+
++m_count;
|
|
66
|
+
m_threadID = pthread_self();
|
|
67
|
+
#endif
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
void unlock()
|
|
71
|
+
{
|
|
72
|
+
#ifdef _MSC_VER
|
|
73
|
+
LeaveCriticalSection( &m_mutex );
|
|
74
|
+
#else
|
|
75
|
+
if ( m_count > 1 )
|
|
76
|
+
{ m_count--; return ; }
|
|
77
|
+
--m_count;
|
|
78
|
+
m_threadID = 0;
|
|
79
|
+
pthread_mutex_unlock( &m_mutex );
|
|
80
|
+
#endif
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
private:
|
|
84
|
+
|
|
85
|
+
#ifdef _MSC_VER
|
|
86
|
+
CRITICAL_SECTION m_mutex;
|
|
87
|
+
#else
|
|
88
|
+
pthread_mutex_t m_mutex;
|
|
89
|
+
pthread_t m_threadID;
|
|
90
|
+
int m_count;
|
|
91
|
+
#endif
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
/// Locks/Unlocks a mutex using RAII.
|
|
95
|
+
class Locker
|
|
96
|
+
{
|
|
97
|
+
public:
|
|
98
|
+
Locker( Mutex& mutex )
|
|
99
|
+
: m_mutex( mutex )
|
|
100
|
+
{
|
|
101
|
+
m_mutex.lock();
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
~Locker()
|
|
105
|
+
{
|
|
106
|
+
m_mutex.unlock();
|
|
107
|
+
}
|
|
108
|
+
private:
|
|
109
|
+
Mutex& m_mutex;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
/// Does the opposite of the Locker to ensure mutex ends up in a locked state.
|
|
113
|
+
class ReverseLocker
|
|
114
|
+
{
|
|
115
|
+
public:
|
|
116
|
+
ReverseLocker( Mutex& mutex )
|
|
117
|
+
: m_mutex( mutex )
|
|
118
|
+
{
|
|
119
|
+
m_mutex.unlock();
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
~ReverseLocker()
|
|
123
|
+
{
|
|
124
|
+
m_mutex.lock();
|
|
125
|
+
}
|
|
126
|
+
private:
|
|
127
|
+
Mutex& m_mutex;
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
#endif
|