MessageStore.h
Go to the documentation of this file.
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 
42 {
43 public:
44  virtual ~MessageStoreFactory() {}
45  virtual MessageStore* create( const SessionID& ) = 0;
46  virtual void destroy( MessageStore* ) = 0;
47 };
48 
56 {
57 public:
58  MessageStore* create( const SessionID& );
59  void destroy( MessageStore* );
60 };
61 
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 };
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; }
113  { ++m_nextSenderMsgSeqNum; }
115  { ++m_nextTargetMsgSeqNum; }
116 
117  void setCreationTime( const UtcTimeStamp& creationTime ) throw ( IOException )
118  { m_creationTime = creationTime; }
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 
136 };
137 
139 {
140 private:
142 public:
144  : m_pFactory( pFactory ) {}
145 
146  MessageStore* create( const SessionID&, bool&, ConfigError& );
147  void destroy( MessageStore* );
148 };
149 
151 {
152 private:
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 
168 
169  void reset( bool&, IOException& );
170  void refresh( bool&, IOException& );
171 };
172 }
173 
174 #endif //FIX_MESSAGESTORE_H
Creates a memory based implementation of MessageStore.
Definition: MessageStore.h:56
void destroy(MessageStore *)
MessageStore * create(const SessionID &)
Memory based implementation of MessageStore.
Definition: MessageStore.h:97
UtcTimeStamp m_creationTime
Definition: MessageStore.h:135
void setCreationTime(const UtcTimeStamp &creationTime)
Definition: MessageStore.h:117
int getNextTargetMsgSeqNum() const
Definition: MessageStore.h:106
void incrNextTargetMsgSeqNum()
Definition: MessageStore.h:114
Messages m_messages
Definition: MessageStore.h:132
void incrNextSenderMsgSeqNum()
Definition: MessageStore.h:112
void setNextTargetMsgSeqNum(int value)
Definition: MessageStore.h:110
UtcTimeStamp getCreationTime() const
Definition: MessageStore.h:119
void setNextSenderMsgSeqNum(int value)
Definition: MessageStore.h:108
std::map< int, std::string > Messages
Definition: MessageStore.h:130
int getNextSenderMsgSeqNum() const
Definition: MessageStore.h:104
MessageStoreExceptionWrapper(MessageStore *pStore)
Definition: MessageStore.h:155
MessageStoreFactoryExceptionWrapper(MessageStoreFactory *pFactory)
Definition: MessageStore.h:143
This interface must be implemented to create a MessageStore.
Definition: MessageStore.h:42
virtual ~MessageStoreFactory()
Definition: MessageStore.h:44
virtual MessageStore * create(const SessionID &)=0
virtual void destroy(MessageStore *)=0
This interface must be implemented to store and retrieve messages and sequence numbers.
Definition: MessageStore.h:67
virtual bool set(int, const std::string &)=0
virtual int getNextSenderMsgSeqNum() const =0
virtual ~MessageStore()
Definition: MessageStore.h:69
virtual void setNextTargetMsgSeqNum(int)=0
virtual void incrNextSenderMsgSeqNum()=0
virtual void incrNextTargetMsgSeqNum()=0
virtual int getNextTargetMsgSeqNum() const =0
virtual UtcTimeStamp getCreationTime() const =0
virtual void reset()=0
virtual void get(int, int, std::vector< std::string > &) const =0
virtual void setNextSenderMsgSeqNum(int)=0
virtual void refresh()=0
Unique session id consists of BeginString, SenderCompID and TargetCompID.
Definition: SessionID.h:31
Date and Time represented in UTC.
Definition: FieldTypes.h:583
Definition: Acceptor.cpp:35
Application is not configured correctly
Definition: Exceptions.h:88

Generated on Wed Nov 24 2021 09:55:53 for QuickFIX by doxygen 1.9.1 written by Dimitri van Heesch, © 1997-2001