Public Types | Public Member Functions | Private Types | Private Attributes
FIX::SessionState Class Reference

Maintains all of state for the Session class. More...

#include <SessionState.h>

Inheritance diagram for FIX::SessionState:
Inheritance graph
[legend]
Collaboration diagram for FIX::SessionState:
Collaboration graph
[legend]

List of all members.

Public Types

typedef std::pair< int, int > ResendRange

Public Member Functions

 SessionState ()
bool enabled () const
void enabled (bool value)
bool receivedLogon () const
void receivedLogon (bool value)
bool sentLogout () const
void sentLogout (bool value)
bool sentLogon () const
void sentLogon (bool value)
bool receivedReset () const
void receivedReset (bool value)
bool sentReset () const
void sentReset (bool value)
bool initiate () const
void initiate (bool value)
int logonTimeout () const
void logonTimeout (int value)
int logoutTimeout () const
void logoutTimeout (int value)
int testRequest () const
void testRequest (int value)
bool resendRequested () const
ResendRange resendRange () const
void resendRange (int begin, int end)
MessageStorestore ()
void store (MessageStore *pValue)
Loglog ()
void log (Log *pValue)
void heartBtInt (const HeartBtInt &value)
HeartBtInt & heartBtInt ()
const HeartBtInt & heartBtInt () const
void lastSentTime (const UtcTimeStamp &value)
UtcTimeStamplastSentTime ()
const UtcTimeStamplastSentTime () const
void lastReceivedTime (const UtcTimeStamp &value)
UtcTimeStamplastReceivedTime ()
const UtcTimeStamplastReceivedTime () const
bool shouldSendLogon () const
bool alreadySentLogon () const
bool logonTimedOut () const
bool logoutTimedOut () const
bool withinHeartBeat () const
bool timedOut () const
bool needHeartbeat () const
bool needTestRequest () const
std::string logoutReason () const
void logoutReason (const std::string &value)
void queue (int msgSeqNum, const Message &message)
bool retrieve (int msgSeqNum, Message &message)
void clearQueue ()
bool set (int s, const std::string &m) throw ( IOException )
void get (int b, int e, std::vector< std::string > &m) const throw ( IOException )
int getNextSenderMsgSeqNum () const throw ( IOException )
int getNextTargetMsgSeqNum () const throw ( IOException )
void setNextSenderMsgSeqNum (int n) throw ( IOException )
void setNextTargetMsgSeqNum (int n) throw ( IOException )
void incrNextSenderMsgSeqNum () throw ( IOException )
void incrNextTargetMsgSeqNum () throw ( IOException )
UtcTimeStamp getCreationTime () const throw ( IOException )
void reset () throw ( IOException )
void refresh () throw ( IOException )
void clear ()
void backup ()
void onIncoming (const std::string &string)
void onOutgoing (const std::string &string)
void onEvent (const std::string &string)

Private Types

typedef std::map< int, MessageMessages

Private Attributes

bool m_enabled
bool m_receivedLogon
bool m_sentLogout
bool m_sentLogon
bool m_sentReset
bool m_receivedReset
bool m_initiate
int m_logonTimeout
int m_logoutTimeout
int m_testRequest
ResendRange m_resendRange
HeartBtInt m_heartBtInt
UtcTimeStamp m_lastSentTime
UtcTimeStamp m_lastReceivedTime
std::string m_logoutReason
Messages m_queue
MessageStorem_pStore
Logm_pLog
NullLog m_nullLog
Mutex m_mutex

Detailed Description

Maintains all of state for the Session class.

Definition at line 37 of file SessionState.h.


Member Typedef Documentation

typedef std::map< int, Message > FIX::SessionState::Messages [private]

Definition at line 39 of file SessionState.h.

typedef std::pair<int, int> FIX::SessionState::ResendRange

Definition at line 83 of file SessionState.h.


Constructor & Destructor Documentation

Definition at line 42 of file SessionState.h.

