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 
41 class MessageStoreFactory
42 {
43 public:
44  virtual ~MessageStoreFactory() {}
45  virtual MessageStore* create( const SessionID& ) = 0;
46  virtual void destroy( MessageStore* ) = 0;
47 };
48 
55 class MemoryStoreFactory : public MessageStoreFactory
56 {
57 public:
59  void destroy( MessageStore* );
60 };
61 
66 class MessageStore
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; }
112  void incrNextSenderMsgSeqNum() throw ( IOException )
113  { ++m_nextSenderMsgSeqNum; }
114  void incrNextTargetMsgSeqNum() throw ( IOException )
115  { ++m_nextTargetMsgSeqNum; }
116 
117  void setCreationTime( const UtcTimeStamp& creationTime ) throw ( IOException )
118  { m_creationTime = creationTime; }
119  UtcTimeStamp getCreationTime() const throw ( IOException )
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 
132  Messages m_messages;
133  int m_nextSenderMsgSeqNum;
134  int m_nextTargetMsgSeqNum;
135  UtcTimeStamp m_creationTime;
136 };
137 
139 {
140 private:
141  MessageStoreFactory* m_pFactory;
142 public:
144  : m_pFactory( pFactory ) {}
145 
146  MessageStore* create( const SessionID&, bool&, ConfigError& );
147  void destroy( MessageStore* );
148 };
149 
151 {
152 private:
153  MessageStore* m_pStore;
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
FIX::MemoryStore::Messages
std::map< int, std::string > Messages
Definition: MessageStore.h:147
FIX::MessageStoreFactory::create
virtual MessageStore * create(const SessionID &)=0
FIX::MessageStoreFactory
This interface must be implemented to create a MessageStore.
Definition: MessageStore.h:58
FIX::UtcTimeStamp
Date and Time represented in UTC.
Definition: FieldTypes.h:599
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::IOException
IO Error.
Definition: Exceptions.h:255
FIX::MessageStore::incrNextTargetMsgSeqNum
virtual void incrNextTargetMsgSeqNum()=0
FIX::MessageStore::~MessageStore
virtual ~MessageStore()
Definition: MessageStore.h:86
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::MessageStore::set
virtual bool set(int, const std::string &)=0
FIX::MessageStoreExceptionWrapper
Definition: MessageStore.h:167
FIX::MessageStoreFactoryExceptionWrapper
Definition: MessageStore.h:155
FIX
Definition: Acceptor.cpp:34
FIX::MessageStoreFactory::~MessageStoreFactory
virtual ~MessageStoreFactory()
Definition: MessageStore.h:61
FIX::MemoryStore
Memory based implementation of MessageStore.
Definition: MessageStore.h:113
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::MessageStore::getNextSenderMsgSeqNum
virtual int getNextSenderMsgSeqNum() const =0
FIX::MemoryStoreFactory::create
MessageStore * create(const SessionID &)
Definition: MessageStore.cpp:47
FIX::MessageStore::getNextTargetMsgSeqNum
virtual int getNextTargetMsgSeqNum() const =0
Message.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