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 
119  NumToOffset m_offsets;
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
std::string m_sessionFileName
Definition: FileStore.h:124
std::string m_msgFileName
Definition: FileStore.h:121
FILE * m_msgFile
Definition: FileStore.h:126
Creates a file based implementation of MessageStore.
Definition: FileStore.h:39
void destroy(MessageStore *)
Definition: FileStore.cpp:187
SessionSettings m_settings
Definition: FileStore.h:51
Definition: Acceptor.cpp:34
MemoryStore m_cache
Definition: FileStore.h:118
std::string m_path
Definition: FileStore.h:50
std::map< int, OffsetSize > NumToOffset
Definition: FileStore.h:108
std::string m_headerFileName
Definition: FileStore.h:122
File based implementation of MessageStore.
Definition: FileStore.h:81
Container for setting dictionaries mapped to sessions.
FILE * m_sessionFile
Definition: FileStore.h:129
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:127
Date and Time represented in UTC.
Definition: FieldTypes.h:582
MessageStore * create(const SessionID &)
Definition: FileStore.cpp:177
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:128
NumToOffset m_offsets
Definition: FileStore.h:119
IO Error.
Definition: Exceptions.h:238
FileStoreFactory(const SessionSettings &settings)
Definition: FileStore.h:42
std::pair< long, std::size_t > OffsetSize
Definition: FileStore.h:106
std::string m_seqNumsFileName
Definition: FileStore.h:123

Generated on Sun Apr 15 2018 21:44:00 for QuickFIX by doxygen 1.8.13 written by Dimitri van Heesch, © 1997-2001