![]() |
![]() |
|
Index
Source Files
Annotated Class List
Alphabetical Class List
Class Hierarchy
Graphical Class Hierarchy
|
||
![]() |
![]() |
#include <Initiator.h>
Inheritance diagram for FIX::Initiator:


Public Member Functions | |
| Initiator (Application &, MessageStoreFactory &, const SessionSettings &) throw ( ConfigError ) | |
| Initiator (Application &, MessageStoreFactory &, const SessionSettings &, LogFactory &) throw ( ConfigError ) | |
| virtual | ~Initiator () |
| void | start () throw ( ConfigError, RuntimeError ) |
| Start initiator. | |
| void | block () throw ( ConfigError, RuntimeError ) |
| Block on the initiator. | |
| bool | poll () throw ( ConfigError, RuntimeError ) |
| Poll the initiator. | |
| void | stop (bool force=false) |
| Stop initiator. | |
| bool | isLoggedOn () |
| Check to see if any sessions are currently logged on. | |
| Session * | getSession (const SessionID &sessionID, Responder &) |
| const std::set< SessionID > | getSessions () const |
| bool | has (const SessionID &id) |
| bool | isStopped () |
| Application & | getApplication () |
| MessageStoreFactory & | getMessageStoreFactory () |
Protected Member Functions | |
| void | setPending (const SessionID &) |
| void | setConnected (const SessionID &) |
| void | setDisconnected (const SessionID &) |
| bool | isPending (const SessionID &) |
| bool | isConnected (const SessionID &) |
| bool | isDisconnected (const SessionID &) |
| void | connect () |
Private Types | |
| typedef std::set< SessionID > | SessionIDs |
| typedef std::map< SessionID, int > | SessionState |
| typedef std::map< SessionID, Session * > | Sessions |
Private Member Functions | |
| void | initialize () throw ( ConfigError ) |
| virtual void | onConfigure (const SessionSettings &) throw ( ConfigError ) |
| Implemented to configure acceptor. | |
| virtual void | onInitialize (const SessionSettings &) throw ( RuntimeError ) |
| Implemented to initialize initiator. | |
| virtual void | onStart ()=0 |
| Implemented to start connecting to targets. | |
| virtual bool | onPoll ()=0 |
| Implemented to connect and poll for events. | |
| virtual void | onStop ()=0 |
| Implemented to stop a running initiator. | |
| virtual bool | doConnect (const SessionID &, const Dictionary &)=0 |
| Implemented to connect a session to its target. | |
Static Private Member Functions | |
| THREAD_PROC | startThread (void *p) |
Private Attributes | |
| Sessions | m_sessions |
| SessionIDs | m_sessionIDs |
| SessionIDs | m_pending |
| SessionIDs | m_connected |
| SessionIDs | m_disconnected |
| SessionState | m_sessionState |
| unsigned | m_threadid |
| Application & | m_application |
| MessageStoreFactory & | m_messageStoreFactory |
| SessionSettings | m_settings |
| LogFactory * | m_pLogFactory |
| bool | m_firstPoll |
| bool | m_stop |
| Mutex | m_mutex |
Most users will not need to implement one of these. The default SocketInitiator implementation will be used in most cases.
Definition at line 51 of file Initiator.h.
|
|
Definition at line 115 of file Initiator.h. |
|
|
Definition at line 117 of file Initiator.h. |
|
|
Definition at line 116 of file Initiator.h. |
|
||||||||||||||||
|
Definition at line 36 of file Initiator.cpp.
00039 : m_threadid( 0 ), 00040 m_application( application ), 00041 m_messageStoreFactory( messageStoreFactory ), 00042 m_settings( settings ), 00043 m_pLogFactory( 0 ), 00044 m_stop( false ) 00045 { initialize(); } |
|
||||||||||||||||||||
|
Definition at line 47 of file Initiator.cpp.
00051 : m_threadid( 0 ), 00052 m_application( application ), 00053 m_messageStoreFactory( messageStoreFactory ), 00054 m_settings( settings ), 00055 m_pLogFactory( &logFactory ), 00056 m_stop( false ) 00057 { initialize(); } |
|
|
Definition at line 87 of file Initiator.cpp. References QF_STACK_IGNORE_BEGIN, and QF_STACK_IGNORE_END.
00088 { QF_STACK_IGNORE_BEGIN
00089
00090 Sessions::iterator i;
00091 for ( i = m_sessions.begin(); i != m_sessions.end(); ++i )
00092 delete i->second;
00093
00094 QF_STACK_IGNORE_END
00095 }
|
|
|
Block on the initiator.
Definition at line 206 of file Initiator.cpp. References QF_STACK_POP, and QF_STACK_PUSH.
00207 { QF_STACK_PUSH(Initiator::block)
00208
00209 onConfigure( m_settings );
00210 onInitialize( m_settings );
00211
00212 startThread(this);
00213
00214 QF_STACK_POP
00215 }
|
|
|
Definition at line 112 of file Initiator.cpp. References doConnect(), FIX::SessionSettings::get(), FIX::Session::isEnabled(), FIX::Session::isSessionTime(), m_disconnected, QF_STACK_POP, and QF_STACK_PUSH. Referenced by FIX::ThreadedSocketInitiator::onStart(), FIX::SocketInitiator::onStart(), and FIX::SocketInitiator::onTimeout().
00113 { QF_STACK_PUSH(Initiator::connect)
00114
00115 Locker l(m_mutex);
00116
00117 SessionIDs disconnected = m_disconnected;
00118 SessionIDs::iterator i = disconnected.begin();
00119 for ( ; i != disconnected.end(); ++i )
00120 {
00121 Session* pSession = Session::lookupSession( *i );
00122 if ( pSession->isEnabled() && pSession->isSessionTime() )
00123 doConnect( *i, m_settings.get( *i ));
00124 }
00125
00126 QF_STACK_POP
00127 }
|
|
||||||||||||
|
Implemented to connect a session to its target.
Implemented in FIX::SocketInitiator, and FIX::ThreadedSocketInitiator. Referenced by connect(). |
|
|
Definition at line 83 of file Initiator.h. Referenced by FIX::ThreadedSocketInitiator::doConnect().
00083 { return m_application; }
|
|
|
Definition at line 84 of file Initiator.h.
00085 { return m_messageStoreFactory; }
|
|
||||||||||||
|
Definition at line 97 of file Initiator.cpp. References QF_STACK_POP, and QF_STACK_PUSH.
00099 { QF_STACK_PUSH(Initiator::getSession)
00100
00101 Sessions::iterator i = m_sessions.find( sessionID );
00102 if ( i != m_sessions.end() )
00103 {
00104 i->second->setResponder( &responder );
00105 return i->second;
00106 }
00107 return 0;
00108
00109 QF_STACK_POP
00110 }
|
|
|
Definition at line 75 of file Initiator.h.
00075 { return m_sessionIDs; }
|
|
|
Definition at line 77 of file Initiator.h.
00078 { return m_sessions.find( id ) != m_sessions.end(); }
|
|
|
Definition at line 59 of file Initiator.cpp. References FIX::SessionFactory::create(), QF_STACK_POP, and QF_STACK_PUSH.
00060 { QF_STACK_PUSH(Initiator::initialize)
00061
00062 std::set < SessionID > sessions = m_settings.getSessions();
00063 std::set < SessionID > ::iterator i;
00064
00065 if ( !sessions.size() )
00066 throw ConfigError( "No sessions defined" );
00067
00068 SessionFactory factory( m_application, m_messageStoreFactory,
00069 m_pLogFactory );
00070
00071 for ( i = sessions.begin(); i != sessions.end(); ++i )
00072 {
00073 if ( m_settings.get( *i ).getString( "ConnectionType" ) == "initiator" )
00074 {
00075 m_sessionIDs.insert( *i );
00076 m_sessions[ *i ] = factory.create( *i, m_settings.get( *i ) );
00077 setDisconnected( *i );
00078 }
00079 }
00080
00081 if ( !m_sessions.size() )
00082 throw ConfigError( "No sessions defined for initiator" );
00083
00084 QF_STACK_POP
00085 }
|
|
|
Definition at line 174 of file Initiator.cpp. References m_connected, QF_STACK_POP, and QF_STACK_PUSH.
00175 { QF_STACK_PUSH(Initiator::isConnected)
00176
00177 Locker l(m_mutex);
00178 return m_connected.find( sessionID ) != m_connected.end();
00179
00180 QF_STACK_POP
00181 }
|
|
|
Definition at line 183 of file Initiator.cpp. References m_disconnected, QF_STACK_POP, and QF_STACK_PUSH.
00184 { QF_STACK_PUSH(Initiator::isDisconnected)
00185
00186 Locker l(m_mutex);
00187 return m_disconnected.find( sessionID ) != m_disconnected.end();
00188
00189 QF_STACK_POP
00190 }
|
|
|
Check to see if any sessions are currently logged on.
Definition at line 276 of file Initiator.cpp. References m_connected, QF_STACK_POP, and QF_STACK_PUSH. Referenced by FIX::SocketInitiator::onPoll(), FIX::SocketInitiator::onStart(), FIX::ThreadedSocketInitiator::onStop(), and stop().
00277 { QF_STACK_PUSH(Initiator::isLoggedOn)
00278
00279 Locker l(m_mutex);
00280
00281 SessionIDs connected = m_connected;
00282 SessionIDs::iterator i = connected.begin();
00283 for ( ; i != connected.end(); ++i )
00284 {
00285 if( Session::lookupSession(*i)->isLoggedOn() )
00286 return true;
00287 }
00288 return false;
00289
00290 QF_STACK_POP
00291 }
|
|
|
Definition at line 165 of file Initiator.cpp. References m_pending, QF_STACK_POP, and QF_STACK_PUSH.
00166 { QF_STACK_PUSH(Initiator::isPending)
00167
00168 Locker l(m_mutex);
00169 return m_pending.find( sessionID ) != m_pending.end();
00170
00171 QF_STACK_POP
00172 }
|
|
|
Definition at line 80 of file Initiator.h. Referenced by FIX::SocketInitiator::onPoll(), FIX::ThreadedSocketInitiator::onStart(), FIX::SocketInitiator::onStart(), FIX::ThreadedSocketInitiator::socketThread(), and stop().
00080 { return m_stop; }
|
|
|
Implemented to configure acceptor.
Reimplemented in FIX::SocketInitiator, and FIX::ThreadedSocketInitiator. Definition at line 101 of file Initiator.h.
00101 {};
|
|
|
Implemented to initialize initiator.
Reimplemented in FIX::SocketInitiator, and FIX::ThreadedSocketInitiator. Definition at line 103 of file Initiator.h.
00103 {};
|
|
|
Implemented to connect and poll for events.
Implemented in FIX::SocketInitiator, and FIX::ThreadedSocketInitiator. |
|
|
Implemented to start connecting to targets.
Implemented in FIX::SocketInitiator, and FIX::ThreadedSocketInitiator. |
|
|
Implemented to stop a running initiator.
Implemented in FIX::SocketInitiator, and FIX::ThreadedSocketInitiator. Referenced by stop(). |
|
|
Poll the initiator.
Definition at line 217 of file Initiator.cpp. References QF_STACK_POP, and QF_STACK_PUSH.
00218 { QF_STACK_PUSH(Initiator::poll)
00219
00220 if( m_firstPoll )
00221 {
00222 onConfigure( m_settings );
00223 onInitialize( m_settings );
00224 m_firstPoll = false;
00225 }
00226
00227 return onPoll();
00228
00229 QF_STACK_POP
00230 }
|
|
|
Definition at line 141 of file Initiator.cpp. References m_connected, m_disconnected, m_pending, QF_STACK_POP, and QF_STACK_PUSH. Referenced by FIX::SocketInitiator::onConnect(), and FIX::ThreadedSocketInitiator::socketThread().
00142 { QF_STACK_PUSH(Initiator::setConnected)
00143
00144 Locker l(m_mutex);
00145
00146 m_pending.erase( sessionID );
00147 m_connected.insert( sessionID );
00148 m_disconnected.erase( sessionID );
00149
00150 QF_STACK_POP
00151 }
|
|
|
Definition at line 153 of file Initiator.cpp. References m_connected, m_disconnected, m_pending, QF_STACK_POP, and QF_STACK_PUSH. Referenced by FIX::SocketInitiator::onDisconnect(), FIX::ThreadedSocketInitiator::socketThread(), and stop().
00154 { QF_STACK_PUSH(Initiator::setDisconnected)
00155
00156 Locker l(m_mutex);
00157
00158 m_pending.erase( sessionID );
00159 m_connected.erase( sessionID );
00160 m_disconnected.insert( sessionID );
00161
00162 QF_STACK_POP
00163 }
|
|
|
Definition at line 129 of file Initiator.cpp. References m_connected, m_disconnected, m_pending, QF_STACK_POP, and QF_STACK_PUSH. Referenced by FIX::SocketInitiator::doConnect().
00130 { QF_STACK_PUSH(Initiator::setPending)
00131
00132 Locker l(m_mutex);
00133
00134 m_pending.insert( sessionID );
00135 m_connected.erase( sessionID );
00136 m_disconnected.erase( sessionID );
00137
00138 QF_STACK_POP
00139 }
|
|
|
Start initiator.
Definition at line 192 of file Initiator.cpp. References QF_STACK_POP, QF_STACK_PUSH, and FIX::thread_spawn().
00193 { QF_STACK_PUSH(Initiator::start)
00194
00195 m_stop = false;
00196 onConfigure( m_settings );
00197 onInitialize( m_settings );
00198
00199 if( !thread_spawn( &startThread, this, m_threadid ) )
00200 throw RuntimeError("Unable to spawn thread");
00201
00202 QF_STACK_POP
00203 }
|
|
|
Definition at line 293 of file Initiator.cpp. References QF_STACK_CATCH, QF_STACK_POP, QF_STACK_PUSH, QF_STACK_TRY, and THREAD_PROC.
00294 { QF_STACK_TRY
00295 QF_STACK_PUSH(Initiator::startThread)
00296
00297 Initiator * pInitiator = static_cast < Initiator* > ( p );
00298 pInitiator->onStart();
00299 return 0;
00300
00301 QF_STACK_POP
00302 QF_STACK_CATCH
00303 }
|
|
|
Stop initiator.
Definition at line 232 of file Initiator.cpp. References FIX::Session::isEnabled(), isLoggedOn(), isStopped(), FIX::Session::logout(), m_connected, onStop(), FIX::process_sleep(), QF_STACK_POP, QF_STACK_PUSH, setDisconnected(), and FIX::thread_join().
00233 { QF_STACK_PUSH(Initiator::stop)
00234
00235 if( isStopped() ) return;
00236
00237 std::vector<Session*> enabledSessions;
00238
00239 SessionIDs connected = m_connected;
00240 SessionIDs::iterator i = connected.begin();
00241 for ( ; i != connected.end(); ++i )
00242 {
00243 Session* pSession = Session::lookupSession(*i);
00244 if( pSession->isEnabled() )
00245 {
00246 enabledSessions.push_back( pSession );
00247 pSession->logout();
00248 }
00249 }
00250
00251 if( !force )
00252 {
00253 for ( int second = 1; second <= 10 && isLoggedOn(); ++second )
00254 process_sleep( 1 );
00255 }
00256
00257 {
00258 Locker l(m_mutex);
00259 for ( i = connected.begin(); i != connected.end(); ++i )
00260 setDisconnected( Session::lookupSession(*i)->getSessionID() );
00261 }
00262
00263 m_stop = true;
00264 onStop();
00265 if( m_threadid )
00266 thread_join( m_threadid );
00267 m_threadid = 0;
00268
00269 std::vector<Session*>::iterator session = enabledSessions.begin();
00270 for( ; session != enabledSessions.end(); ++session )
00271 (*session)->logon();
00272
00273 QF_STACK_POP
00274 }
|
|
|
Definition at line 127 of file Initiator.h. |
|
|
Definition at line 122 of file Initiator.h. Referenced by isConnected(), isLoggedOn(), setConnected(), setDisconnected(), setPending(), and stop(). |
|
|
Definition at line 123 of file Initiator.h. Referenced by connect(), isDisconnected(), setConnected(), setDisconnected(), and setPending(). |
|
|
Definition at line 131 of file Initiator.h. |
|
|
Definition at line 128 of file Initiator.h. |
|
|
Reimplemented in FIX::ThreadedSocketInitiator. Definition at line 133 of file Initiator.h. |
|
|
Definition at line 121 of file Initiator.h. Referenced by isPending(), setConnected(), setDisconnected(), and setPending(). |
|
|
Definition at line 130 of file Initiator.h. |
|
|
Definition at line 120 of file Initiator.h. |
|
|
Definition at line 119 of file Initiator.h. |
|
|
Definition at line 124 of file Initiator.h. |
|
|
Reimplemented in FIX::SocketInitiator, and FIX::ThreadedSocketInitiator. Definition at line 129 of file Initiator.h. |
|
|
Reimplemented in FIX::SocketInitiator, and FIX::ThreadedSocketInitiator. Definition at line 132 of file Initiator.h. |
|
|
Definition at line 126 of file Initiator.h. |
1.3.6-20040222 written by Dimitri van Heesch,
© 1997-2001