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

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
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

FIX::SessionState::SessionState (  )  [inline]

Definition at line 42 of file SessionState.h.

00043 : m_enabled( true ), m_receivedLogon( false ),
00044   m_sentLogout( false ), m_sentLogon( false ),
00045   m_sentReset( false ), m_receivedReset( false ),
00046   m_initiate( false ), m_logonTimeout( 10 ), 
00047   m_logoutTimeout( 2 ), m_testRequest( 0 ),
00048   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().

00116 { 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.

00199   { 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.

00197   { 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().

00170   { Locker l( m_mutex ); m_queue.clear(); }

void FIX::SessionState::enabled ( bool  value  )  [inline]

Definition at line 51 of file SessionState.h.

References m_enabled.

00051 { m_enabled = value; }

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().

00050 { return m_enabled; }

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().

00176   { 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().

00190   { Locker l( m_mutex ); return m_pStore->getCreationTime(); }

int FIX::SessionState::getNextSenderMsgSeqNum (  )  const throw ( IOException ) [inline, virtual]

Implements FIX::MessageStore.

Definition at line 177 of file SessionState.h.

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

Referenced by FIX::Session::getExpectedSenderNum(), and FIX::Session::nextResendRequest().

00178   { Locker l( m_mutex ); return m_pStore->getNextSenderMsgSeqNum(); }

int FIX::SessionState::getNextTargetMsgSeqNum (  )  const throw ( IOException ) [inline, virtual]

Implements FIX::MessageStore.

Definition at line 179 of file SessionState.h.

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

Referenced by FIX::Session::getExpectedTargetNum(), FIX::Session::isTargetTooHigh(), and FIX::Session::isTargetTooLow().

00180   { Locker l( m_mutex ); return m_pStore->getNextTargetMsgSeqNum(); }

const HeartBtInt& FIX::SessionState::heartBtInt (  )  const [inline]

Definition at line 98 of file SessionState.h.

References m_heartBtInt.

00099   { return m_heartBtInt; }

HeartBtInt& FIX::SessionState::heartBtInt (  )  [inline]

Definition at line 96 of file SessionState.h.

References m_heartBtInt.

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

00097   { return m_heartBtInt; }

void FIX::SessionState::heartBtInt ( const HeartBtInt &  value  )  [inline]
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.

00186   { Locker l( m_mutex ); m_pStore->incrNextSenderMsgSeqNum(); }

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

Definition at line 69 of file SessionState.h.

References m_initiate.

00069 { m_initiate = value; }

bool FIX::SessionState::initiate (  )  const [inline]
const UtcTimeStamp& FIX::SessionState::lastReceivedTime (  )  const [inline]

Definition at line 112 of file SessionState.h.

References m_lastReceivedTime.

00113   { return m_lastReceivedTime; }

UtcTimeStamp& FIX::SessionState::lastReceivedTime (  )  [inline]

Definition at line 110 of file SessionState.h.

References m_lastReceivedTime.

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

00111   { return m_lastReceivedTime; }

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().

00109   { m_lastReceivedTime = value; }

const UtcTimeStamp& FIX::SessionState::lastSentTime (  )  const [inline]

Definition at line 105 of file SessionState.h.

References m_lastSentTime.

00106   { return m_lastSentTime; }

UtcTimeStamp& FIX::SessionState::lastSentTime (  )  [inline]

Definition at line 103 of file SessionState.h.

References m_lastSentTime.

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

00104   { return m_lastSentTime; }

void FIX::SessionState::lastSentTime ( const UtcTimeStamp value  )  [inline]

Definition at line 101 of file SessionState.h.

References m_lastSentTime.

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

00102   { m_lastSentTime = value; }

void FIX::SessionState::log ( Log pValue  )  [inline]

Definition at line 92 of file SessionState.h.

References m_pLog.

00092 { m_pLog = pValue; }

Log* FIX::SessionState::log (  )  [inline]

Definition at line 91 of file SessionState.h.

References m_pLog.

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

00091 { return m_pLog; }

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

Definition at line 117 of file SessionState.h.

References lastReceivedTime(), and logonTimeout().

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

00118   {
00119     UtcTimeStamp now;
00120     return now - lastReceivedTime() >= logonTimeout();
00121   }

void FIX::SessionState::logonTimeout ( int  value  )  [inline]

Definition at line 72 of file SessionState.h.

References m_logonTimeout.

00072 { m_logonTimeout = value; }

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().

00071 { return m_logonTimeout; }

void FIX::SessionState::logoutReason ( const std::string &  value  )  [inline]

Definition at line 152 of file SessionState.h.

References m_logoutReason, and m_mutex.

00153   { Locker l( m_mutex ); m_logoutReason = 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().

00151   { Locker l( m_mutex ); return m_logoutReason; }

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

Definition at line 122 of file SessionState.h.

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

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

00123   {
00124     UtcTimeStamp now;
00125     return sentLogout() && ( ( now - lastSentTime() ) >= logoutTimeout() );
00126   }

void FIX::SessionState::logoutTimeout ( int  value  )  [inline]

Definition at line 75 of file SessionState.h.

References m_logoutTimeout.

00075 { m_logoutTimeout = value; }

int FIX::SessionState::logoutTimeout (  )  const [inline]

Definition at line 74 of file SessionState.h.

References m_logoutTimeout.

Referenced by FIX::Session::getLogoutTimeout(), logoutTimedOut(), and FIX::Session::setLogoutTimeout().

00074 { return m_logoutTimeout; }

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

Definition at line 138 of file SessionState.h.

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

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

00139   {
00140     UtcTimeStamp now;
00141     return ( ( now - lastSentTime() ) >= heartBtInt() ) && !testRequest();
00142   }

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

Definition at line 143 of file SessionState.h.

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

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

00144   {
00145     UtcTimeStamp now;
00146     return ( now - lastReceivedTime() ) >=
00147            ( ( 1.2 * ( ( double ) testRequest() + 1 ) ) * ( double ) heartBtInt() );
00148   }

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().

00201   { 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().

00203   { 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().

00156   { Locker l( m_mutex ); m_queue[ msgSeqNum ] = message; }

void FIX::SessionState::receivedLogon ( bool  value  )  [inline]

Definition at line 54 of file SessionState.h.

References m_receivedLogon.

00054 { m_receivedLogon = value; }

bool FIX::SessionState::receivedLogon (  )  const [inline]
void FIX::SessionState::receivedReset ( bool  value  )  [inline]

Definition at line 63 of file SessionState.h.

References m_receivedReset.

00063 { m_receivedReset = value; }

bool FIX::SessionState::receivedReset (  )  const [inline]
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().

00194   { 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.

00087   { m_resendRange = std::make_pair( begin, end ); }

ResendRange FIX::SessionState::resendRange (  )  const [inline]
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().

00081   { 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().

00158   {
00159     Locker l( m_mutex );
00160     Messages::iterator i = m_queue.find( msgSeqNum );
00161     if ( i != m_queue.end() )
00162     {
00163       message = i->second;
00164       m_queue.erase( i );
00165       return true;
00166     }
00167     return false;
00168   }

void FIX::SessionState::sentLogon ( bool  value  )  [inline]

Definition at line 60 of file SessionState.h.

References m_sentLogon.

00060 { m_sentLogon = value; }

bool FIX::SessionState::sentLogon (  )  const [inline]
void FIX::SessionState::sentLogout ( bool  value  )  [inline]

Definition at line 57 of file SessionState.h.

References m_sentLogout.

00057 { m_sentLogout = value; }

bool FIX::SessionState::sentLogout (  )  const [inline]
void FIX::SessionState::sentReset ( bool  value  )  [inline]

Definition at line 66 of file SessionState.h.

References m_sentReset.

00066 { m_sentReset = value; }

bool FIX::SessionState::sentReset (  )  const [inline]
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().

00173   { Locker l( m_mutex ); return m_pStore->set( s, m ); }

void FIX::SessionState::setNextSenderMsgSeqNum ( int  n  )  throw ( IOException ) [inline, virtual]

Implements FIX::MessageStore.

Definition at line 181 of file SessionState.h.

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

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

00182   { Locker l( m_mutex ); m_pStore->setNextSenderMsgSeqNum( n ); }

void FIX::SessionState::setNextTargetMsgSeqNum ( int  n  )  throw ( IOException ) [inline, virtual]

Implements FIX::MessageStore.

Definition at line 183 of file SessionState.h.

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

Referenced by FIX::Session::nextSequenceReset(), and FIX::Session::setNextTargetMsgSeqNum().

00184   { Locker l( m_mutex ); m_pStore->setNextTargetMsgSeqNum( n ); }

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().

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

void FIX::SessionState::store ( MessageStore pValue  )  [inline]

Definition at line 90 of file SessionState.h.

References m_pStore.

00090 { m_pStore = pValue; }

MessageStore* FIX::SessionState::store (  )  [inline]

Definition at line 89 of file SessionState.h.

References m_pStore.

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

00089 { return m_pStore; }

void FIX::SessionState::testRequest ( int  value  )  [inline]

Definition at line 78 of file SessionState.h.

References m_testRequest.

00078 { m_testRequest = value; }

int FIX::SessionState::testRequest (  )  const [inline]
bool FIX::SessionState::timedOut (  )  const [inline]

Definition at line 133 of file SessionState.h.

References heartBtInt(), and lastReceivedTime().

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

00134   {
00135     UtcTimeStamp now;
00136     return ( now - lastReceivedTime() ) >= ( 2.4 * ( double ) heartBtInt() );
00137   }

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

Definition at line 127 of file SessionState.h.

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

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

00128   {
00129     UtcTimeStamp now;
00130     return ( ( now - lastSentTime() ) < heartBtInt() ) &&
00131            ( ( now - lastReceivedTime() ) < heartBtInt() );
00132   }


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 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 Apr 5 21:00:10 2010 for QuickFIX by doxygen 1.6.1 written by Dimitri van Heesch, © 1997-2001