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