: m_enabled( true ), m_receivedLogon( false ),
  m_sentLogout( false ), m_sentLogon( false ),
  m_sentReset( false ), m_receivedReset( false ),
  m_initiate( false ), m_logonTimeout( 10 ), 
  m_logoutTimeout( 2 ), m_testRequest( 0 ),
  m_pStore( 0 ), m_pLog( 0 ) {}

Member Function Documentation

bool FIX::SessionState::alreadySentLogon ( ) const [inline]

Definition at line 116 of file SessionState.h.

References initiate(), and sentLogon().

Referenced by FIX::Session::next().

{ return initiate() && sentLogon(); }
void FIX::SessionState::backup ( ) [inline, virtual]

Implements FIX::Log.

Definition at line 198 of file SessionState.h.

References FIX::Log::backup(), m_mutex, and m_pLog.

  { if ( !m_pLog ) return ; Locker l( m_mutex ); m_pLog->backup(); }
void FIX::SessionState::clear ( ) [inline, virtual]

Implements FIX::Log.

Definition at line 196 of file SessionState.h.

References FIX::Log::clear(), m_mutex, and m_pLog.

  { if ( !m_pLog ) return ; Locker l( m_mutex ); m_pLog->clear(); }
void FIX::SessionState::clearQueue ( ) [inline]

Definition at line 169 of file SessionState.h.

References m_mutex, and m_queue.

Referenced by FIX::Session::disconnect().

  { Locker l( m_mutex ); m_queue.clear(); }
bool FIX::SessionState::enabled ( ) const [inline]

Definition at line 50 of file SessionState.h.

References m_enabled.

Referenced by FIX::Session::isEnabled(), FIX::Session::logon(), and FIX::Session::logout().

{ return m_enabled; }
void FIX::SessionState::enabled ( bool  value) [inline]

Definition at line 51 of file SessionState.h.

References m_enabled.

{ m_enabled = value; }
void FIX::SessionState::get ( int  b,
int  e,
std::vector< std::string > &  m 
) const throw ( IOException ) [inline, virtual]

Implements FIX::MessageStore.

Definition at line 174 of file SessionState.h.

References FIX::MessageStore::get(), m_mutex, and m_pStore.

Referenced by FIX::Session::nextResendRequest().

  { Locker l( m_mutex ); m_pStore->get( b, e, m ); }
UtcTimeStamp FIX::SessionState::getCreationTime ( ) const throw ( IOException ) [inline, virtual]

Implements FIX::MessageStore.

Definition at line 189 of file SessionState.h.

References FIX::MessageStore::getCreationTime(), m_mutex, and m_pStore.

Referenced by FIX::Session::checkSessionTime().

  { Locker l( m_mutex ); return m_pStore->getCreationTime(); }
int FIX::SessionState::getNextSenderMsgSeqNum ( ) const throw ( IOException ) [inline, virtual]
int FIX::SessionState::getNextTargetMsgSeqNum ( ) const throw ( IOException ) [inline, virtual]
void FIX::SessionState::heartBtInt ( const HeartBtInt &  value) [inline]
HeartBtInt& FIX::SessionState::heartBtInt ( ) [inline]

Definition at line 96 of file SessionState.h.

References m_heartBtInt.

Referenced by needHeartbeat(), needTestRequest(), timedOut(), and withinHeartBeat().

  { return m_heartBtInt; }
const HeartBtInt& FIX::SessionState::heartBtInt ( ) const [inline]

Definition at line 98 of file SessionState.h.

References m_heartBtInt.

  { return m_heartBtInt; }
void FIX::SessionState::incrNextSenderMsgSeqNum ( ) throw ( IOException ) [inline, virtual]

Implements FIX::MessageStore.

Definition at line 185 of file SessionState.h.

References FIX::MessageStore::incrNextSenderMsgSeqNum(), m_mutex, and m_pStore.

void FIX::SessionState::incrNextTargetMsgSeqNum ( ) throw ( IOException ) [inline, virtual]
bool FIX::SessionState::initiate ( ) const [inline]
void FIX::SessionState::initiate ( bool  value) [inline]

Definition at line 69 of file SessionState.h.

References m_initiate.

{ m_initiate = value; }
void FIX::SessionState::lastReceivedTime ( const UtcTimeStamp value) [inline]

