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 
39 class FileStoreFactory : public MessageStoreFactory
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;
51  SessionSettings m_settings;
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;
127  FILE* m_headerFile;
128  FILE* m_seqNumsFile;
129  FILE* m_sessionFile;
130 };
131 }
132 
133 #endif //FIX_FILESTORE_H
FIX::FileStore::refresh
void refresh()
Definition: FileStore.cpp:306
FIX::FileStoreFactory::FileStoreFactory
FileStoreFactory(const SessionSettings &settings)
Definition: FileStore.h:59
FIX::FileStore::m_seqNumsFileName
std::string m_seqNumsFileName
Definition: FileStore.h:140
FIX::FileStore::populateCache
void populateCache()
Definition: FileStore.cpp:143
FIX::FileStore::reset
void reset()
Definition: FileStore.cpp:292
SessionSettings.h
FIX::FileStore::m_sessionFileName
std::string m_sessionFileName
Definition: FileStore.h:141
FIX::FileStore::m_msgFileName
std::string m_msgFileName
Definition: FileStore.h:138
FIX::FileStore::setSession
void setSession()
Definition: FileStore.cpp:330
FIX::FileStoreFactory::create
MessageStore * create(const SessionID &)
Definition: FileStore.cpp:194
FIX::FileStore::incrNextTargetMsgSeqNum
void incrNextTargetMsgSeqNum()
Definition: FileStore.cpp:281
FIX::FileStore::readFromFile
bool readFromFile(int offset, int size, std::string &msg)
FIX::FileStore::m_cache
MemoryStore m_cache
Definition: FileStore.h:135
FIX::FileStore::FileStore
FileStore(std::string, const SessionID &s)
Definition: FileStore.cpp:51
FIX::FileStore::m_msgFile
FILE * m_msgFile
Definition: FileStore.h:143
FIX::FileStore::~FileStore
virtual ~FileStore()
Definition: FileStore.cpp:88
FIX::FileStore::getNextSenderMsgSeqNum
int getNextSenderMsgSeqNum() const
Definition: FileStore.cpp:253
FIX::IOException
IO Error.
Definition: Exceptions.h:255
FIX::FileStore::setNextTargetMsgSeqNum
void setNextTargetMsgSeqNum(int value)
Definition: FileStore.cpp:269
FIX::FileStore::get
void get(int, int, std::vector< std::string > &) const
Definition: FileStore.cpp:240
FIX::TYPE::UtcTimeStamp
@ UtcTimeStamp
Definition: FieldTypes.h:940
FIX::FileStore::m_seqNumsFile
FILE * m_seqNumsFile
Definition: FileStore.h:145
FIX::FileStore::incrNextSenderMsgSeqNum
void incrNextSenderMsgSeqNum()
Definition: FileStore.cpp:275
FIX::FileStore::m_headerFileName
std::string m_headerFileName
Definition: FileStore.h:139
FIX::FileStore::m_sessionFile
FILE * m_sessionFile
Definition: FileStore.h:146
FIX::FileStore::OffsetSize
std::pair< long, std::size_t > OffsetSize
Definition: FileStore.h:123
FIX
Definition: Acceptor.cpp:34
FIX::FileStore::getNextTargetMsgSeqNum
int getNextTargetMsgSeqNum() const
Definition: FileStore.cpp:258
FIX::MemoryStore
Memory based implementation of MessageStore.
Definition: MessageStore.h:113
FIX::FileStore::getCreationTime
UtcTimeStamp getCreationTime() const
Definition: FileStore.cpp:287
FIX::FileStoreFactory::m_path
std::string m_path
Definition: FileStore.h:67
FIX::FileStore::setSeqNum
void setSeqNum()
Definition: FileStore.cpp:319
FIX::FileStore::m_offsets
NumToOffset m_offsets
Definition: FileStore.h:136
FIX::FileStore::NumToOffset
std::map< int, OffsetSize > NumToOffset
Definition: FileStore.h:125
FIX::FileStore::open
void open(bool deleteFile)
Definition: FileStore.cpp:96
FIX::FileStoreFactory::m_settings
SessionSettings m_settings
Definition: FileStore.h:68
FIX::FileStore::set
bool set(int, const std::string &)
Definition: FileStore.cpp:209
FIX::FileStoreFactory::destroy
void destroy(MessageStore *)
Definition: FileStore.cpp:204
FIX::FileStore::setNextSenderMsgSeqNum
void setNextSenderMsgSeqNum(int value)
Definition: FileStore.cpp:263
MessageStore.h
FIX::FileStore::m_headerFile
FILE * m_headerFile
Definition: FileStore.h:144

Generated on Wed Apr 29 2020 19:41:30 for QuickFIX by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2001