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


Public Member Functions | |
| Acceptor (Application &, MessageStoreFactory &, const SessionSettings &) throw ( ConfigError ) | |
| Acceptor (Application &, MessageStoreFactory &, const SessionSettings &, LogFactory &) throw ( ConfigError ) | |
| virtual | ~Acceptor () |
| void | start () throw ( ConfigError, RuntimeError ) |
| Start acceptor. | |
| void | block () throw ( ConfigError, RuntimeError ) |
| Block on the acceptor. | |
| bool | poll () throw ( ConfigError, RuntimeError ) |
| Poll the acceptor. | |
| void | stop (bool force=false) |
| Stop acceptor. | |
| bool | isLoggedOn () |
| Check to see if any sessions are currently logged on. | |
| Session * | getSession (const std::string &msg, Responder &) |
| const std::set< SessionID > | getSessions () const |
| bool | has (const SessionID &id) |
| bool | isStopped () |
| Application & | getApplication () |
| MessageStoreFactory & | getMessageStoreFactory () |
Protected Member Functions | |
| void | log (const std::string &text) |
Private Types | |
| typedef std::set< SessionID > | SessionIDs |
| 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 acceptor. | |
| virtual void | onStart ()=0 |
| Implemented to start listening for connections. | |
| virtual bool | onPoll ()=0 |
| Implemented to connect and poll for events. | |
| virtual void | onStop ()=0 |
| Implemented to stop a running acceptor. | |
Static Private Member Functions | |
| THREAD_PROC | startThread (void *p) |
Private Attributes | |
| unsigned | m_threadid |
| Sessions | m_sessions |
| SessionIDs | m_sessionIDs |
| Application & | m_application |
| MessageStoreFactory & | m_messageStoreFactory |
| SessionSettings | m_settings |
| LogFactory * | m_pLogFactory |
| Log * | m_pLog |
| bool | m_firstPoll |
| bool | m_stop |
Most users will not need to implement one of these. The default SocketAcceptor implementation will be used in most cases.
Definition at line 49 of file Acceptor.h.
|
|
Definition at line 104 of file Acceptor.h. |
|
|
Reimplemented in FIX::SocketAcceptor, and FIX::ThreadedSocketAcceptor. Definition at line 105 of file Acceptor.h. Referenced by isLoggedOn(), and stop(). |
|
||||||||||||||||
|
Definition at line 36 of file Acceptor.cpp.
00040 : m_threadid( 0 ), 00041 m_application( application ), 00042 m_messageStoreFactory( messageStoreFactory ), 00043 m_settings( settings ), 00044 m_pLogFactory( 0 ), 00045 m_pLog( 0 ), 00046 m_firstPoll( true ), 00047 m_stop( false ) 00048 { 00049 initialize(); 00050 } |
|
||||||||||||||||||||
|
Definition at line 52 of file Acceptor.cpp.
00057 : m_threadid( 0 ), 00058 m_application( application ), 00059 m_messageStoreFactory( messageStoreFactory ), 00060 m_settings( settings ), 00061 m_pLogFactory( &logFactory ), 00062 m_pLog( logFactory.create() ), 00063 m_firstPoll( true ), 00064 m_stop( false ) 00065 { 00066 initialize(); 00067 } |
|
|
Definition at line 96 of file Acceptor.cpp. References FIX::LogFactory::destroy(), m_pLog, m_pLogFactory, m_sessions, QF_STACK_IGNORE_BEGIN, and QF_STACK_IGNORE_END.
00097 { QF_STACK_IGNORE_BEGIN
00098
00099 Sessions::iterator i;
00100 for ( i = m_sessions.begin(); i != m_sessions.end(); ++i )
00101 delete i->second;
00102
00103 if( m_pLogFactory && m_pLog )
00104 m_pLogFactory->destroy( m_pLog );
00105
00106 QF_STACK_IGNORE_END
00107 }
|
|
|
Block on the acceptor.
Definition at line 159 of file Acceptor.cpp. References QF_STACK_POP, and QF_STACK_PUSH.
00160 { QF_STACK_PUSH( Acceptor::start )
00161
00162 onConfigure( m_settings );
00163 onInitialize( m_settings );
00164
00165 startThread(this);
00166
00167 QF_STACK_POP
00168 }
|
|
|
Definition at line 80 of file Acceptor.h. References m_application. Referenced by FIX::ThreadedSocketAcceptor::socketAcceptorThread().
00080 { return m_application; }
|
|
|
Definition at line 81 of file Acceptor.h. References m_messageStoreFactory.
00082 { return m_messageStoreFactory; }
|
|
||||||||||||
|
Definition at line 110 of file Acceptor.cpp. References FIX::FieldMap::getField(), FIX::Message::getHeader(), QF_STACK_POP, QF_STACK_PUSH, and FIX::Message::setStringHeader(). Referenced by FIX::SocketConnection::read().
00111 { QF_STACK_PUSH( Acceptor::getSession )
00112
00113 Message message;
00114 if ( !message.setStringHeader( msg ) )
00115 return 0;
00116
00117 BeginString beginString;
00118 SenderCompID clSenderCompID;
00119 TargetCompID clTargetCompID;
00120 MsgType msgType;
00121 try
00122 {
00123 message.getHeader().getField( beginString );
00124 message.getHeader().getField( clSenderCompID );
00125 message.getHeader().getField( clTargetCompID );
00126 message.getHeader().getField( msgType );
00127 if ( msgType != "A" ) return 0;
00128
00129 SenderCompID senderCompID( clTargetCompID );
00130 TargetCompID targetCompID( clSenderCompID );
00131 SessionID sessionID( beginString, senderCompID, targetCompID );
00132
00133 Sessions::iterator i = m_sessions.find( sessionID );
00134 if ( i != m_sessions.end() )
00135 {
00136 i->second->setResponder( &responder );
00137 return i->second;
00138 }
00139 }
00140 catch ( FieldNotFound& ) {}
00141 return 0;
00142
00143 QF_STACK_POP
00144 }
|
|
|
Definition at line 73 of file Acceptor.h. References m_sessionIDs.
00073 { return m_sessionIDs; }
|
|
|
Definition at line 75 of file Acceptor.h. References m_sessions.
00076 { return m_sessions.find( id ) != m_sessions.end(); }
|
|
|
Definition at line 69 of file Acceptor.cpp. References FIX::CONNECTION_TYPE, FIX::SessionFactory::create(), QF_STACK_POP, and QF_STACK_PUSH.
00070 { QF_STACK_PUSH( Acceptor::initialize )
00071
00072 std::set < SessionID > sessions = m_settings.getSessions();
00073 std::set < SessionID > ::iterator i;
00074
00075 if ( !sessions.size() )
00076 throw ConfigError( "No sessions defined" );
00077
00078 SessionFactory factory( m_application, m_messageStoreFactory,
00079 m_pLogFactory );
00080
00081 for ( i = sessions.begin(); i != sessions.end(); ++i )
00082 {
00083 if ( m_settings.get( *i ).getString( CONNECTION_TYPE ) == "acceptor" )
00084 {
00085 m_sessionIDs.insert( *i );
00086 m_sessions[ *i ] = factory.create( *i, m_settings.get( *i ) );
00087 }
00088 }
00089
00090 if ( !m_sessions.size() )
00091 throw ConfigError( "No sessions defined for acceptor" );
00092
00093 QF_STACK_POP
00094 }
|
|
|
Check to see if any sessions are currently logged on.
Definition at line 224 of file Acceptor.cpp. References m_sessions, QF_STACK_POP, QF_STACK_PUSH, and Sessions. Referenced by FIX::SocketAcceptor::onPoll(), FIX::SocketAcceptor::onStart(), FIX::ThreadedSocketAcceptor::onStop(), and stop().
00225 { QF_STACK_PUSH(Acceptor::isLoggedOn)
00226
00227 Sessions sessions = m_sessions;
00228 Sessions::iterator i = sessions.begin();
00229 for ( ; i != sessions.end(); ++i )
00230 {
00231 if( i->second->isLoggedOn() )
00232 return true;
00233 }
00234 return false;
00235
00236 QF_STACK_POP
00237 }
|
|
|
Definition at line 78 of file Acceptor.h. References m_stop. Referenced by FIX::SocketAcceptor::onPoll(), FIX::SocketAcceptor::onStart(), FIX::ThreadedSocketAcceptor::socketAcceptorThread(), FIX::ThreadedSocketAcceptor::socketConnectionThread(), and stop().
00078 { return m_stop; }
|
|
|
Definition at line 85 of file Acceptor.h. References m_pLog, and FIX::Log::onEvent(). Referenced by FIX::SocketAcceptor::onConnect(), and FIX::ThreadedSocketAcceptor::socketAcceptorThread().
|
|
|
Implemented to configure acceptor.
Reimplemented in FIX::SocketAcceptor, and FIX::ThreadedSocketAcceptor. Definition at line 92 of file Acceptor.h.
00092 {};
|
|
|
Implemented to initialize acceptor.
Reimplemented in FIX::SocketAcceptor, and FIX::ThreadedSocketAcceptor. Definition at line 94 of file Acceptor.h.
00094 {};
|
|
|
Implemented to connect and poll for events.
Implemented in FIX::SocketAcceptor, and FIX::ThreadedSocketAcceptor. |
|
|
Implemented to start listening for connections.
Implemented in FIX::SocketAcceptor, and FIX::ThreadedSocketAcceptor. |
|
|
Implemented to stop a running acceptor.
Implemented in FIX::SocketAcceptor, and FIX::ThreadedSocketAcceptor. Referenced by stop(). |
|
|
Poll the acceptor.
Definition at line 170 of file Acceptor.cpp. References QF_STACK_POP, and QF_STACK_PUSH.
00171 { QF_STACK_PUSH( Acceptor::poll )
00172
00173 if( m_firstPoll )
00174 {
00175 onConfigure( m_settings );
00176 onInitialize( m_settings );
00177 m_firstPoll = false;
00178 }
00179
00180 return onPoll();
00181
00182 QF_STACK_POP
00183 }
|
|
|
Start acceptor.
Definition at line 146 of file Acceptor.cpp. References QF_STACK_POP, QF_STACK_PUSH, and FIX::thread_spawn().
00147 { QF_STACK_PUSH( Acceptor::start )
00148
00149 m_stop = false;
00150 onConfigure( m_settings );
00151 onInitialize( m_settings );
00152
00153 if( !thread_spawn( &startThread, this, m_threadid ) )
00154 throw RuntimeError("Unable to spawn thread");
00155
00156 QF_STACK_POP
00157 }
|
|
|
Definition at line 239 of file Acceptor.cpp. References QF_STACK_CATCH, QF_STACK_POP, QF_STACK_PUSH, QF_STACK_TRY, and THREAD_PROC.
00240 { QF_STACK_TRY
00241 QF_STACK_PUSH( Acceptor::startThread )
00242
00243 Acceptor * pAcceptor = static_cast < Acceptor* > ( p );
00244 pAcceptor->onStart();
00245 return 0;
00246
00247 QF_STACK_POP
00248 QF_STACK_CATCH
00249 }
|
|
|
Stop acceptor.
Definition at line 185 of file Acceptor.cpp. References FIX::Session::getSessionID(), FIX::Session::isEnabled(), isLoggedOn(), isStopped(), FIX::Session::logout(), m_sessions, m_stop, m_threadid, onStop(), FIX::process_sleep(), QF_STACK_POP, QF_STACK_PUSH, Sessions, and FIX::thread_join().
00186 { QF_STACK_PUSH( Acceptor::stop )
00187
00188 if( isStopped() ) return;
00189
00190 std::vector<Session*> enabledSessions;
00191
00192 Sessions sessions = m_sessions;
00193 Sessions::iterator i = sessions.begin();
00194 for ( ; i != sessions.end(); ++i )
00195 {
00196 Session* pSession = Session::lookupSession(i->first);
00197 if( pSession->isEnabled() )
00198 {
00199 enabledSessions.push_back( pSession );
00200 pSession->logout();
00201 Session::unregisterSession( pSession->getSessionID() );
00202 }
00203 }
00204
00205 if( !force )
00206 {
00207 for ( int second = 1; second <= 10 && isLoggedOn(); ++second )
00208 process_sleep( 1 );
00209 }
00210
00211 m_stop = true;
00212 onStop();
00213 if( m_threadid )
00214 thread_join( m_threadid );
00215 m_threadid = 0;
00216
00217 std::vector<Session*>::iterator session = enabledSessions.begin();
00218 for( ; session != enabledSessions.end(); ++session )
00219 (*session)->logon();
00220
00221 QF_STACK_POP
00222 }
|
|
|
Definition at line 110 of file Acceptor.h. Referenced by getApplication(). |
|
|
Definition at line 115 of file Acceptor.h. |
|
|
Definition at line 111 of file Acceptor.h. Referenced by getMessageStoreFactory(). |
|
|
Definition at line 114 of file Acceptor.h. Referenced by log(), and ~Acceptor(). |
|
|
Definition at line 113 of file Acceptor.h. Referenced by ~Acceptor(). |
|
|
Definition at line 109 of file Acceptor.h. Referenced by getSessions(). |
|
|
Definition at line 108 of file Acceptor.h. Referenced by has(), isLoggedOn(), stop(), and ~Acceptor(). |
|
|
Definition at line 112 of file Acceptor.h. |
|
|
Definition at line 116 of file Acceptor.h. Referenced by isStopped(), and stop(). |
|
|
Definition at line 107 of file Acceptor.h. Referenced by stop(). |
1.3.6-20040222 written by Dimitri van Heesch,
© 1997-2001