Definition at line 108 of file SessionState.h.

References m_lastReceivedTime.

Referenced by FIX::Session::generateLogon(), and FIX::Session::verify().

  { m_lastReceivedTime = value; }

Definition at line 110 of file SessionState.h.

References m_lastReceivedTime.

Referenced by logonTimedOut(), needTestRequest(), timedOut(), and withinHeartBeat().

  { return m_lastReceivedTime; }

Definition at line 112 of file SessionState.h.

References m_lastReceivedTime.

  { return m_lastReceivedTime; }
void FIX::SessionState::lastSentTime ( const UtcTimeStamp value) [inline]

Definition at line 101 of file SessionState.h.

References m_lastSentTime.

Referenced by FIX::Session::fill().

  { m_lastSentTime = value; }

Definition at line 103 of file SessionState.h.

References m_lastSentTime.

Referenced by logoutTimedOut(), needHeartbeat(), and withinHeartBeat().

  { return m_lastSentTime; }
const UtcTimeStamp& FIX::SessionState::lastSentTime ( ) const [inline]

Definition at line 105 of file SessionState.h.

References m_lastSentTime.

  { return m_lastSentTime; }
Log* FIX::SessionState::log ( ) [inline]

Definition at line 91 of file SessionState.h.

References m_nullLog, and m_pLog.

Referenced by FIX::Session::Session(), and FIX::Session::~Session().

{ return m_pLog ? m_pLog : &m_nullLog; }
void FIX::SessionState::log ( Log pValue) [inline]

Definition at line 92 of file SessionState.h.

References m_pLog.

{ m_pLog = pValue; }
bool FIX::SessionState::logonTimedOut ( ) const [inline]

Definition at line 117 of file SessionState.h.

References lastReceivedTime(), and logonTimeout().

Referenced by FIX::Session::next().

  {
    UtcTimeStamp now;
    return now - lastReceivedTime() >= logonTimeout();
  }
int FIX::SessionState::logonTimeout ( ) const [inline]

Definition at line 71 of file SessionState.h.

References m_logonTimeout.

Referenced by FIX::Session::getLogonTimeout(), logonTimedOut(), and FIX::Session::setLogonTimeout().

{ return m_logonTimeout; }
void FIX::SessionState::logonTimeout ( int  value) [inline]

Definition at line 72 of file SessionState.h.

References m_logonTimeout.

{ m_logonTimeout = value; }
std::string FIX::SessionState::logoutReason ( ) const [inline]

Definition at line 150 of file SessionState.h.

References m_logoutReason, and m_mutex.

Referenced by FIX::Session::disconnect(), FIX::Session::logon(), FIX::Session::logout(), and FIX::Session::next().

  { Locker l( m_mutex ); return m_logoutReason; }
void FIX::SessionState::logoutReason ( const std::string &  value) [inline]

Definition at line 152 of file SessionState.h.

References m_logoutReason, and m_mutex.

  { Locker l( m_mutex ); m_logoutReason = value; }
bool FIX::SessionState::logoutTimedOut ( ) const [inline]

Definition at line 122 of file SessionState.h.

References lastSentTime(), logoutTimeout(), and sentLogout().

Referenced by FIX::Session::next().

  {
    UtcTimeStamp now;
    return sentLogout() && ( ( now - lastSentTime() ) >= logoutTimeout() );
  }
int FIX::SessionState::logoutTimeout ( ) const [inline]
void FIX::SessionState::logoutTimeout ( int  value) [inline]

Definition at line 75 of file SessionState.h.

References m_logoutTimeout.

{ m_logoutTimeout = value; }
bool FIX::SessionState::needHeartbeat ( ) const [inline]

Definition at line 138 of file SessionState.h.

References heartBtInt(), lastSentTime(), and testRequest().

Referenced by FIX::Session::next().

  {
    UtcTimeStamp now;
    return ( ( now - lastSentTime() ) >= heartBtInt() ) && !testRequest();
  }
bool FIX::SessionState::needTestRequest ( ) const [inline]

Definition at line 143 of file SessionState.h.

