SocketInitiator.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_SOCKETINITIATOR_H
#define FIX_SOCKETINITIATOR_H
#ifdef _MSC_VER
#pragma warning( disable : 4503 4355 4786 4290 )
#endif
#include "Initiator.h"
#include "SocketConnector.h"
#include "SocketConnection.h"
namespace FIX
{
class SocketInitiator : public Initiator, SocketConnector::Strategy
{
public:
SocketInitiator( Application&, MessageStoreFactory&,
const SessionSettings& ) throw( ConfigError );
SocketInitiator( Application&, MessageStoreFactory&,
const SessionSettings&, LogFactory& ) throw( ConfigError );
virtual ~SocketInitiator();
private:
typedef std::map < int, SocketConnection* > SocketConnections;
typedef std::map < SessionID, int > SessionToHostNum;
void onConfigure( const SessionSettings& ) throw ( ConfigError );
void onInitialize( const SessionSettings& ) throw ( RuntimeError );
void onStart();
bool onPoll( double timeout );
void onStop();
void doConnect( const SessionID&, const Dictionary& d );
void onConnect( SocketConnector&, int );
void onWrite( SocketConnector&, int );
bool onData( SocketConnector&, int );
void onDisconnect( SocketConnector&, int );
void onError( SocketConnector& );
void onTimeout( SocketConnector& );
void getHost( const SessionID&, const Dictionary&, std::string&, short& );
SessionSettings m_settings;
SessionToHostNum m_sessionToHostNum;
SocketConnector m_connector;
SocketConnections m_pendingConnections;
SocketConnections m_connections;
time_t m_lastConnect;
int m_reconnectInterval;
bool m_noDelay;
int m_sendBufSize;
int m_rcvBufSize;
};
}
#endif //FIX_SOCKETINITIATOR_H
FIX::SocketInitiator::m_rcvBufSize
int m_rcvBufSize
Definition: SocketInitiator.h:76
FIX::SocketInitiator::onConnect
void onConnect(SocketConnector &, int)
Definition: SocketInitiator.cpp:154
FIX::SocketInitiator::onStart
void onStart()
Implemented to start connecting to targets.
Definition: SocketInitiator.cpp:87
FIX::SocketInitiator::m_settings
SessionSettings m_settings
Definition: SocketInitiator.h:67
FIX::SocketInitiator::~SocketInitiator
virtual ~SocketInitiator()
Definition: SocketInitiator.cpp:55
FIX::SocketInitiator::m_pendingConnections
SocketConnections m_pendingConnections
Definition: SocketInitiator.h:70
FIX::SocketInitiator::m_connector
SocketConnector m_connector
Definition: SocketInitiator.h:69
FIX::SocketInitiator::doConnect
void doConnect(const SessionID &, const Dictionary &d)
Implemented to connect a session to its target.
Definition: SocketInitiator.cpp:131
FIX::SocketConnector
Connects sockets to remote ports and addresses.
Definition: SocketConnector.h:35
FIX::SocketInitiator
Socket implementation of Initiator.
Definition: SocketInitiator.h:36
FIX::SocketInitiator::m_sessionToHostNum
SessionToHostNum m_sessionToHostNum
Definition: SocketInitiator.h:68
FIX::SocketInitiator::onConfigure
void onConfigure(const SessionSettings &)
Implemented to configure acceptor.
Definition: SocketInitiator.cpp:67
FIX::SocketInitiator::m_noDelay
bool m_noDelay
Definition: SocketInitiator.h:74
FIX::SocketInitiator::onStop
void onStop()
Implemented to stop a running initiator.
Definition: SocketInitiator.cpp:127
FIX::SocketInitiator::SocketInitiator
SocketInitiator(Application &, MessageStoreFactory &, const SessionSettings &)
Definition: SocketInitiator.cpp:32
FIX
Definition: Acceptor.cpp:34
FIX::Application
This interface must be implemented to define what your FIX application does.
Definition: Application.h:43
FIX::SocketConnector::Strategy
Definition: SocketConnector.h:53
FIX::RuntimeError
Application encountered serious error during runtime
Definition: Exceptions.h:94
FIX::ConfigError
Application is not configured correctly
Definition: Exceptions.h:87
FIX::SessionSettings
Container for setting dictionaries mapped to sessions.
Definition: SessionSettings.h:130
FIX::SocketInitiator::onPoll
bool onPoll(double timeout)
Implemented to connect and poll for events.
Definition: SocketInitiator.cpp:108
FIX::SocketInitiator::SocketConnections
std::map< int, SocketConnection *> SocketConnections
Definition: SocketInitiator.h:47
SocketConnection.h
FIX::LogFactory
This interface must be implemented to create a Log.
Definition: Log.h:42
FIX::MessageStoreFactory
This interface must be implemented to create a MessageStore.
Definition: MessageStore.h:41
Initiator.h
FIX::SocketInitiator::getHost
void getHost(const SessionID &, const Dictionary &, std::string &, short &)
Definition: SocketInitiator.cpp:231
FIX::SocketInitiator::m_connections
SocketConnections m_connections
Definition: SocketInitiator.h:71
SocketConnector.h
FIX::SocketInitiator::onDisconnect
void onDisconnect(SocketConnector &, int)
Definition: SocketInitiator.cpp:183
FIX::SocketInitiator::onData
bool onData(SocketConnector &, int)
Definition: SocketInitiator.cpp:175
FIX::SocketInitiator::m_lastConnect
time_t m_lastConnect
Definition: SocketInitiator.h:72
FIX::Dictionary
For storage and retrieval of key/value pairs.
Definition: Dictionary.h:36
FIX::SocketInitiator::SessionToHostNum
std::map< SessionID, int > SessionToHostNum
Definition: SocketInitiator.h:48
FIX::SessionID
Unique session id consists of BeginString, SenderCompID and TargetCompID.
Definition: SessionID.h:30
FIX::SocketInitiator::onInitialize
void onInitialize(const SessionSettings &)
Implemented to initialize initiator.
Definition: SocketInitiator.cpp:82
FIX::SocketInitiator::m_reconnectInterval
int m_reconnectInterval
Definition: SocketInitiator.h:73
FIX::SocketInitiator::onWrite
void onWrite(SocketConnector &, int)
Definition: SocketInitiator.cpp:166
FIX::SocketInitiator::m_sendBufSize
int m_sendBufSize
Definition: SocketInitiator.h:75
FIX::SocketInitiator::onError
void onError(SocketConnector &)
Definition: SocketInitiator.cpp:210
FIX::Initiator
Base for classes which act as an initiator for establishing connections.
Definition: Initiator.h:51
FIX::SocketInitiator::onTimeout
void onTimeout(SocketConnector &)
Definition: SocketInitiator.cpp:215