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 {
31 {
32  return new MemoryStore();
33 }
34 
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 
91 {
92  threw = false;
93  try { return m_pStore->getNextTargetMsgSeqNum(); }
94  catch ( IOException & e ) { threw = true; ex = e; return 0; }
95 }
96 
98 {
99  threw = false;
100  try { m_pStore->setNextSenderMsgSeqNum( num ); }
101  catch ( IOException & e ) { threw = true; ex = e; }
102 }
103 
105 {
106  threw = false;
107  try { m_pStore->setNextTargetMsgSeqNum( num ); }
108  catch ( IOException & e ) { threw = true; ex = e; }
109 }
110 
112 {
113  threw = false;
115  catch ( IOException & e ) { threw = true; ex = e; }
116 }
117 
119 {
120  threw = false;
122  catch ( IOException & e ) { threw = true; ex = e; }
123 }
124 
126 {
127  threw = false;
128  try { return m_pStore->getCreationTime(); }
129  catch ( IOException & e ) { threw = true; ex = e; return UtcTimeStamp(); }
130 }
131 
133 {
134  threw = false;
135  try { m_pStore->reset(); }
136  catch ( IOException & e ) { threw = true; ex = e; }
137 }
138 
140 {
141  threw = false;
142  try { m_pStore->refresh(); }
143  catch ( IOException & e ) { threw = true; ex = e; }
144 }
145 
146 } //namespace FIX
MessageStore * create(const SessionID &, bool &, ConfigError &)
virtual void setNextSenderMsgSeqNum(int)=0
void get(int, int, std::vector< std::string > &) const
virtual MessageStore * create(const SessionID &)=0
void setNextTargetMsgSeqNum(int, bool &, IOException &)
virtual bool set(int, const std::string &)=0
MessageStore * create(const SessionID &)
void reset(bool &, IOException &)
virtual int getNextTargetMsgSeqNum() const =0
virtual UtcTimeStamp getCreationTime() const =0
bool set(int, const std::string &, bool &, IOException &)
void incrNextTargetMsgSeqNum(bool &, IOException &)
virtual void incrNextTargetMsgSeqNum()=0
void get(int, int, std::vector< std::string > &, bool &, IOException &) const
Application is not configured correctly
Definition: Exceptions.h:87
void refresh(bool &, IOException &)
bool set(int, const std::string &)
virtual void destroy(MessageStore *)=0
This interface must be implemented to store and retrieve messages and sequence numbers.
Definition: MessageStore.h:66
void setNextSenderMsgSeqNum(int, bool &, IOException &)
UtcTimeStamp getCreationTime(bool &, IOException &)
Date and Time represented in UTC.
Definition: FieldTypes.h:399
virtual void get(int, int, std::vector< std::string > &) const =0
Memory based implementation of MessageStore.
Definition: MessageStore.h:96
virtual int getNextSenderMsgSeqNum() const =0
Unique session id consists of BeginString, SenderCompID and TargetCompID.
Definition: SessionID.h:30
virtual void incrNextSenderMsgSeqNum()=0
virtual void reset()=0
void incrNextSenderMsgSeqNum(bool &, IOException &)
IO Error.
Definition: Exceptions.h:238
virtual void refresh()=0
virtual void setNextTargetMsgSeqNum(int)=0
int getNextSenderMsgSeqNum(bool &, IOException &) const
int getNextTargetMsgSeqNum(bool &, IOException &) const
void destroy(MessageStore *)

Generated on Sat Mar 29 2014 15:13:32 for QuickFIX by doxygen 1.8.5 written by Dimitri van Heesch, © 1997-2001