MessageStore.cpp
Go to the documentation of this file.
/****************************************************************************
** Copyright (c) 2001-2014
**
** This file is part of the QuickFIX FIX Engine
**
** This file may be distributed under the terms of the quickfixengine.org
** license as defined by quickfixengine.org and appearing in the file
** LICENSE included in the packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.quickfixengine.org/LICENSE for licensing information.
**
** Contact ask@quickfixengine.org if any conditions of this licensing are
** not clear to you.
**
****************************************************************************/
#ifdef _MSC_VER
#include "stdafx.h"
#else
#include "config.h"
#endif
#include "MessageStore.h"
namespace FIX
{
MessageStore* MemoryStoreFactory::create( const SessionID& )
{
return new MemoryStore();
}
void MemoryStoreFactory::destroy( MessageStore* pStore )
{
delete pStore;
}
bool MemoryStore::set( int msgSeqNum, const std::string& msg )
throw( IOException )
{
m_messages[ msgSeqNum ] = msg;
return true;
}
void MemoryStore::get( int begin, int end,
std::vector < std::string > & messages ) const
throw( IOException )
{
messages.clear();
Messages::const_iterator find = m_messages.find( begin );
for ( ; find != m_messages.end() && find->first <= end; ++find )
messages.push_back( find->second );
}
MessageStore* MessageStoreFactoryExceptionWrapper::create( const SessionID& sessionID, bool& threw, ConfigError& ex )
{
threw = false;
try { return m_pFactory->create( sessionID ); }
catch ( ConfigError & e ) { threw = true; ex = e; return 0; }
}
void MessageStoreFactoryExceptionWrapper::destroy( MessageStore* pStore )
{
m_pFactory->destroy( pStore );
}
bool MessageStoreExceptionWrapper::set( int num, const std::string& msg, bool& threw, IOException& ex )
{
threw = false;
try { return m_pStore->set( num, msg ); }
catch ( IOException & e ) { threw = true; ex = e; return false; }
}
void MessageStoreExceptionWrapper::get( int begin, int end, std::vector < std::string > & msgs, bool& threw, IOException& ex ) const
{
threw = false;
try { m_pStore->get( begin, end, msgs ); }
catch ( IOException & e ) { threw = true; ex = e; }
}
int MessageStoreExceptionWrapper::getNextSenderMsgSeqNum( bool& threw, IOException& ex ) const
{
threw = false;
try { return m_pStore->getNextSenderMsgSeqNum(); }
catch ( IOException & e ) { threw = true; ex = e; return 0; }
}
int MessageStoreExceptionWrapper::getNextTargetMsgSeqNum( bool& threw, IOException& ex ) const
{
threw = false;
try { return m_pStore->getNextTargetMsgSeqNum(); }
catch ( IOException & e ) { threw = true; ex = e; return 0; }
}
void MessageStoreExceptionWrapper::setNextSenderMsgSeqNum( int num, bool& threw, IOException& ex )
{
threw = false;
try { m_pStore->setNextSenderMsgSeqNum( num ); }
catch ( IOException & e ) { threw = true; ex = e; }
}
void MessageStoreExceptionWrapper::setNextTargetMsgSeqNum( int num, bool& threw, IOException& ex )
{
threw = false;
try { m_pStore->setNextTargetMsgSeqNum( num ); }
catch ( IOException & e ) { threw = true; ex = e; }
}
void MessageStoreExceptionWrapper::incrNextSenderMsgSeqNum( bool& threw, IOException& ex )
{
threw = false;
try { m_pStore->incrNextSenderMsgSeqNum(); }
catch ( IOException & e ) { threw = true; ex = e; }
}
void MessageStoreExceptionWrapper::incrNextTargetMsgSeqNum( bool& threw, IOException& ex )
{
threw = false;
try { m_pStore->incrNextTargetMsgSeqNum(); }
catch ( IOException & e ) { threw = true; ex = e; }
}
UtcTimeStamp MessageStoreExceptionWrapper::getCreationTime( bool& threw, IOException& ex )
{
threw = false;
try { return m_pStore->getCreationTime(); }
catch ( IOException & e ) { threw = true; ex = e; return UtcTimeStamp(); }
}
void MessageStoreExceptionWrapper::reset( bool& threw, IOException& ex )
{
threw = false;
try { m_pStore->reset(); }
catch ( IOException & e ) { threw = true; ex = e; }
}
void MessageStoreExceptionWrapper::refresh( bool& threw, IOException& ex )
{
threw = false;
try { m_pStore->refresh(); }
catch ( IOException & e ) { threw = true; ex = e; }
}
} //namespace FIX
MessageStore.h
FIX::MemoryStoreFactory::destroy
void destroy(MessageStore *)
Definition MessageStore.cpp:35
FIX::MemoryStoreFactory::create
MessageStore * create(const SessionID &)
Definition MessageStore.cpp:30
FIX::MemoryStore
Memory based implementation of MessageStore.
Definition MessageStore.h:97
FIX::MemoryStore::get
void get(int, int, std::vector< std::string > &) const
Definition MessageStore.cpp:47
FIX::MemoryStore::set
bool set(int, const std::string &)
Definition MessageStore.cpp:40
FIX::MessageStoreExceptionWrapper::m_pStore
MessageStore * m_pStore
Definition MessageStore.h:153
FIX::MessageStoreExceptionWrapper::incrNextSenderMsgSeqNum
void incrNextSenderMsgSeqNum(bool &, IOException &)
Definition MessageStore.cpp:111
FIX::MessageStoreExceptionWrapper::setNextSenderMsgSeqNum
void setNextSenderMsgSeqNum(int, bool &, IOException &)
Definition MessageStore.cpp:97
FIX::MessageStoreExceptionWrapper::refresh
void refresh(bool &, IOException &)
Definition MessageStore.cpp:139
FIX::MessageStoreExceptionWrapper::getNextSenderMsgSeqNum
int getNextSenderMsgSeqNum(bool &, IOException &) const
Definition MessageStore.cpp:83
FIX::MessageStoreExceptionWrapper::incrNextTargetMsgSeqNum
void incrNextTargetMsgSeqNum(bool &, IOException &)
Definition MessageStore.cpp:118
FIX::MessageStoreExceptionWrapper::reset
void reset(bool &, IOException &)
Definition MessageStore.cpp:132
FIX::MessageStoreExceptionWrapper::get
void get(int, int, std::vector< std::string > &, bool &, IOException &) const
Definition MessageStore.cpp:76
FIX::MessageStoreExceptionWrapper::set
bool set(int, const std::string &, bool &, IOException &)
Definition MessageStore.cpp:69
FIX::MessageStoreExceptionWrapper::getNextTargetMsgSeqNum
int getNextTargetMsgSeqNum(bool &, IOException &) const
Definition MessageStore.cpp:90
FIX::MessageStoreExceptionWrapper::getCreationTime
UtcTimeStamp getCreationTime(bool &, IOException &)
Definition MessageStore.cpp:125
FIX::MessageStoreExceptionWrapper::setNextTargetMsgSeqNum
void setNextTargetMsgSeqNum(int, bool &, IOException &)
Definition MessageStore.cpp:104
FIX::MessageStoreFactoryExceptionWrapper::destroy
void destroy(MessageStore *)
Definition MessageStore.cpp:64
FIX::MessageStoreFactoryExceptionWrapper::create
MessageStore * create(const SessionID &, bool &, ConfigError &)
Definition MessageStore.cpp:57
FIX::MessageStoreFactoryExceptionWrapper::m_pFactory
MessageStoreFactory * m_pFactory
Definition MessageStore.h:141
FIX::MessageStoreFactory::create
virtual MessageStore * create(const SessionID &)=0
FIX::MessageStoreFactory::destroy
virtual void destroy(MessageStore *)=0
FIX::MessageStore
This interface must be implemented to store and retrieve messages and sequence numbers.
Definition MessageStore.h:67
FIX::MessageStore::set
virtual bool set(int, const std::string &)=0
FIX::MessageStore::getNextSenderMsgSeqNum
virtual int getNextSenderMsgSeqNum() const =0
FIX::MessageStore::setNextTargetMsgSeqNum
virtual void setNextTargetMsgSeqNum(int)=0
FIX::MessageStore::incrNextSenderMsgSeqNum
virtual void incrNextSenderMsgSeqNum()=0
FIX::MessageStore::incrNextTargetMsgSeqNum
virtual void incrNextTargetMsgSeqNum()=0
FIX::MessageStore::getNextTargetMsgSeqNum
virtual int getNextTargetMsgSeqNum() const =0
FIX::MessageStore::getCreationTime
virtual UtcTimeStamp getCreationTime() const =0
FIX::MessageStore::reset
virtual void reset()=0
FIX::MessageStore::get
virtual void get(int, int, std::vector< std::string > &) const =0
FIX::MessageStore::setNextSenderMsgSeqNum
virtual void setNextSenderMsgSeqNum(int)=0
FIX::MessageStore::refresh
virtual void refresh()=0
FIX::SessionID
Unique session id consists of BeginString, SenderCompID and TargetCompID.
Definition SessionID.h:31
FIX::UtcTimeStamp
Date and Time represented in UTC.
Definition FieldTypes.h:583
FIX
Definition Acceptor.cpp:35
FIX::ConfigError
Application is not configured correctly
Definition Exceptions.h:88
FIX::IOException
IO Error.
Definition Exceptions.h:239