Public Member Functions | Protected Attributes | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
FIX::Acceptor Class Referenceabstract

Base for classes which act as an acceptor for incoming connections. More...

#include <Acceptor.h>

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

Public Member Functions

 Acceptor (Application &, MessageStoreFactory &, const SessionSettings &) throw ( ConfigError )
 
 Acceptor (Application &, MessageStoreFactory &, const SessionSettings &, LogFactory &) throw ( ConfigError )
 
virtual ~Acceptor ()
 
LoggetLog ()
 
void start () throw ( ConfigError, RuntimeError )
 Start acceptor. More...
 
void block () throw ( ConfigError, RuntimeError )
 Block on the acceptor. More...
 
bool poll (double timeout=0.0) throw ( ConfigError, RuntimeError )
 Poll the acceptor. More...
 
void stop (bool force=false)
 Stop acceptor. More...
 
bool isLoggedOn ()
 Check to see if any sessions are currently logged on. More...
 
SessiongetSession (const std::string &msg, Responder &)
 
const std::set< SessionID > & getSessions () const
 
SessiongetSession (const SessionID &sessionID) const
 
const Dictionary *const getSessionSettings (const SessionID &sessionID) const
 
bool has (const SessionID &id)
 
bool isStopped ()
 
ApplicationgetApplication ()
 
MessageStoreFactorygetMessageStoreFactory ()
 

Protected Attributes

SessionSettings m_settings
 

Private Types

typedef std::set< SessionIDSessionIDs
 
typedef std::map< SessionID, Session * > Sessions
 

Private Member Functions

void initialize () throw ( ConfigError )
 
virtual void onConfigure (const SessionSettings &) throw ( ConfigError )
 Implemented to configure acceptor. More...
 
virtual void onInitialize (const SessionSettings &) throw ( RuntimeError )
 Implemented to initialize acceptor. More...
 
virtual void onStart ()=0
 Implemented to start listening for connections. More...
 
virtual bool onPoll (double second)=0
 Implemented to connect and poll for events. More...
 
virtual void onStop ()=0
 Implemented to stop a running acceptor. More...
 

Static Private Member Functions

static THREAD_PROC startThread (void *p)
 

Private Attributes

thread_id m_threadid
 
Sessions m_sessions
 
SessionIDs m_sessionIDs
 
Applicationm_application
 
MessageStoreFactorym_messageStoreFactory
 
LogFactorym_pLogFactory
 
Logm_pLog
 
NullLog m_nullLog
 
bool m_firstPoll
 
bool m_stop
 

Detailed Description

Base for classes which act as an acceptor for incoming connections.

Most users will not need to implement one of these. The default SocketAcceptor implementation will be used in most cases.

Definition at line 64 of file Acceptor.h.

Member Typedef Documentation

◆ SessionIDs

typedef std::set< SessionID > FIX::Acceptor::SessionIDs
private

Definition at line 124 of file Acceptor.h.

◆ Sessions

typedef std::map< SessionID, Session* > FIX::Acceptor::Sessions
private

Definition at line 125 of file Acceptor.h.

Constructor & Destructor Documentation

◆ Acceptor() [1/2]

FIX::Acceptor::Acceptor ( Application application,
MessageStoreFactory messageStoreFactory,
const SessionSettings settings 
)
throw (ConfigError
)

Definition at line 52 of file Acceptor.cpp.

