Acceptor.h
Go to the documentation of this file.
1/* -*- C++ -*- */
2
3/****************************************************************************
4** Copyright (c) 2001-2014
5**
6** This file is part of the QuickFIX FIX Engine
7**
8** This file may be distributed under the terms of the quickfixengine.org
9** license as defined by quickfixengine.org and appearing in the file
10** LICENSE included in the packaging of this file.
11**
12** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
13** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
14**
15** See http://www.quickfixengine.org/LICENSE for licensing information.
16**
17** Contact ask@quickfixengine.org if any conditions of this licensing are
18** not clear to you.
19**
20****************************************************************************/
21
22#ifndef FIX_ACCEPTOR_H
23#define FIX_ACCEPTOR_H
24
25#ifdef _MSC_VER
26#pragma warning( disable : 4503 4355 4786 4290 )
27#endif
28
29#include "Application.h"
30#include "MessageStore.h"
31#include "Log.h"
32#include "Responder.h"
33#include "SessionSettings.h"
34#include "Exceptions.h"
35#include <map>
36#include <string>
37
38namespace FIX
39{
40class Client;
41class Session;
42
50{
51public:
53 const SessionSettings& ) throw( ConfigError );
55 const SessionSettings&, LogFactory& ) throw( ConfigError );
56
57 virtual ~Acceptor();
58
60 {
61 if( m_pLog ) return m_pLog;
62 return &m_nullLog;
63 }
64
66 void start() throw ( ConfigError, RuntimeError );
68 void block() throw ( ConfigError, RuntimeError );
70 bool poll( double timeout = 0.0 ) throw ( ConfigError, RuntimeError );
71
73 void stop( bool force = false );
74
76 bool isLoggedOn();
77
78 Session* getSession( const std::string& msg, Responder& );
79
80 const std::set<SessionID>& getSessions() const { return m_sessionIDs; }
81 Session* getSession( const SessionID& sessionID ) const;
82 const Dictionary* const getSessionSettings( const SessionID& sessionID ) const;
83
84 bool has( const SessionID& id )
85 { return m_sessions.find( id ) != m_sessions.end(); }
86
87 bool isStopped() { return m_stop; }
88
92
93private:
94 void initialize() throw ( ConfigError );
95
97 virtual void onConfigure( const SessionSettings& ) throw ( ConfigError ) {};
99 virtual void onInitialize( const SessionSettings& ) throw ( RuntimeError ) {};
101 virtual void onStart() = 0;
103 virtual bool onPoll( double second ) = 0;
105 virtual void onStop() = 0;
106
107 static THREAD_PROC startThread( void* p );
108
109 typedef std::set < SessionID > SessionIDs;
110 typedef std::map < SessionID, Session* > Sessions;
111
117protected:
119private:
124 bool m_stop;
125};
127}
128
129#endif // FIX_ACCEPTOR_H
#define THREAD_PROC
Definition Utility.h:184
Base for classes which act as an acceptor for incoming connections.
Definition Acceptor.h:50
virtual void onStop()=0
Implemented to stop a running acceptor.
virtual ~Acceptor()
Definition Acceptor.cpp:93
Sessions m_sessions
Definition Acceptor.h:113
void start()
Start acceptor.
Definition Acceptor.cpp:158
NullLog m_nullLog
Definition Acceptor.h:122
void initialize()
Definition Acceptor.cpp:69
SessionIDs m_sessionIDs
Definition Acceptor.h:114
Application & getApplication()
Definition Acceptor.h:89
void stop(bool force=false)
Stop acceptor.
Definition Acceptor.cpp:192
void block()
Block on the acceptor.
Definition Acceptor.cpp:170
SessionSettings m_settings
Definition Acceptor.h:118
bool m_firstPoll
Definition Acceptor.h:123
std::map< SessionID, Session * > Sessions
Definition Acceptor.h:110
std::set< SessionID > SessionIDs
Definition Acceptor.h:109
Session * getSession(const std::string &msg, Responder &)
Definition Acceptor.cpp:104
MessageStoreFactory & m_messageStoreFactory
Definition Acceptor.h:116
virtual void onInitialize(const SessionSettings &)
Implemented to initialize acceptor.
Definition Acceptor.h:99
const std::set< SessionID > & getSessions() const
Definition Acceptor.h:80
bool has(const SessionID &id)
Definition Acceptor.h:84
static THREAD_PROC startThread(void *p)
Definition Acceptor.cpp:242
MessageStoreFactory & getMessageStoreFactory()
Definition Acceptor.h:90
bool poll(double timeout=0.0)
Poll the acceptor.
Definition Acceptor.cpp:179
const Dictionary *const getSessionSettings(const SessionID &sessionID) const
Definition Acceptor.cpp:146
LogFactory * m_pLogFactory
Definition Acceptor.h:120
bool isStopped()
Definition Acceptor.h:87
thread_id m_threadid
Definition Acceptor.h:112
bool isLoggedOn()
Check to see if any sessions are currently logged on.
Definition Acceptor.cpp:230
Application & m_application
Definition Acceptor.h:115
virtual bool onPoll(double second)=0
Implemented to connect and poll for events.
Log * getLog()
Definition Acceptor.h:59
virtual void onStart()=0
Implemented to start listening for connections.
virtual void onConfigure(const SessionSettings &)
Implemented to configure acceptor.
Definition Acceptor.h:97
This interface must be implemented to define what your FIX application does.
Definition Application.h:44
For storage and retrieval of key/value pairs.
Definition Dictionary.h:37
This interface must be implemented to create a Log.
Definition Log.h:43
This interface must be implemented to log messages and events.
Definition Log.h:82
This interface must be implemented to create a MessageStore.
Null implementation of Log.
Definition Log.h:101
Interface implements sending on and disconnecting a transport.
Definition Responder.h:35
Maintains the state and implements the logic of a FIX session.
Definition Session.h:46
Unique session id consists of BeginString, SenderCompID and TargetCompID.
Definition SessionID.h:31
Container for setting dictionaries mapped to sessions.
pthread_t thread_id
Definition Utility.h:190
Application is not configured correctly
Definition Exceptions.h:88
Application encountered serious error during runtime
Definition Exceptions.h:95

Generated on Thu Feb 29 2024 22:38:19 for QuickFIX by doxygen 1.9.8 written by Dimitri van Heesch, © 1997-2001