Index Source Files Annotated Class List Alphabetical Class List Class Hierarchy Graphical Class Hierarchy

# ThreadedSocketInitiator.h

Go to the documentation of this file.

    00001 /* -*- C++ -*- */
    00002
    00003 /****************************************************************************
    00004 ** Copyright (c) quickfixengine.org  All rights reserved.
    00005 **
    00006 ** This file is part of the QuickFIX FIX Engine
    00007 **
    00008 ** This file may be distributed under the terms of the quickfixengine.org
    00009 ** license as defined by quickfixengine.org and appearing in the file
    00010 ** LICENSE included in the packaging of this file.
    00011 **
    00012 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
    00013 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
    00014 **
    00015 ** See http://www.quickfixengine.org/LICENSE for licensing information.
    00016 **
    00017 ** Contact ask@quickfixengine.org if any conditions of this licensing are
    00018 ** not clear to you.
    00019 **
    00020 ****************************************************************************/
    00021
    00022 #ifndef FIX_THREADEDSOCKETINITIATOR_H
    00023 #define FIX_THREADEDSOCKETINITIATOR_H
    00024
    00025 #ifdef _MSC_VER
    00026 #pragma warning( disable : 4503 4355 4786 4290 )
    00027 #endif
    00028
    00029 #include "Initiator.h"
    00030 #include "ThreadedSocketConnection.h"
    00031 #include <map>
    00032
    00033 namespace FIX
    00034 {
    00038
    00039 class ThreadedSocketInitiator : public Initiator
    00040 {
    00041 public:
    00042   ThreadedSocketInitiator( Application&, MessageStoreFactory&,
    00043                            const SessionSettings& ) throw( ConfigError );
    00044   ThreadedSocketInitiator( Application&, MessageStoreFactory&,
    00045                            const SessionSettings&,
    00046                            LogFactory& ) throw( ConfigError );
    00047
    00048   virtual ~ThreadedSocketInitiator();
    00049
    00050 private:
    00051   typedef std::map < int, thread_id > SocketToThread;
    00052   typedef std::map < SessionID, int > SessionToHostNum;
    00053   typedef std::pair < ThreadedSocketInitiator*, ThreadedSocketConnection* > ThreadPair;
    00054
    00055   void onConfigure( const SessionSettings& ) throw ( ConfigError );
    00056   void onInitialize( const SessionSettings& ) throw ( RuntimeError );
    00057
    00058   void onStart();
    00059   bool onPoll( double timeout );
    00060   void onStop();
    00061
    00062   void doConnect( const SessionID& s, const Dictionary& d );
    00063
    00064   void addThread( int s, thread_id t );
    00065   void removeThread( int s );
    00066   void lock() { Locker l(m_mutex); }
    00067   static THREAD_PROC socketThread( void* p );
    00068
    00069   void getHost( const SessionID&, const Dictionary&, std::string&, short& );
    00070
    00071   SessionSettings m_settings;
    00072   SessionToHostNum m_sessionToHostNum;
    00073   time_t m_lastConnect;
    00074   int m_reconnectInterval;
    00075   bool m_noDelay;
    00076   int m_sendBufSize;
    00077   int m_rcvBufSize;
    00078   bool m_stop;
    00079   SocketToThread m_threads;
    00080   Mutex m_mutex;
    00081 };
    00083 }
    00084
    00085 #endif //FIX_THREADEDSOCKETINITIATOR_H