57 : m_threadid( 0 ),
58  m_application( application ),
59  m_messageStoreFactory( messageStoreFactory ),
60  m_settings( settings ),
61  m_pLogFactory( &logFactory ),
62  m_pLog( logFactory.create() ),
63  m_firstPoll( true ),
64  m_stop( true )
65 {
66  initialize();

◆ Acceptor() [2/2]

FIX::Acceptor::Acceptor ( Application application,
MessageStoreFactory messageStoreFactory,
const SessionSettings settings,
LogFactory logFactory 
)
throw (ConfigError
)

Definition at line 68 of file Acceptor.cpp.

70 {
71  std::set < SessionID > sessions = m_settings.getSessions();
72  std::set < SessionID > ::iterator i;
73 
74  if ( !sessions.size() )
75  throw ConfigError( "No sessions defined" );
76 
77  SessionFactory factory( m_application, m_messageStoreFactory,
78  m_pLogFactory );
79 
80  for ( i = sessions.begin(); i != sessions.end(); ++i )
81  {
82  if ( m_settings.get( *i ).getString( CONNECTION_TYPE ) == "acceptor" )
83  {

References FIX::CONNECTION_TYPE, FIX::SessionSettings::get(), FIX::SessionSettings::getSessions(), FIX::Dictionary::getString(), m_application, m_messageStoreFactory, m_pLogFactory, m_sessionIDs, and m_settings.

◆ ~Acceptor()

FIX::Acceptor::~Acceptor ( )
virtual

Definition at line 109 of file Acceptor.cpp.

115  {
116  message.getHeader().getField( beginString );
117  message.getHeader().getField( clSenderCompID );

Member Function Documentation

◆ block()

void FIX::Acceptor::block ( )
throw ( ConfigError,
RuntimeError
)

Block on the acceptor.

Definition at line 186 of file Acceptor.cpp.

193 {

◆ getApplication()

Application& FIX::Acceptor::getApplication ( )
inline

Definition at line 104 of file Acceptor.h.

◆ getLog()

Log* FIX::Acceptor::getLog ( )
inline

Definition at line 74 of file Acceptor.h.

References m_sessionIDs.

Referenced by FIX::ThreadedSocketAcceptor::socketAcceptorThread().

◆ getMessageStoreFactory()

MessageStoreFactory& FIX::Acceptor::getMessageStoreFactory ( )
inline

Definition at line 105 of file Acceptor.h.

◆ getSession() [1/2]

Session * FIX::Acceptor::getSession ( const SessionID sessionID) const

Definition at line 153 of file Acceptor.cpp.

153  {
154  return 0;
155  }
156 }
157 
158 void Acceptor::start() throw ( ConfigError, RuntimeError )
159 {
160  m_stop = false;

◆ getSession() [2/2]

Session * FIX::Acceptor::getSession ( const std::string &  msg,
Responder responder 
)

Definition at line 120 of file Acceptor.cpp.

128  {
129  i->second->setResponder( &responder );
130  return i->second;
131  }
132  }
133  catch ( FieldNotFound& ) {}
134  return 0;
135 }
136 
137 Session* Acceptor::getSession( const SessionID& sessionID ) const
138 {
139  Sessions::const_iterator i = m_sessions.find( sessionID );
140  if( i != m_sessions.end() )
141  return i->second;
142  else
143  return 0;
144 }
145 
146 const Dictionary* const Acceptor::getSessionSettings( const SessionID& sessionID ) const
147 {
148  try
149  {
150  return &m_settings.get( sessionID );
151  }

◆ getSessions()

const std::set<SessionID>& FIX::Acceptor::getSessions ( ) const
inline

Definition at line 95 of file Acceptor.h.

97 {};

◆ getSessionSettings()

const Dictionary *const FIX::Acceptor::getSessionSettings ( const SessionID sessionID) const

Definition at line 162 of file Acceptor.cpp.

171 {
172  m_stop = false;

◆ has()

bool FIX::Acceptor::has ( const SessionID id)
inline

Definition at line 99 of file Acceptor.h.

99  {};

◆ initialize()

void FIX::Acceptor::initialize ( )
throw (ConfigError
)
private

Definition at line 85 of file Acceptor.cpp.

94 {
95  Sessions::iterator i;
96  for ( i = m_sessions.begin(); i != m_sessions.end(); ++i )
97  delete i->second;
98 
99  if( m_pLogFactory && m_pLog )
101 }
102 
103 Session* Acceptor::getSession
104 ( const std::string& msg, Responder& responder )
105 {
106  Message message;
107  if ( !message.setStringHeader( msg ) )

◆ isLoggedOn()

bool FIX::Acceptor::isLoggedOn ( )

Check to see if any sessions are currently logged on.

Definition at line 246 of file Acceptor.cpp.

◆ isStopped()

bool FIX::Acceptor::isStopped ( )
inline

Definition at line 102 of file Acceptor.h.

◆ onConfigure()

virtual void FIX::Acceptor::onConfigure ( const SessionSettings )
throw (ConfigError
)
inlineprivatevirtual

Implemented to configure acceptor.

Reimplemented in FIX::ThreadedSocketAcceptor, and FIX::SocketAcceptor.

Definition at line 112 of file Acceptor.h.

117 :
118  SessionSettings m_settings;

◆ onInitialize()

virtual void FIX::Acceptor::onInitialize ( const SessionSettings )
throw (RuntimeError
)
inlineprivatevirtual

Implemented to initialize acceptor.

Reimplemented in FIX::ThreadedSocketAcceptor, and FIX::SocketAcceptor.

Definition at line 114 of file Acceptor.h.

117 :
118  SessionSettings m_settings;

◆ onPoll()

virtual bool FIX::Acceptor::onPoll ( double  second)
privatepure virtual

Implemented to connect and poll for events.

Implemented in FIX::ThreadedSocketAcceptor, and FIX::SocketAcceptor.

◆ onStart()

virtual void FIX::Acceptor::onStart ( )
privatepure virtual

Implemented to start listening for connections.

Implemented in FIX::ThreadedSocketAcceptor, and FIX::SocketAcceptor.

◆ onStop()

virtual void FIX::Acceptor::onStop ( )
privatepure virtual

Implemented to stop a running acceptor.

Implemented in FIX::ThreadedSocketAcceptor, and FIX::SocketAcceptor.

◆ poll()

bool FIX::Acceptor::poll ( double  timeout = 0.0)
throw ( ConfigError,
RuntimeError
)

Poll the acceptor.

Definition at line 195 of file Acceptor.cpp.

203  {
204  Session* pSession = Session::lookupSession(i->first);
205  if( pSession && pSession->isEnabled() )
206  {

◆ start()

void FIX::Acceptor::start ( )
throw ( ConfigError,
RuntimeError
)

Start acceptor.

Definition at line 174 of file Acceptor.cpp.

180 {
181  if( m_firstPoll )
182  {
183  m_stop = false;

◆ startThread()

THREAD_PROC FIX::Acceptor::startThread ( void *  p)
staticprivate

Definition at line 258 of file Acceptor.cpp.

◆ stop()

void FIX::Acceptor::stop ( bool  force = false)

Stop acceptor.

Definition at line 208 of file Acceptor.cpp.

214  {
215  for ( int second = 1; second <= 10 && isLoggedOn(); ++second )
216  process_sleep( 1 );
217  }
218 
219  m_stop = true;
220  onStop();
221  if( m_threadid )
223  m_threadid = 0;
224 
225  std::vector<Session*>::iterator session = enabledSessions.begin();
226  for( ; session != enabledSessions.end(); ++session )
227  (*session)->logon();
228 }
229 
231 {
232  Sessions sessions = m_sessions;
233  Sessions::iterator i = sessions.begin();
234  for ( ; i != sessions.end(); ++i )
235  {
236  if( i->second->isLoggedOn() )
237  return true;
238  }
239  return false;
240 }
241 
243 {
244  Acceptor * pAcceptor = static_cast < Acceptor* > ( p );

Member Data Documentation

◆ m_application

Application& FIX::Acceptor::m_application
private

Definition at line 130 of file Acceptor.h.

Referenced by Acceptor().

◆ m_firstPoll

bool FIX::Acceptor::m_firstPoll
private

Definition at line 138 of file Acceptor.h.

◆ m_messageStoreFactory

MessageStoreFactory& FIX::Acceptor::m_messageStoreFactory
private

Definition at line 131 of file Acceptor.h.

Referenced by Acceptor().

◆ m_nullLog

NullLog FIX::Acceptor::m_nullLog
private

Definition at line 137 of file Acceptor.h.

◆ m_pLog

Log* FIX::Acceptor::m_pLog
private

Definition at line 136 of file Acceptor.h.

◆ m_pLogFactory

LogFactory* FIX::Acceptor::m_pLogFactory
private

Definition at line 135 of file Acceptor.h.

Referenced by Acceptor().

◆ m_sessionIDs

SessionIDs FIX::Acceptor::m_sessionIDs
private

Definition at line 129 of file Acceptor.h.

Referenced by Acceptor(), and getLog().

◆ m_sessions

Sessions FIX::Acceptor::m_sessions
private

Definition at line 128 of file Acceptor.h.

◆ m_settings

SessionSettings FIX::Acceptor::m_settings
protected

Definition at line 133 of file Acceptor.h.

Referenced by Acceptor().

◆ m_stop

bool FIX::Acceptor::m_stop
private

Definition at line 139 of file Acceptor.h.

◆ m_threadid

thread_id FIX::Acceptor::m_threadid
private

Definition at line 127 of file Acceptor.h.


The documentation for this class was generated from the following files:
FIX::Acceptor::getSession
Session * getSession(const std::string &msg, Responder &)
Definition: Acceptor.cpp:120
FIX::Session::lookupSession
static Session * lookupSession(const SessionID &)
Definition: Session.cpp:1511
FIX::Acceptor::getSessionSettings
const Dictionary *const getSessionSettings(const SessionID &sessionID) const
Definition: Acceptor.cpp:162
FIX::Acceptor::m_messageStoreFactory
MessageStoreFactory & m_messageStoreFactory
Definition: Acceptor.h:131
FIX::CONNECTION_TYPE
const char CONNECTION_TYPE[]
Definition: SessionSettings.h:57
FIX::Dictionary::getString
std::string getString(const std::string &, bool capitalize=false) const
Get a value as a string.
Definition: Dictionary.cpp:47
FIX::Acceptor::m_pLogFactory
LogFactory * m_pLogFactory
Definition: Acceptor.h:135
FIX::Acceptor::m_firstPoll
bool m_firstPoll
Definition: Acceptor.h:138
FIX::Acceptor::Acceptor
Acceptor(Application &, MessageStoreFactory &, const SessionSettings &)
Definition: Acceptor.cpp:52
FIX::Acceptor::start
void start()
Start acceptor.
Definition: Acceptor.cpp:174
FIX::Acceptor::startThread
static THREAD_PROC startThread(void *p)
Definition: Acceptor.cpp:258
THREAD_PROC
#define THREAD_PROC
Definition: Utility.h:183
FIX::Acceptor::isLoggedOn
bool isLoggedOn()
Check to see if any sessions are currently logged on.
Definition: Acceptor.cpp:246
FIX::Acceptor::Sessions
std::map< SessionID, Session * > Sessions
Definition: Acceptor.h:125
FIX::SessionSettings::getSessions
std::set< SessionID > getSessions() const
Definition: SessionSettings.cpp:175
FIX::Acceptor::m_pLog
Log * m_pLog
Definition: Acceptor.h:136
FIX::LogFactory::destroy
virtual void destroy(Log *)=0
FIX::Acceptor::onStop
virtual void onStop()=0
Implemented to stop a running acceptor.
FIX::process_sleep
void process_sleep(double s)
Definition: Utility.cpp:481
FIX::Acceptor::m_stop
bool m_stop
Definition: Acceptor.h:139
FIX::Acceptor::initialize
void initialize()
Definition: Acceptor.cpp:85
FIX::thread_join
void thread_join(thread_id thread)
Definition: Utility.cpp:452
FIX::Acceptor::onConfigure
virtual void onConfigure(const SessionSettings &)
Implemented to configure acceptor.
Definition: Acceptor.h:112
FIX::Acceptor::m_settings
SessionSettings m_settings
Definition: Acceptor.h:133
FIX::SessionSettings::get
const Dictionary & get(const SessionID &) const
Get a dictionary for a session.
Definition: SessionSettings.cpp:142
FIX::Acceptor::m_application
Application & m_application
Definition: Acceptor.h:130
FIX::Acceptor::m_sessions
Sessions m_sessions
Definition: Acceptor.h:128
FIX::Acceptor::m_threadid
thread_id m_threadid
Definition: Acceptor.h:127

Generated on Wed Apr 29 2020 19:41:30 for QuickFIX by doxygen 1.8.16 written by Dimitri van Heesch, © 1997-2001