FileStore.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_FILESTORE_H
23 #define FIX_FILESTORE_H
24 
25 #ifdef _MSC_VER
26 #pragma warning( disable : 4503 4355 4786 4290 )
27 #endif
28 
29 #include "MessageStore.h"
30 #include "SessionSettings.h"
31 #include <fstream>
32 #include <string>
33 
34 namespace FIX
35 {
36 class Session;
37 
40 {
41 public:
42  FileStoreFactory( const SessionSettings& settings )
43 : m_settings( settings ) {};
44  FileStoreFactory( const std::string& path )
45 : m_path( path ) {};
46 
47  MessageStore* create( const SessionID& );
48  void destroy( MessageStore* );
49 private:
50  std::string m_path;
52 };
81 class FileStore : public MessageStore
82 {
83 public:
84  FileStore( std::string, const SessionID& s );
85  virtual ~FileStore();
86 
87  bool set( int, const std::string& ) throw ( IOException );
88  void get( int, int, std::vector < std::string > & ) const throw ( IOException );
89 
90  int getNextSenderMsgSeqNum() const throw ( IOException );
91  int getNextTargetMsgSeqNum() const throw ( IOException );
92  void setNextSenderMsgSeqNum( int value ) throw ( IOException );
93  void setNextTargetMsgSeqNum( int value ) throw ( IOException );
94  void incrNextSenderMsgSeqNum() throw ( IOException );
95  void incrNextTargetMsgSeqNum() throw ( IOException );
96 
97  UtcTimeStamp getCreationTime() const throw ( IOException );
98 
99  void reset() throw ( IOException );
100  void refresh() throw ( IOException );
101 
102 private:
103 #ifdef _MSC_VER
104  typedef std::pair < int, int > OffsetSize;
105 #else
106  typedef std::pair < long, std::size_t > OffsetSize;
107 #endif
108  typedef std::map < int, OffsetSize > NumToOffset;
109 
110  void open( bool deleteFile );
111  void populateCache();
112  bool readFromFile( int offset, int size, std::string& msg );
113  void setSeqNum();
114  void setSession();
115 
116  bool get( int, std::string& ) const throw ( IOException );
117 
120 
121  std::string m_msgFileName;
122  std::string m_headerFileName;
123  std::string m_seqNumsFileName;
124  std::string m_sessionFileName;
125 
126  FILE* m_msgFile;
130 };
131 }
132 
133 #endif //FIX_FILESTORE_H
Creates a file based implementation of MessageStore.
Definition: FileStore.h:40
MessageStore * create(const SessionID &)
Definition: FileStore.cpp:177
SessionSettings m_settings
Definition: FileStore.h:51
FileStoreFactory(const SessionSettings &settings)
Definition: FileStore.h:42
std::string m_path
Definition: FileStore.h:50
FileStoreFactory(const std::string &path)
Definition: FileStore.h:44
void destroy(MessageStore *)
Definition: FileStore.cpp:187
File based implementation of MessageStore.
Definition: FileStore.h:82
FILE * m_headerFile
Definition: FileStore.h:127
std::string m_seqNumsFileName
Definition: FileStore.h:123
void setNextSenderMsgSeqNum(int value)
Definition: FileStore.cpp:246
UtcTimeStamp getCreationTime() const
Definition: FileStore.cpp:270
int getNextSenderMsgSeqNum() const
Definition: FileStore.cpp:236
std::pair< long, std::size_t > OffsetSize
Definition: FileStore.h:106
FILE * m_sessionFile
Definition: FileStore.h:129
FILE * m_seqNumsFile
Definition: FileStore.h:128
void incrNextSenderMsgSeqNum()
Definition: FileStore.cpp:258
void setSession()
Definition: FileStore.cpp:313
void incrNextTargetMsgSeqNum()
Definition: FileStore.cpp:264
std::string m_sessionFileName
Definition: FileStore.h:124
void open(bool deleteFile)
Definition: FileStore.cpp:79
void populateCache()
Definition: FileStore.cpp:126
std::string m_headerFileName
Definition: FileStore.h:122
void get(int, int, std::vector< std::string > &) const
Definition: FileStore.cpp:223
virtual ~FileStore()
Definition: FileStore.cpp:71
MemoryStore m_cache
Definition: FileStore.h:118
void setNextTargetMsgSeqNum(int value)
Definition: FileStore.cpp:252
std::string m_msgFileName
Definition: FileStore.h:121
FileStore(std::string, const SessionID &s)
Definition: FileStore.cpp:34
void setSeqNum()
Definition: FileStore.cpp:302
std::map< int, OffsetSize > NumToOffset
Definition: FileStore.h:108
FILE * m_msgFile
Definition: FileStore.h:126
bool readFromFile(int offset, int size, std::string &msg)
NumToOffset m_offsets
Definition: FileStore.h:119
bool set(int, const std::string &)
Definition: FileStore.cpp:192
int getNextTargetMsgSeqNum() const
Definition: FileStore.cpp:241
Memory based implementation of MessageStore.
Definition: MessageStore.h:97
This interface must be implemented to create a MessageStore.
Definition: MessageStore.h:42
This interface must be implemented to store and retrieve messages and sequence numbers.
Definition: MessageStore.h:67
Unique session id consists of BeginString, SenderCompID and TargetCompID.
Definition: SessionID.h:31
Container for setting dictionaries mapped to sessions.
Date and Time represented in UTC.
Definition: FieldTypes.h:583
Definition: Acceptor.cpp:35

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