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

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


Constructor & Destructor Documentation

FIX::SessionState::SessionState  )  [inline]
 

Definition at line 42 of file SessionState.h.

References m_enabled, m_initiate, m_logonTimeout, m_logoutTimeout, m_receivedLogon, m_receivedReset, m_sentLogon, m_sentLogout, m_sentReset, and m_testRequest.

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::clear  )  [inline, virtual]
 

Implements FIX::Log.

Definition at line 196 of file SessionState.h.

References FIX::Log::clear().

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.

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

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

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

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

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]
 

Definition at line 94 of file SessionState.h.

References m_heartBtInt.

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

00095   { m_heartBtInt = value; }

void FIX::SessionState::incrNextSenderMsgSeqNum  )  throw ( IOException ) [inline, virtual]
 

Implements FIX::MessageStore.

Definition at line 185 of file SessionState.h.

References FIX::MessageStore::incrNextSenderMsgSeqNum().

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

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

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

Implements FIX::MessageStore.

Definition at line 187 of file SessionState.h.

References FIX::MessageStore::incrNextTargetMsgSeqNum().

Referenced by FIX::Session::generateBusinessReject(), FIX::Session::generateReject(), FIX::Session::next(), FIX::Session::nextHeartbeat(), FIX::Session::nextLogon(), FIX::Session::nextLogout(), FIX::Session::nextQueued(), FIX::Session::nextReject(), FIX::Session::nextResendRequest(), and FIX::Session::nextTestRequest().

00188   { Locker l( m_mutex ); m_pStore->incrNextTargetMsgSeqNum(); }

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]
 

Definition at line 68 of file SessionState.h.

References m_initiate.

Referenced by alreadySentLogon(), FIX::Session::nextLogon(), FIX::Session::Session(), and shouldSendLogon().

00068 { return m_initiate; }

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.

00092 { m_pLog = pValue; }

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

Definition at line 91 of file SessionState.h.

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

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.

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

Implements FIX::Log.

Definition at line 202 of file SessionState.h.

References FIX::Log::onEvent().

Referenced by FIX::Session::disconnect(), FIX::Session::doTargetTooHigh(), FIX::Session::generateBusinessReject(), FIX::Session::generateReject(), FIX::Session::generateResendRequest(), FIX::Session::next(), FIX::Session::nextLogon(), FIX::Session::nextLogout(), FIX::Session::nextQueued(), FIX::Session::nextResendRequest(), FIX::Session::nextSequenceReset(), FIX::Session::sendRaw(), FIX::Session::Session(), and FIX::Session::verify().

00203   { if ( !m_pLog ) return ; Locker l( m_mutex ); m_pLog->onEvent( string ); }

void FIX::SessionState::onIncoming const std::string &  string  )  [inline, virtual]
 

Implements FIX::Log.

Definition at line 198 of file SessionState.h.

References FIX::Log::onIncoming().

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

00199   { 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 200 of file SessionState.h.

References FIX::Log::onOutgoing().

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

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

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]
 

Definition at line 53 of file SessionState.h.

References m_receivedLogon.

Referenced by FIX::Session::disconnect(), FIX::Session::generateReject(), FIX::Session::next(), FIX::Session::nextLogon(), FIX::Session::receivedLogon(), and FIX::Session::validLogonState().

00053 { return m_receivedLogon; }

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]
 

Definition at line 62 of file SessionState.h.

References m_receivedReset.

Referenced by FIX::Session::disconnect(), FIX::Session::generateLogon(), FIX::Session::nextLogon(), FIX::Session::sendRaw(), and FIX::Session::validLogonState().

00062 { return m_receivedReset; }

void FIX::SessionState::refresh  )  throw ( IOException ) [inline, virtual]
 

Implements FIX::MessageStore.

Definition at line 193 of file SessionState.h.

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

Definition at line 85 of file SessionState.h.

References m_resendRange, and ResendRange.

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

00085 { return m_resendRange; }

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]
 

Implements FIX::MessageStore.

Definition at line 191 of file SessionState.h.

References FIX::MessageStore::reset().

Referenced by FIX::Session::disconnect(), FIX::Session::generateLogon(), FIX::Session::nextLogon(), FIX::Session::nextLogout(), FIX::Session::reset(), and FIX::Session::sendRaw().

00192   { Locker l( m_mutex ); m_pStore->reset(); }

bool FIX::SessionState::retreive int  msgSeqNum,
Message message
[inline]
 

Definition at line 157 of file SessionState.h.

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]
 

Definition at line 59 of file SessionState.h.

References m_sentLogon.

Referenced by alreadySentLogon(), FIX::Session::disconnect(), FIX::Session::generateLogon(), FIX::Session::sentLogon(), shouldSendLogon(), and FIX::Session::validLogonState().

00059 { return m_sentLogon; }

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]
 

Definition at line 56 of file SessionState.h.

References m_sentLogout.

Referenced by FIX::Session::disconnect(), FIX::Session::generateLogout(), logoutTimedOut(), FIX::Session::next(), FIX::Session::nextLogout(), FIX::Session::sentLogout(), and FIX::Session::validLogonState().

00056 { return m_sentLogout; }

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]
 

Definition at line 65 of file SessionState.h.

References m_sentReset.

Referenced by FIX::Session::disconnect(), FIX::Session::nextLogon(), FIX::Session::sendRaw(), and FIX::Session::validLogonState().

00065 { return m_sentReset; }

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 FIX::MessageStore::set().

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

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

00090 { m_pStore = pValue; }

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

Definition at line 89 of file SessionState.h.

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]
 

Definition at line 77 of file SessionState.h.

References m_testRequest.

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

00077 { return m_testRequest; }

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

bool FIX::SessionState::m_enabled [private]
 

Definition at line 206 of file SessionState.h.

Referenced by enabled(), and SessionState().

HeartBtInt FIX::SessionState::m_heartBtInt [private]
 

Definition at line 217 of file SessionState.h.

Referenced by heartBtInt().

bool FIX::SessionState::m_initiate [private]
 

Definition at line 212 of file SessionState.h.

Referenced by initiate(), and SessionState().

UtcTimeStamp FIX::SessionState::m_lastReceivedTime [private]