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  typedef std::pair < int, int > OffsetSize;
104  typedef std::map < int, OffsetSize > NumToOffset;
105 
106  void open( bool deleteFile );
107  void populateCache();
108  bool readFromFile( int offset, int size, std::string& msg );
109  void setSeqNum();
110  void setSession();
111 
112  bool get( int, std::string& ) const throw ( IOException );
113 
115  NumToOffset m_offsets;
116 
117  std::string m_msgFileName;
118  std::string m_headerFileName;
119  std::string m_seqNumsFileName;
120  std::string m_sessionFileName;
121 
122  FILE* m_msgFile;
126 };
127 }
128 
129 #endif //FIX_FILESTORE_H
std::string m_sessionFileName
Definition: FileStore.h:120
std::string m_msgFileName
Definition: FileStore.h:117
FILE * m_msgFile
Definition: FileStore.h:122
Creates a file based implementation of MessageStore.
Definition: FileStore.h:39
void destroy(MessageStore *)
Definition: FileStore.cpp:179
SessionSettings m_settings
Definition: FileStore.h:51
Definition: Acceptor.cpp:34
MemoryStore m_cache
Definition: FileStore.h:114
std::string m_path
Definition: FileStore.h:50
std::map< int, OffsetSize > NumToOffset
Definition: FileStore.h:104
std::string m_headerFileName
Definition: FileStore.h:118
File based implementation of MessageStore.
Definition: FileStore.h:81
Container for setting dictionaries mapped to sessions.
FILE * m_sessionFile
Definition: FileStore.h:125
This interface must be implemented to store and retrieve messages and sequence numbers.
Definition: MessageStore.h:66
This interface must be implemented to create a MessageStore.
Definition: MessageStore.h:41
FileStoreFactory(const std::string &path)
Definition: FileStore.h:44
FILE * m_headerFile
Definition: FileStore.h:123
Date and Time represented in UTC.
Definition: FieldTypes.h:399
MessageStore * create(const SessionID &)
Definition: FileStore.cpp:169
Memory based implementation of MessageStore.
Definition: MessageStore.h:96
Unique session id consists of BeginString, SenderCompID and TargetCompID.
Definition: SessionID.h:30
FILE * m_seqNumsFile
Definition: FileStore.h:124
NumToOffset m_offsets
Definition: FileStore.h:115
IO Error.
Definition: Exceptions.h:238
FileStoreFactory(const SessionSettings &settings)
Definition: FileStore.h:42
std::pair< int, int > OffsetSize
Definition: FileStore.h:103
std::string m_seqNumsFileName
Definition: FileStore.h:119

Generated on Thu Sep 5 2019 11:07:58 for QuickFIX by doxygen 1.8.13 written by Dimitri van Heesch, © 1997-2001