QuickFIX: /home/omiller/Development/autobuild/quickfix/src/C++/Acceptor.h Source File

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

# Acceptor.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_ACCEPTOR_H
    00023 #define FIX_ACCEPTOR_H
    00024
    00025 #ifdef _MSC_VER
    00026 #pragma warning( disable : 4503 4355 4786 4290 )
    00027 #endif
    00028
    00029 #include "Application.h"
    00030 #include "MessageStore.h"
    00031 #include "Log.h"
    00032 #include "Responder.h"
    00033 #include "SessionSettings.h"
    00034 #include "Exceptions.h"
    00035 #include <map>
    00036 #include <string>
    00037
    00038 namespace FIX
    00039 {
    00040 class Client;
    00041 class Session;
    00042
    00049 class Acceptor
    00050 {
    00051 public:
    00052   Acceptor( Application&, MessageStoreFactory&,
    00053             const SessionSettings& ) throw( ConfigError );
    00054   Acceptor( Application&, MessageStoreFactory&,
    00055             const SessionSettings&, LogFactory& ) throw( ConfigError );
    00056
    00057   virtual ~Acceptor();
    00058
    00059   Log* getLog()
    00060   {
    00061     if( m_pLog ) return m_pLog;
    00062     return &m_nullLog;
    00063   }
    00064
    00066   void start() throw ( ConfigError, RuntimeError );
    00068   void block() throw ( ConfigError, RuntimeError );
    00070   bool poll( double timeout = 0.0 ) throw ( ConfigError, RuntimeError );
    00071
    00073   void stop( bool force = false );
    00074
    00076   bool isLoggedOn();
    00077
    00078   Session* getSession( const std::string& msg, Responder& );
    00079
    00080   const std::set<SessionID>& getSessions() const { return m_sessionIDs; }
    00081   Session* getSession( const SessionID& sessionID ) const;
    00082   const Dictionary* const getSessionSettings( const SessionID& sessionID ) const;
    00083
    00084   bool has( const SessionID& id )
    00085   { return m_sessions.find( id ) != m_sessions.end(); }
    00086
    00087   bool isStopped() { return m_stop; }
    00088
    00089   Application& getApplication() { return m_application; }
    00090   MessageStoreFactory& getMessageStoreFactory()
    00091   { return m_messageStoreFactory; }
    00092
    00093 private:
    00094   void initialize() throw ( ConfigError );
    00095
    00097   virtual void onConfigure( const SessionSettings& ) throw ( ConfigError ) {};
    00099   virtual void onInitialize( const SessionSettings& ) throw ( RuntimeError ) {};
    00101   virtual void onStart() = 0;
    00103   virtual bool onPoll( double second ) = 0;
    00105   virtual void onStop() = 0;
    00106
    00107   static THREAD_PROC startThread( void* p );
    00108
    00109   typedef std::set < SessionID > SessionIDs;
    00110   typedef std::map < SessionID, Session* > Sessions;
    00111
    00112   thread_id m_threadid;
    00113   Sessions m_sessions;
    00114   SessionIDs m_sessionIDs;
    00115   Application& m_application;
    00116   MessageStoreFactory& m_messageStoreFactory;
    00117   SessionSettings m_settings;
    00118   LogFactory* m_pLogFactory;
    00119   Log* m_pLog;
    00120   NullLog m_nullLog;
    00121   bool m_firstPoll;
    00122   bool m_stop;
    00123 };
    00125 }
    00126
    00127 #endif // FIX_ACCEPTOR_H