Index Source Files Annotated Class List Alphabetical Class List Class Hierarchy Graphical Class Hierarchy

# FileStore.h

Go to the documentation of this file.

    00001 /* -*- C++ -*- */
    00002
    00003 /****************************************************************************
    00004 ** Copyright (c) quickfixengine.org  All rights reserved.
    00005 **
    00006 ** This file is part of the QuickFIX FIX Engine
    00007 **
    00008 ** This file may be distributed under the terms of the quickfixengine.org
    00009 ** license as defined by quickfixengine.org and appearing in the file
    00010 ** LICENSE included in the packaging of this file.
    00011 **
    00012 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
    00013 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
    00014 **
    00015 ** See http://www.quickfixengine.org/LICENSE for licensing information.
    00016 **
    00017 ** Contact ask@quickfixengine.org if any conditions of this licensing are
    00018 ** not clear to you.
    00019 **
    00020 ****************************************************************************/
    00021
    00022 #ifndef FIX_FILESTORE_H
    00023 #define FIX_FILESTORE_H
    00024
    00025 #ifdef _MSC_VER
    00026 #pragma warning( disable : 4503 4355 4786 4290 )
    00027 #endif
    00028
    00029 #include "MessageStore.h"
    00030 #include "SessionSettings.h"
    00031 #include <fstream>
    00032 #include <string>
    00033
    00034 namespace FIX
    00035 {
    00036 class Session;
    00037
    00039 class FileStoreFactory : public MessageStoreFactory
    00040 {
    00041 public:
    00042   FileStoreFactory( const SessionSettings& settings )
    00043 : m_settings( settings ) {};
    00044   FileStoreFactory( const std::string& path )
    00045 : m_path( path ) {};
    00046
    00047   MessageStore* create( const SessionID& );
    00048   void destroy( MessageStore* );
    00049 private:
    00050   std::string m_path;
    00051   SessionSettings m_settings;
    00052 };
    00081 class FileStore : public MessageStore
    00082 {
    00083 public:
    00084   FileStore( std::string, const SessionID& s );
    00085   virtual ~FileStore();
    00086
    00087   bool set( int, const std::string& ) throw ( IOException );
    00088   void get( int, int, std::vector < std::string > & ) const throw ( IOException );
    00089
    00090   int getNextSenderMsgSeqNum() const throw ( IOException );
    00091   int getNextTargetMsgSeqNum() const throw ( IOException );
    00092   void setNextSenderMsgSeqNum( int value ) throw ( IOException );
    00093   void setNextTargetMsgSeqNum( int value ) throw ( IOException );
    00094   void incrNextSenderMsgSeqNum() throw ( IOException );
    00095   void incrNextTargetMsgSeqNum() throw ( IOException );
    00096
    00097   UtcTimeStamp getCreationTime() const throw ( IOException );
    00098
    00099   void reset() throw ( IOException );
    00100   void refresh() throw ( IOException );
    00101
    00102 private:
    00103   typedef std::pair < int, int > OffsetSize;
    00104   typedef std::map < int, OffsetSize > NumToOffset;
    00105
    00106   void open( bool deleteFile );
    00107   void populateCache();
    00108   bool readFromFile( int offset, int size, std::string& msg );
    00109   void setSeqNum();
    00110   void setSession();
    00111
    00112   bool get( int, std::string& ) const throw ( IOException );
    00113
    00114   MemoryStore m_cache;
    00115   NumToOffset m_offsets;
    00116
    00117   std::string m_msgFileName;
    00118   std::string m_headerFileName;
    00119   std::string m_seqNumsFileName;
    00120   std::string m_sessionFileName;
    00121
    00122   FILE* m_msgFile;
    00123   FILE* m_headerFile;
    00124   FILE* m_seqNumsFile;
    00125   FILE* m_sessionFile;
    00126 };
    00127 }
    00128
    00129 #endif //FIX_FILESTORE_H