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
34namespace FIX
35{
36class Session;
37
40{
41public:
43: m_settings( settings ) {};
44 FileStoreFactory( const std::string& path )
45: m_path( path ) {};
46
47 MessageStore* create( const SessionID& );
48 void destroy( MessageStore* );
49private:
50 std::string m_path;
52};
81class FileStore : public MessageStore
82{
83public:
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
98
99 void reset() throw ( IOException );
100 void refresh() throw ( IOException );
101
102private:
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
130};
131}
132
133#endif //FIX_FILESTORE_H
Creates a file based implementation of MessageStore.
Definition FileStore.h:40
MessageStore * create(const SessionID &)
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 *)
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)
UtcTimeStamp getCreationTime() const
int getNextSenderMsgSeqNum() const
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()
void incrNextTargetMsgSeqNum()
std::string m_sessionFileName
Definition FileStore.h:124
void open(bool deleteFile)
Definition FileStore.cpp:79
void populateCache()
std::string m_headerFileName
Definition FileStore.h:122
void get(int, int, std::vector< std::string > &) const
virtual ~FileStore()
Definition FileStore.cpp:71
MemoryStore m_cache
Definition FileStore.h:118
void setNextTargetMsgSeqNum(int value)
std::string m_msgFileName
Definition FileStore.h:121
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 &)
int getNextTargetMsgSeqNum() const
Memory based implementation of MessageStore.
This interface must be implemented to create a MessageStore.
This interface must be implemented to store and retrieve messages and sequence numbers.
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

Generated on Thu May 22 2025 08:23:50 for QuickFIX by doxygen 1.9.8 written by Dimitri van Heesch, © 1997-2001