NullStore.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /* -*- C++ -*- */
  2. /****************************************************************************
  3. ** Copyright (c) 2001-2014
  4. **
  5. ** This file is part of the QuickFIX FIX Engine
  6. **
  7. ** This file may be distributed under the terms of the quickfixengine.org
  8. ** license as defined by quickfixengine.org and appearing in the file
  9. ** LICENSE included in the packaging of this file.
  10. **
  11. ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
  12. ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  13. **
  14. ** See http://www.quickfixengine.org/LICENSE for licensing information.
  15. **
  16. ** Contact ask@quickfixengine.org if any conditions of this licensing are
  17. ** not clear to you.
  18. **
  19. ****************************************************************************/
  20. #ifndef FIX_NULLSTORE_H
  21. #define FIX_NULLSTORE_H
  22. #ifdef _MSC_VER
  23. #pragma warning( disable : 4503 4355 4786 4290 )
  24. #endif
  25. #include "MessageStore.h"
  26. #include "SessionSettings.h"
  27. #include <string>
  28. namespace FIX
  29. {
  30. class Session;
  31. /**
  32. * Null implementation of MessageStore.
  33. *
  34. * Will not actually store messages. Useful for admin-only or market
  35. * data-only applications.
  36. */
  37. class NullStoreFactory : public MessageStoreFactory
  38. {
  39. public:
  40. MessageStore* create( const SessionID& );
  41. void destroy( MessageStore* );
  42. };
  43. /*! @} */
  44. /**
  45. * Null implementation of MessageStore.
  46. *
  47. * Will not actually store messages. Useful for admin-only or market
  48. * data-only applications.
  49. */
  50. class NullStore : public MessageStore
  51. {
  52. public:
  53. NullStore() : m_nextSenderMsgSeqNum( 1 ), m_nextTargetMsgSeqNum( 1 ) {}
  54. bool set( int, const std::string& ) throw ( IOException );
  55. void get( int, int, std::vector < std::string > & ) const throw ( IOException );
  56. int getNextSenderMsgSeqNum() const throw ( IOException )
  57. { return m_nextSenderMsgSeqNum; }
  58. int getNextTargetMsgSeqNum() const throw ( IOException )
  59. { return m_nextTargetMsgSeqNum; }
  60. void setNextSenderMsgSeqNum( int value ) throw ( IOException )
  61. { m_nextSenderMsgSeqNum = value; }
  62. void setNextTargetMsgSeqNum( int value ) throw ( IOException )
  63. { m_nextTargetMsgSeqNum = value; }
  64. void incrNextSenderMsgSeqNum() throw ( IOException )
  65. { ++m_nextSenderMsgSeqNum; }
  66. void incrNextTargetMsgSeqNum() throw ( IOException )
  67. { ++m_nextTargetMsgSeqNum; }
  68. void setCreationTime( const UtcTimeStamp& creationTime ) throw ( IOException )
  69. { m_creationTime = creationTime; }
  70. UtcTimeStamp getCreationTime() const throw ( IOException )
  71. { return m_creationTime; }
  72. void reset() throw ( IOException )
  73. {
  74. m_nextSenderMsgSeqNum = 1; m_nextTargetMsgSeqNum = 1;
  75. m_creationTime.setCurrent();
  76. }
  77. void refresh() throw ( IOException ) {}
  78. private:
  79. int m_nextSenderMsgSeqNum;
  80. int m_nextTargetMsgSeqNum;
  81. UtcTimeStamp m_creationTime;
  82. };
  83. }
  84. #endif // FIX_NULLSTORE_H