Application.h
Go to the documentation of this file.
00001 /* -*- C++ -*- */
00002 
00003 /****************************************************************************
00004 ** Copyright (c) 2001-2014
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_APPLICATION_H
00023 #define FIX_APPLICATION_H
00024 
00025 #include "Message.h"
00026 #include "SessionID.h"
00027 #include "Mutex.h"
00028 
00029 namespace FIX
00030 {
00043 class Application
00044 {
00045 public:
00046   virtual ~Application() {};
00048   virtual void onCreate( const SessionID& ) = 0;
00050   virtual void onLogon( const SessionID& ) = 0;
00052   virtual void onLogout( const SessionID& ) = 0;
00054   virtual void toAdmin( Message&, const SessionID& ) = 0;
00056   virtual void toApp( Message&, const SessionID& )
00057   throw( DoNotSend ) = 0;
00059   virtual void fromAdmin( const Message&, const SessionID& )
00060   throw( FieldNotFound, IncorrectDataFormat, IncorrectTagValue, RejectLogon ) = 0;
00062   virtual void fromApp( const Message&, const SessionID& )
00063   throw( FieldNotFound, IncorrectDataFormat, IncorrectTagValue, UnsupportedMessageType ) = 0;
00064 };
00065 
00076 class SynchronizedApplication : public Application
00077 {
00078 public:
00079   SynchronizedApplication( Application& app ) : m_app( app ) {}
00080 
00081   void onCreate( const SessionID& sessionID )
00082   { Locker l( m_mutex ); app().onCreate( sessionID ); }
00083   void onLogon( const SessionID& sessionID )
00084   { Locker l( m_mutex ); app().onLogon( sessionID ); }
00085   void onLogout( const SessionID& sessionID )
00086   { Locker l( m_mutex ); app().onLogout( sessionID ); }
00087   void toAdmin( Message& message, const SessionID& sessionID )
00088   { Locker l( m_mutex ); app().toAdmin( message, sessionID ); }
00089   void toApp( Message& message, const SessionID& sessionID )
00090   throw( DoNotSend )
00091   { Locker l( m_mutex ); app().toApp( message, sessionID ); }
00092   void fromAdmin( const Message& message, const SessionID& sessionID )
00093   throw( FieldNotFound, IncorrectDataFormat, IncorrectTagValue, RejectLogon )
00094   { Locker l( m_mutex ); app().fromAdmin( message, sessionID ); }
00095   void fromApp( const Message& message, const SessionID& sessionID )
00096   throw( FieldNotFound, IncorrectDataFormat, IncorrectTagValue, UnsupportedMessageType )
00097   { Locker l( m_mutex ); app().fromApp( message, sessionID ); }
00098 
00099   Mutex m_mutex;
00100 
00101   Application& app() { return m_app; }
00102   Application& m_app;
00103 };
00104 
00111 class NullApplication : public Application
00112 {
00113   void onCreate( const SessionID& ) {}
00114   void onLogon( const SessionID& ) {}
00115   void onLogout( const SessionID& ) {}
00116   void toAdmin( Message&, const SessionID& ) {}
00117   void toApp( Message&, const SessionID& )
00118   throw( DoNotSend ) {}
00119   void fromAdmin( const Message&, const SessionID& )
00120   throw( FieldNotFound, IncorrectDataFormat, IncorrectTagValue, RejectLogon ) {}
00121   void fromApp( const Message&, const SessionID& )
00122   throw( FieldNotFound, IncorrectDataFormat, IncorrectTagValue, UnsupportedMessageType ) {}
00123 };
00125 }
00126 
00127 #endif //FIX_APPLICATION_H

Generated on Mon Jun 23 2014 23:49:37 for QuickFIX by doxygen 1.7.6.1 written by Dimitri van Heesch, © 1997-2001