ThreadedSocketInitiator.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_THREADEDSOCKETINITIATOR_H
23 #define FIX_THREADEDSOCKETINITIATOR_H
24 
25 #ifdef _MSC_VER
26 #pragma warning( disable : 4503 4355 4786 4290 )
27 #endif
28 
29 #include "Initiator.h"
31 #include <map>
32 
33 namespace FIX
34 {
38 class ThreadedSocketInitiator : public Initiator
40 {
41 public:
42  ThreadedSocketInitiator( Application&, MessageStoreFactory&,
43  const SessionSettings& ) throw( ConfigError );
44  ThreadedSocketInitiator( Application&, MessageStoreFactory&,
45  const SessionSettings&,
46  LogFactory& ) throw( ConfigError );
47 
48  virtual ~ThreadedSocketInitiator();
49 
50 private:
51  typedef std::map < int, thread_id > SocketToThread;
52  typedef std::map < SessionID, int > SessionToHostNum;
53  typedef std::pair < ThreadedSocketInitiator*, ThreadedSocketConnection* > ThreadPair;
54 
55  void onConfigure( const SessionSettings& ) throw ( ConfigError );
56  void onInitialize( const SessionSettings& ) throw ( RuntimeError );
57 
58  void onStart();
59  bool onPoll( double timeout );
60  void onStop();
61 
62  void doConnect( const SessionID& s, const Dictionary& d );
63 
64  void addThread( int s, thread_id t );
65  void removeThread( int s );
66  void lock() { Locker l(m_mutex); }
67  static THREAD_PROC socketThread( void* p );
68 
69  void getHost( const SessionID&, const Dictionary&, std::string&, short&, std::string&, short& );
70 
73  time_t m_lastConnect;
75  bool m_noDelay;
76  int m_sendBufSize;
77  int m_rcvBufSize;
79  Mutex m_mutex;
80 };
82 }
83 
84 #endif //FIX_THREADEDSOCKETINITIATOR_H
FIX::thread_id
pthread_t thread_id
Definition: Utility.h:190
FIX::ThreadedSocketInitiator::getHost
void getHost(const SessionID &, const Dictionary &, std::string &, short &, std::string &, short &)
Definition: ThreadedSocketInitiator.cpp:257
FIX::ThreadedSocketInitiator::ThreadedSocketInitiator
ThreadedSocketInitiator(Application &, MessageStoreFactory &, const SessionSettings &)
Definition: ThreadedSocketInitiator.cpp:49
FIX::ThreadedSocketInitiator::m_mutex
Mutex m_mutex
Definition: ThreadedSocketInitiator.h:96
Initiator.h
FIX::ThreadedSocketInitiator::onInitialize
void onInitialize(const SessionSettings &)
Implemented to initialize initiator.
Definition: ThreadedSocketInitiator.cpp:92
FIX::ThreadedSocketInitiator::onStart
void onStart()
Implemented to start connecting to targets.
Definition: ThreadedSocketInitiator.cpp:97
FIX::Mutex
Portable implementation of a mutex.
Definition: Mutex.h:47
FIX::ThreadedSocketInitiator::lock
void lock()
Definition: ThreadedSocketInitiator.h:83
FIX::ThreadedSocketInitiator::SessionToHostNum
std::map< SessionID, int > SessionToHostNum
Definition: ThreadedSocketInitiator.h:69
FIX::ThreadedSocketInitiator::m_sendBufSize
int m_sendBufSize
Definition: ThreadedSocketInitiator.h:93
FIX::RuntimeError
Application encountered serious error during runtime
Definition: Exceptions.h:111
FIX::SessionID
Unique session id consists of BeginString, SenderCompID and TargetCompID.
Definition: SessionID.h:47
FIX::SessionSettings
Container for setting dictionaries mapped to sessions.
Definition: SessionSettings.h:237
THREAD_PROC
#define THREAD_PROC
Definition: Utility.h:184
FIX::ThreadedSocketInitiator::m_reconnectInterval
int m_reconnectInterval
Definition: ThreadedSocketInitiator.h:91
FIX::ThreadedSocketInitiator::m_sessionToHostNum
SessionToHostNum m_sessionToHostNum
Definition: ThreadedSocketInitiator.h:89
FIX::ThreadedSocketInitiator::SocketToThread
std::map< int, thread_id > SocketToThread
Definition: ThreadedSocketInitiator.h:68
FIX::ThreadedSocketInitiator::doConnect
void doConnect(const SessionID &s, const Dictionary &d)
Implemented to connect a session to its target.
Definition: ThreadedSocketInitiator.cpp:150
FIX
Definition: Acceptor.cpp:34
FIX::ThreadedSocketInitiator::removeThread
void removeThread(int s)
Definition: ThreadedSocketInitiator.cpp:207
ThreadedSocketConnection.h
FIX::ThreadedSocketInitiator::~ThreadedSocketInitiator
virtual ~ThreadedSocketInitiator()
Definition: ThreadedSocketInitiator.cpp:72
FIX::ThreadedSocketInitiator::ThreadPair
std::pair< ThreadedSocketInitiator *, ThreadedSocketConnection * > ThreadPair
Definition: ThreadedSocketInitiator.h:70
FIX::ThreadedSocketInitiator::m_lastConnect
time_t m_lastConnect
Definition: ThreadedSocketInitiator.h:90
FIX::ThreadedSocketInitiator::onStop
void onStop()
Implemented to stop a running initiator.
Definition: ThreadedSocketInitiator.cpp:120
FIX::ThreadedSocketInitiator::addThread
void addThread(int s, thread_id t)
Definition: ThreadedSocketInitiator.cpp:200
FIX::Locker
Locks/Unlocks a mutex using RAII.
Definition: Mutex.h:112
FIX::ThreadedSocketInitiator::onConfigure
void onConfigure(const SessionSettings &)
Implemented to configure acceptor.
Definition: ThreadedSocketInitiator.cpp:77
FIX::ThreadedSocketInitiator::m_noDelay
bool m_noDelay
Definition: ThreadedSocketInitiator.h:92
FIX::ThreadedSocketInitiator::onPoll
bool onPoll(double timeout)
Implemented to connect and poll for events.
Definition: ThreadedSocketInitiator.cpp:115
FIX::ThreadedSocketInitiator::socketThread
static THREAD_PROC socketThread(void *p)
Definition: ThreadedSocketInitiator.cpp:219
FIX::ThreadedSocketInitiator::m_threads
SocketToThread m_threads
Definition: ThreadedSocketInitiator.h:95
FIX::ThreadedSocketInitiator::m_settings
SessionSettings m_settings
Definition: ThreadedSocketInitiator.h:88
FIX::Dictionary
For storage and retrieval of key/value pairs.
Definition: Dictionary.h:53
FIX::ThreadedSocketInitiator::m_rcvBufSize
int m_rcvBufSize
Definition: ThreadedSocketInitiator.h:94

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