Acceptor.h
Go to the documentation of this file.
/* -*- C++ -*- */
/****************************************************************************
** Copyright (c) 2001-2014
**
** This file is part of the QuickFIX FIX Engine
**
** This file may be distributed under the terms of the quickfixengine.org
** license as defined by quickfixengine.org and appearing in the file
** LICENSE included in the packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.quickfixengine.org/LICENSE for licensing information.
**
** Contact ask@quickfixengine.org if any conditions of this licensing are
** not clear to you.
**
****************************************************************************/
#ifndef FIX_ACCEPTOR_H
#define FIX_ACCEPTOR_H
#ifdef _MSC_VER
#pragma warning( disable : 4503 4355 4786 4290 )
#endif
#include "Application.h"
#include "MessageStore.h"
#include "Log.h"
#include "Responder.h"
#include "SessionSettings.h"
#include "Exceptions.h"
#include <map>
#include <string>
namespace FIX
{
class Client;
class Session;
class Acceptor
{
public:
Acceptor( Application&, MessageStoreFactory&,
const SessionSettings& ) throw( ConfigError );
Acceptor( Application&, MessageStoreFactory&,
const SessionSettings&, LogFactory& ) throw( ConfigError );
virtual ~Acceptor();
Log* getLog()
{
if( m_pLog ) return m_pLog;
return &m_nullLog;
}
void start() throw ( ConfigError, RuntimeError );
void block() throw ( ConfigError, RuntimeError );
bool poll( double timeout = 0.0 ) throw ( ConfigError, RuntimeError );
void stop( bool force = false );
bool isLoggedOn();
Session* getSession( const std::string& msg, Responder& );
const std::set<SessionID>& getSessions() const { return m_sessionIDs; }
Session* getSession( const SessionID& sessionID ) const;
const Dictionary* const getSessionSettings( const SessionID& sessionID ) const;
bool has( const SessionID& id )
{ return m_sessions.find( id ) != m_sessions.end(); }
bool isStopped() { return m_stop; }
Application& getApplication() { return m_application; }
MessageStoreFactory& getMessageStoreFactory()
{ return m_messageStoreFactory; }
private:
void initialize() throw ( ConfigError );
virtual void onConfigure( const SessionSettings& ) throw ( ConfigError ) {};
virtual void onInitialize( const SessionSettings& ) throw ( RuntimeError ) {};
virtual void onStart() = 0;
virtual bool onPoll( double second ) = 0;
virtual void onStop() = 0;
static THREAD_PROC startThread( void* p );
typedef std::set < SessionID > SessionIDs;
typedef std::map < SessionID, Session* > Sessions;
thread_id m_threadid;
Sessions m_sessions;
SessionIDs m_sessionIDs;
Application& m_application;
MessageStoreFactory& m_messageStoreFactory;
protected:
SessionSettings m_settings;
private:
LogFactory* m_pLogFactory;
Log* m_pLog;
NullLog m_nullLog;
bool m_firstPoll;
bool m_stop;
};
}
#endif // FIX_ACCEPTOR_H
Application.h
Exceptions.h
Log.h
MessageStore.h
Responder.h
SessionSettings.h
THREAD_PROC
#define THREAD_PROC
Definition Utility.h:184
FIX::Acceptor
Base for classes which act as an acceptor for incoming connections.
Definition Acceptor.h:50
FIX::Acceptor::onStop
virtual void onStop()=0
Implemented to stop a running acceptor.
FIX::Acceptor::~Acceptor
virtual ~Acceptor()
Definition Acceptor.cpp:93
FIX::Acceptor::m_sessions
Sessions m_sessions
Definition Acceptor.h:113
FIX::Acceptor::start
void start()
Start acceptor.
Definition Acceptor.cpp:158
FIX::Acceptor::m_nullLog
NullLog m_nullLog
Definition Acceptor.h:122
FIX::Acceptor::initialize
void initialize()
Definition Acceptor.cpp:69
FIX::Acceptor::m_sessionIDs
SessionIDs m_sessionIDs
Definition Acceptor.h:114
FIX::Acceptor::getApplication
Application & getApplication()
Definition Acceptor.h:89
FIX::Acceptor::stop
void stop(bool force=false)
Stop acceptor.
Definition Acceptor.cpp:192
FIX::Acceptor::block
void block()
Block on the acceptor.
Definition Acceptor.cpp:170
FIX::Acceptor::m_settings
SessionSettings m_settings
Definition Acceptor.h:118
FIX::Acceptor::m_firstPoll
bool m_firstPoll
Definition Acceptor.h:123
FIX::Acceptor::Sessions
std::map< SessionID, Session * > Sessions
Definition Acceptor.h:110
FIX::Acceptor::SessionIDs
std::set< SessionID > SessionIDs
Definition Acceptor.h:109
FIX::Acceptor::getSession
Session * getSession(const std::string &msg, Responder &)
Definition Acceptor.cpp:104
FIX::Acceptor::m_messageStoreFactory
MessageStoreFactory & m_messageStoreFactory
Definition Acceptor.h:116
FIX::Acceptor::onInitialize
virtual void onInitialize(const SessionSettings &)
Implemented to initialize acceptor.
Definition Acceptor.h:99
FIX::Acceptor::getSessions
const std::set< SessionID > & getSessions() const
Definition Acceptor.h:80
FIX::Acceptor::has
bool has(const SessionID &id)
Definition Acceptor.h:84
FIX::Acceptor::startThread
static THREAD_PROC startThread(void *p)
Definition Acceptor.cpp:242
FIX::Acceptor::getMessageStoreFactory
MessageStoreFactory & getMessageStoreFactory()
Definition Acceptor.h:90
FIX::Acceptor::m_pLog
Log * m_pLog
Definition Acceptor.h:121
FIX::Acceptor::poll
bool poll(double timeout=0.0)
Poll the acceptor.
Definition Acceptor.cpp:179
FIX::Acceptor::getSessionSettings
const Dictionary *const getSessionSettings(const SessionID &sessionID) const
Definition Acceptor.cpp:146
FIX::Acceptor::m_stop
bool m_stop
Definition Acceptor.h:124
FIX::Acceptor::m_pLogFactory
LogFactory * m_pLogFactory
Definition Acceptor.h:120
FIX::Acceptor::isStopped
bool isStopped()
Definition Acceptor.h:87
FIX::Acceptor::m_threadid
thread_id m_threadid
Definition Acceptor.h:112
FIX::Acceptor::isLoggedOn
bool isLoggedOn()
Check to see if any sessions are currently logged on.
Definition Acceptor.cpp:230
FIX::Acceptor::m_application
Application & m_application
Definition Acceptor.h:115
FIX::Acceptor::onPoll
virtual bool onPoll(double second)=0
Implemented to connect and poll for events.
FIX::Acceptor::getLog
Log * getLog()
Definition Acceptor.h:59
FIX::Acceptor::onStart
virtual void onStart()=0
Implemented to start listening for connections.
FIX::Acceptor::onConfigure
virtual void onConfigure(const SessionSettings &)
Implemented to configure acceptor.
Definition Acceptor.h:97
FIX::Application
This interface must be implemented to define what your FIX application does.
Definition Application.h:44
FIX::Dictionary
For storage and retrieval of key/value pairs.
Definition Dictionary.h:37
FIX::LogFactory
This interface must be implemented to create a Log.
Definition Log.h:43
FIX::Log
This interface must be implemented to log messages and events.
Definition Log.h:82
FIX::MessageStoreFactory
This interface must be implemented to create a MessageStore.
Definition MessageStore.h:42
FIX::NullLog
Null implementation of Log.
Definition Log.h:101
FIX::Responder
Interface implements sending on and disconnecting a transport.
Definition Responder.h:35
FIX::Session
Maintains the state and implements the logic of a FIX session.
Definition Session.h:46
FIX::SessionID
Unique session id consists of BeginString, SenderCompID and TargetCompID.
Definition SessionID.h:31
FIX::SessionSettings
Container for setting dictionaries mapped to sessions.
Definition SessionSettings.h:221
FIX
Definition Acceptor.cpp:35
FIX::thread_id
pthread_t thread_id
Definition Utility.h:190
FIX::ConfigError
Application is not configured correctly
Definition Exceptions.h:88
FIX::RuntimeError
Application encountered serious error during runtime
Definition Exceptions.h:95