forked from quickfix/quickfix
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMessageStore.cpp
More file actions
146 lines (126 loc) · 4.24 KB
/
Copy pathMessageStore.cpp
File metadata and controls
146 lines (126 loc) · 4.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/****************************************************************************
** Copyright (c) 2001-2014
**
** This file is part of the QuickFIX FIX Engine
**
** This file may be distributed under the terms of the quickfixengine.org
** license as defined by quickfixengine.org and appearing in the file
** LICENSE included in the packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.quickfixengine.org/LICENSE for licensing information.
**
** Contact ask@quickfixengine.org if any conditions of this licensing are
** not clear to you.
**
****************************************************************************/
#ifdef _MSC_VER
#include "stdafx.h"
#else
#include "config.h"
#endif
#include "MessageStore.h"
namespace FIX
{
MessageStore* MemoryStoreFactory::create( const SessionID& )
{
return new MemoryStore();
}
void MemoryStoreFactory::destroy( MessageStore* pStore )
{
delete pStore;
}
bool MemoryStore::set( int msgSeqNum, const std::string& msg )
EXCEPT ( IOException )
{
m_messages[ msgSeqNum ] = msg;
return true;
}
void MemoryStore::get( int begin, int end,
std::vector < std::string > & messages ) const
EXCEPT ( IOException )
{
messages.clear();
Messages::const_iterator find = m_messages.find( begin );
for ( ; find != m_messages.end() && find->first <= end; ++find )
messages.push_back( find->second );
}
MessageStore* MessageStoreFactoryExceptionWrapper::create( const SessionID& sessionID, bool& threw, ConfigError& ex )
{
threw = false;
try { return m_pFactory->create( sessionID ); }
catch ( ConfigError & e ) { threw = true; ex = e; return 0; }
}
void MessageStoreFactoryExceptionWrapper::destroy( MessageStore* pStore )
{
m_pFactory->destroy( pStore );
}
bool MessageStoreExceptionWrapper::set( int num, const std::string& msg, bool& threw, IOException& ex )
{
threw = false;
try { return m_pStore->set( num, msg ); }
catch ( IOException & e ) { threw = true; ex = e; return false; }
}
void MessageStoreExceptionWrapper::get( int begin, int end, std::vector < std::string > & msgs, bool& threw, IOException& ex ) const
{
threw = false;
try { m_pStore->get( begin, end, msgs ); }
catch ( IOException & e ) { threw = true; ex = e; }
}
int MessageStoreExceptionWrapper::getNextSenderMsgSeqNum( bool& threw, IOException& ex ) const
{
threw = false;
try { return m_pStore->getNextSenderMsgSeqNum(); }
catch ( IOException & e ) { threw = true; ex = e; return 0; }
}
int MessageStoreExceptionWrapper::getNextTargetMsgSeqNum( bool& threw, IOException& ex ) const
{
threw = false;
try { return m_pStore->getNextTargetMsgSeqNum(); }
catch ( IOException & e ) { threw = true; ex = e; return 0; }
}
void MessageStoreExceptionWrapper::setNextSenderMsgSeqNum( int num, bool& threw, IOException& ex )
{
threw = false;
try { m_pStore->setNextSenderMsgSeqNum( num ); }
catch ( IOException & e ) { threw = true; ex = e; }
}
void MessageStoreExceptionWrapper::setNextTargetMsgSeqNum( int num, bool& threw, IOException& ex )
{
threw = false;
try { m_pStore->setNextTargetMsgSeqNum( num ); }
catch ( IOException & e ) { threw = true; ex = e; }
}
void MessageStoreExceptionWrapper::incrNextSenderMsgSeqNum( bool& threw, IOException& ex )
{
threw = false;
try { m_pStore->incrNextSenderMsgSeqNum(); }
catch ( IOException & e ) { threw = true; ex = e; }
}
void MessageStoreExceptionWrapper::incrNextTargetMsgSeqNum( bool& threw, IOException& ex )
{
threw = false;
try { m_pStore->incrNextTargetMsgSeqNum(); }
catch ( IOException & e ) { threw = true; ex = e; }
}
UtcTimeStamp MessageStoreExceptionWrapper::getCreationTime( bool& threw, IOException& ex )
{
threw = false;
try { return m_pStore->getCreationTime(); }
catch ( IOException & e ) { threw = true; ex = e; return UtcTimeStamp(); }
}
void MessageStoreExceptionWrapper::reset( bool& threw, IOException& ex )
{
threw = false;
try { m_pStore->reset(); }
catch ( IOException & e ) { threw = true; ex = e; }
}
void MessageStoreExceptionWrapper::refresh( bool& threw, IOException& ex )
{
threw = false;
try { m_pStore->refresh(); }
catch ( IOException & e ) { threw = true; ex = e; }
}
} //namespace FIX