References heartBtInt(), lastReceivedTime(), and testRequest().

Referenced by FIX::Session::next().

  {
    UtcTimeStamp now;
    return ( now - lastReceivedTime() ) >=
           ( ( 1.2 * ( ( double ) testRequest() + 1 ) ) * ( double ) heartBtInt() );
  }
void FIX::SessionState::onEvent ( const std::string &  string) [inline, virtual]
void FIX::SessionState::onIncoming ( const std::string &  string) [inline, virtual]

Implements FIX::Log.

Definition at line 200 of file SessionState.h.

References m_mutex, m_pLog, and FIX::Log::onIncoming().

Referenced by FIX::Session::next().

  { if ( !m_pLog ) return ; Locker l( m_mutex ); m_pLog->onIncoming( string ); }
void FIX::SessionState::onOutgoing ( const std::string &  string) [inline, virtual]

Implements FIX::Log.

Definition at line 202 of file SessionState.h.

References m_mutex, m_pLog, and FIX::Log::onOutgoing().

Referenced by FIX::Session::send().

  { if ( !m_pLog ) return ; Locker l( m_mutex ); m_pLog->onOutgoing( string ); }
void FIX::SessionState::queue ( int  msgSeqNum,
const Message message 
) [inline]

Definition at line 155 of file SessionState.h.

References m_mutex, and m_queue.

Referenced by FIX::Session::doTargetTooHigh().

  { Locker l( m_mutex ); m_queue[ msgSeqNum ] = message; }
bool FIX::SessionState::receivedLogon ( ) const [inline]
void FIX::SessionState::receivedLogon ( bool  value) [inline]

Definition at line 54 of file SessionState.h.

References m_receivedLogon.

{ m_receivedLogon = value; }
bool FIX::SessionState::receivedReset ( ) const [inline]
void FIX::SessionState::receivedReset ( bool  value) [inline]

Definition at line 63 of file SessionState.h.

References m_receivedReset.

{ m_receivedReset = value; }
void FIX::SessionState::refresh ( ) throw ( IOException ) [inline, virtual]

Implements FIX::MessageStore.

Definition at line 193 of file SessionState.h.

References m_mutex, m_pStore, and FIX::MessageStore::refresh().

Referenced by FIX::Session::refresh().

  { Locker l( m_mutex ); m_pStore->refresh(); }
void FIX::SessionState::resendRange ( int  begin,
int  end 
) [inline]

Definition at line 86 of file SessionState.h.

References m_resendRange.

  { m_resendRange = std::make_pair( begin, end ); }
bool FIX::SessionState::resendRequested ( ) const [inline]

Definition at line 80 of file SessionState.h.

References m_resendRange.

Referenced by FIX::Session::doTargetTooHigh(), and FIX::Session::verify().

  { return !(m_resendRange.first == 0 && m_resendRange.second == 0); }
void FIX::SessionState::reset ( ) throw ( IOException ) [inline, virtual]
bool FIX::SessionState::retrieve ( int  msgSeqNum,
Message message 
) [inline]

Definition at line 157 of file SessionState.h.

References m_mutex, and m_queue.

Referenced by FIX::Session::nextQueued().

  {
    Locker l( m_mutex );
    Messages::iterator i = m_queue.find( msgSeqNum );
    if ( i != m_queue.end() )
    {
      message = i->second;
      m_queue.erase( i );
      return true;
    }
    return false;
  }
bool FIX::SessionState::sentLogon ( ) const [inline]
void FIX::SessionState::sentLogon ( bool  value) [inline]

Definition at line 60 of file SessionState.h.

References m_sentLogon.

{ m_sentLogon = value; }
bool FIX::SessionState::sentLogout ( ) const [inline]
void FIX::SessionState::sentLogout ( bool  value) [inline]

Definition at line 57 of file SessionState.h.

References m_sentLogout.

{ m_sentLogout = value; }
bool FIX::SessionState::sentReset ( ) const [inline]
void FIX::SessionState::sentReset ( bool  value) [inline]

Definition at line 66 of file SessionState.h.

References m_sentReset.

