MessageStore.cpp
Go to the documentation of this file.
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 
58 {
59  threw = false;
60  try { return m_pFactory->create( sessionID ); }
61  catch ( ConfigError & e ) { threw = true; ex = e; return 0; }
62 }
63 
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 
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;
101  catch ( IOException & e ) { threw = true; ex = e; }
102 }
103 
104 void MessageStoreExceptionWrapper::setNextTargetMsgSeqNum( int num, bool& threw, IOException& ex )
105 {
106  threw = false;
108  catch ( IOException & e ) { threw = true; ex = e; }
109 }
110 
111 void MessageStoreExceptionWrapper::incrNextSenderMsgSeqNum( bool& threw, IOException& ex )
112 {
113  threw = false;
115  catch ( IOException & e ) { threw = true; ex = e; }
116 }
117 
118 void MessageStoreExceptionWrapper::incrNextTargetMsgSeqNum( bool& threw, IOException& ex )
119 {
120  threw = false;
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
FIX::MessageStoreExceptionWrapper::m_pStore
MessageStore * m_pStore
Definition: MessageStore.h:170
FIX::MessageStoreExceptionWrapper::reset
void reset(bool &, IOException &)
Definition: MessageStore.cpp:149
FIX::MessageStoreFactory::create
virtual MessageStore * create(const SessionID &)=0
FIX::MessageStoreExceptionWrapper::setNextSenderMsgSeqNum
void setNextSenderMsgSeqNum(int, bool &, IOException &)
Definition: MessageStore.cpp:114
FIX::MessageStoreExceptionWrapper::getNextTargetMsgSeqNum
int getNextTargetMsgSeqNum(bool &, IOException &) const
Definition: MessageStore.cpp:107
FIX::MessageStoreFactory::destroy
virtual void destroy(MessageStore *)=0
FIX::MessageStore::getCreationTime
virtual UtcTimeStamp getCreationTime() const =0
FIX::ConfigError
Application is not configured correctly
Definition: Exceptions.h:104
FIX::SessionID
Unique session id consists of BeginString, SenderCompID and TargetCompID.
Definition: SessionID.h:47
FIX::MessageStore::incrNextSenderMsgSeqNum
virtual void incrNextSenderMsgSeqNum()=0
FIX::MessageStoreExceptionWrapper::incrNextSenderMsgSeqNum
void incrNextSenderMsgSeqNum(bool &, IOException &)
Definition: MessageStore.cpp:128
FIX::IOException
IO Error.
Definition: Exceptions.h:255
FIX::MessageStore::incrNextTargetMsgSeqNum
virtual void incrNextTargetMsgSeqNum()=0
FIX::TYPE::UtcTimeStamp
@ UtcTimeStamp
Definition: FieldTypes.h:940
FIX::MessageStoreExceptionWrapper::incrNextTargetMsgSeqNum
void incrNextTargetMsgSeqNum(bool &, IOException &)
Definition: MessageStore.cpp:135
FIX::MessageStore::reset
virtual void reset()=0
FIX::MessageStore::setNextTargetMsgSeqNum
virtual void setNextTargetMsgSeqNum(int)=0
FIX::MessageStore::refresh
virtual void refresh()=0
FIX::MessageStore
This interface must be implemented to store and retrieve messages and sequence numbers.
Definition: MessageStore.h:83
FIX::MessageStoreExceptionWrapper::set
bool set(int, const std::string &, bool &, IOException &)
Definition: MessageStore.cpp:86
FIX::MessageStoreFactoryExceptionWrapper::m_pFactory
MessageStoreFactory * m_pFactory
Definition: MessageStore.h:158
FIX::MessageStore::set
virtual bool set(int, const std::string &)=0
FIX::MessageStoreExceptionWrapper::setNextTargetMsgSeqNum
void setNextTargetMsgSeqNum(int, bool &, IOException &)
Definition: MessageStore.cpp:121
FIX::MessageStoreExceptionWrapper::refresh
void refresh(bool &, IOException &)
Definition: MessageStore.cpp:156
FIX::MemoryStore::set
bool set(int, const std::string &)
Definition: MessageStore.cpp:57
FIX
Definition: Acceptor.cpp:34
FIX::MessageStoreExceptionWrapper::getNextSenderMsgSeqNum
int getNextSenderMsgSeqNum(bool &, IOException &) const
Definition: MessageStore.cpp:100
FIX::MessageStore::get
virtual void get(int, int, std::vector< std::string > &) const =0
FIX::MemoryStoreFactory::destroy
void destroy(MessageStore *)
Definition: MessageStore.cpp:52
FIX::MessageStoreFactoryExceptionWrapper::destroy
void destroy(MessageStore *)
Definition: MessageStore.cpp:81
FIX::MessageStore::getNextSenderMsgSeqNum
virtual int getNextSenderMsgSeqNum() const =0
FIX::MemoryStore::get
void get(int, int, std::vector< std::string > &) const
Definition: MessageStore.cpp:64
FIX::MessageStoreExceptionWrapper::getCreationTime
UtcTimeStamp getCreationTime(bool &, IOException &)
Definition: MessageStore.cpp:142
FIX::MessageStoreFactoryExceptionWrapper::create
MessageStore * create(const SessionID &, bool &, ConfigError &)
Definition: MessageStore.cpp:74
FIX::MemoryStoreFactory::create
MessageStore * create(const SessionID &)
Definition: MessageStore.cpp:47
FIX::MessageStoreExceptionWrapper::get
void get(int, int, std::vector< std::string > &, bool &, IOException &) const
Definition: MessageStore.cpp:93
FIX::MessageStore::getNextTargetMsgSeqNum
virtual int getNextTargetMsgSeqNum() const =0
MessageStore.h
FIX::MessageStore::setNextSenderMsgSeqNum
virtual void setNextSenderMsgSeqNum(int)=0

Generated on Wed Apr 29 2020 19:41:30 for QuickFIX by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2001