{ m_sentReset = value; }
bool FIX::SessionState::set ( int  s,
const std::string &  m 
) throw ( IOException ) [inline, virtual]

Implements FIX::MessageStore.

Definition at line 172 of file SessionState.h.

References m_mutex, m_pStore, and FIX::MessageStore::set().

  { Locker l( m_mutex ); return m_pStore->set( s, m ); }
void FIX::SessionState::setNextSenderMsgSeqNum ( int  n) throw ( IOException ) [inline, virtual]
void FIX::SessionState::setNextTargetMsgSeqNum ( int  n) throw ( IOException ) [inline, virtual]
bool FIX::SessionState::shouldSendLogon ( ) const [inline]

Definition at line 115 of file SessionState.h.

References initiate(), and sentLogon().

Referenced by FIX::Session::next(), and FIX::Session::nextLogon().

{ return initiate() && !sentLogon(); }

Definition at line 89 of file SessionState.h.

References m_pStore.

Referenced by FIX::Session::Session(), and FIX::Session::~Session().

{ return m_pStore; }
void FIX::SessionState::store ( MessageStore pValue) [inline]

Definition at line 90 of file SessionState.h.

References m_pStore.

{ m_pStore = pValue; }
int FIX::SessionState::testRequest ( ) const [inline]
void FIX::SessionState::testRequest ( int  value) [inline]

Definition at line 78 of file SessionState.h.

References m_testRequest.

{ m_testRequest = value; }
bool FIX::SessionState::timedOut ( ) const [inline]

Definition at line 133 of file SessionState.h.

References heartBtInt(), and lastReceivedTime().

Referenced by FIX::Session::next().

  {
    UtcTimeStamp now;
    return ( now - lastReceivedTime() ) >= ( 2.4 * ( double ) heartBtInt() );
  }
bool FIX::SessionState::withinHeartBeat ( ) const [inline]

Definition at line 127 of file SessionState.h.

References heartBtInt(), lastReceivedTime(), and lastSentTime().

Referenced by FIX::Session::next().

  {
    UtcTimeStamp now;
    return ( ( now - lastSentTime() ) < heartBtInt() ) &&
           ( ( now - lastReceivedTime() ) < heartBtInt() );
  }

Member Data Documentation

Definition at line 208 of file SessionState.h.

Referenced by enabled().

HeartBtInt FIX::SessionState::m_heartBtInt [private]

Definition at line 219 of file SessionState.h.

Referenced by heartBtInt().

Definition at line 214 of file SessionState.h.

Referenced by initiate().

Definition at line 221 of file SessionState.h.

Referenced by lastReceivedTime().

Definition at line 220 of file SessionState.h.

Referenced by lastSentTime().

Definition at line 215 of file SessionState.h.

Referenced by logonTimeout().

std::string FIX::SessionState::m_logoutReason [private]

Definition at line 222 of file SessionState.h.

Referenced by logoutReason().

Definition at line 216 of file SessionState.h.

Referenced by logoutTimeout().

Mutex FIX::SessionState::m_mutex [mutable, private]

Definition at line 226 of file SessionState.h.

Referenced by log().

Definition at line 225 of file SessionState.h.

Referenced by backup(), clear(), log(), onEvent(), onIncoming(), and onOutgoing().

Definition at line 223 of file SessionState.h.

Referenced by clearQueue(), queue(), and retrieve().

Definition at line 209 of file SessionState.h.

Referenced by receivedLogon().

Definition at line 213 of file SessionState.h.

Referenced by receivedReset().

Definition at line 218 of file SessionState.h.

Referenced by resendRange(), and resendRequested().

Definition at line 211 of file SessionState.h.

Referenced by sentLogon().

Definition at line 210 of file SessionState.h.

Referenced by sentLogout().

Definition at line 212 of file SessionState.h.

Referenced by sentReset().

Definition at line 217 of file SessionState.h.

Referenced by testRequest().


The documentation for this class was generated from the following file:

Generated on Mon Sep 15 2014 01:23:57 for QuickFIX by doxygen 1.7.6.1 written by Dimitri van Heesch, © 1997-2001