Application.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_APPLICATION_H
#define FIX_APPLICATION_H
#include "Message.h"
#include "SessionID.h"
#include "Mutex.h"
namespace FIX
{
class Application
{
public:
virtual ~Application() {};
virtual void onCreate( const SessionID& ) = 0;
virtual void onLogon( const SessionID& ) = 0;
virtual void onLogout( const SessionID& ) = 0;
virtual void toAdmin( Message&, const SessionID& ) = 0;
virtual void toApp( Message&, const SessionID& )
throw( DoNotSend ) = 0;
virtual void fromAdmin( const Message&, const SessionID& )
throw( FieldNotFound, IncorrectDataFormat, IncorrectTagValue, RejectLogon ) = 0;
virtual void fromApp( const Message&, const SessionID& )
throw( FieldNotFound, IncorrectDataFormat, IncorrectTagValue, UnsupportedMessageType ) = 0;
};
class SynchronizedApplication : public Application
{
public:
SynchronizedApplication( Application& app ) : m_app( app ) {}
void onCreate( const SessionID& sessionID )
{ Locker l( m_mutex ); app().onCreate( sessionID ); }
void onLogon( const SessionID& sessionID )
{ Locker l( m_mutex ); app().onLogon( sessionID ); }
void onLogout( const SessionID& sessionID )
{ Locker l( m_mutex ); app().onLogout( sessionID ); }
void toAdmin( Message& message, const SessionID& sessionID )
{ Locker l( m_mutex ); app().toAdmin( message, sessionID ); }
void toApp( Message& message, const SessionID& sessionID )
throw( DoNotSend )
{ Locker l( m_mutex ); app().toApp( message, sessionID ); }
void fromAdmin( const Message& message, const SessionID& sessionID )
throw( FieldNotFound, IncorrectDataFormat, IncorrectTagValue, RejectLogon )
{ Locker l( m_mutex ); app().fromAdmin( message, sessionID ); }
void fromApp( const Message& message, const SessionID& sessionID )
throw( FieldNotFound, IncorrectDataFormat, IncorrectTagValue, UnsupportedMessageType )
{ Locker l( m_mutex ); app().fromApp( message, sessionID ); }
Mutex m_mutex;
Application& app() { return m_app; }
Application& m_app;
};
class NullApplication : public Application
{
void onCreate( const SessionID& ) {}
void onLogon( const SessionID& ) {}
void onLogout( const SessionID& ) {}
void toAdmin( Message&, const SessionID& ) {}
void toApp( Message&, const SessionID& )
throw( DoNotSend ) {}
void fromAdmin( const Message&, const SessionID& )
throw( FieldNotFound, IncorrectDataFormat, IncorrectTagValue, RejectLogon ) {}
void fromApp( const Message&, const SessionID& )
throw( FieldNotFound, IncorrectDataFormat, IncorrectTagValue, UnsupportedMessageType ) {}
};
}
#endif //FIX_APPLICATION_H
Message.h
Mutex.h
SessionID.h
FIX::Application
This interface must be implemented to define what your FIX application does.
Definition: Application.h:44
FIX::Application::fromApp
virtual void fromApp(const Message &, const SessionID &)=0
Notification of app message being received from target.
FIX::Application::onCreate
virtual void onCreate(const SessionID &)=0
Notification of a session begin created.
FIX::Application::fromAdmin
virtual void fromAdmin(const Message &, const SessionID &)=0
Notification of admin message being received from target.
FIX::Application::toAdmin
virtual void toAdmin(Message &, const SessionID &)=0
Notification of admin message being sent to target.
FIX::Application::onLogout
virtual void onLogout(const SessionID &)=0
Notification of a session logging off or disconnecting.
FIX::Application::toApp
virtual void toApp(Message &, const SessionID &)=0
Notification of app message being sent to target.
FIX::Application::onLogon
virtual void onLogon(const SessionID &)=0
Notification of a session successfully logging on.
FIX::Application::~Application
virtual ~Application()
Definition: Application.h:46
FIX::Locker
Locks/Unlocks a mutex using RAII.
Definition: Mutex.h:96
FIX::Message
Base class for all FIX messages.
Definition: Message.h:118
FIX::Mutex
Portable implementation of a mutex.
Definition: Mutex.h:31
FIX::NullApplication
An empty implementation of an Application.
Definition: Application.h:112
FIX::NullApplication::onCreate
void onCreate(const SessionID &)
Notification of a session begin created.
Definition: Application.h:113
FIX::NullApplication::fromApp
void fromApp(const Message &, const SessionID &)
Notification of app message being received from target.
Definition: Application.h:121
FIX::NullApplication::onLogout
void onLogout(const SessionID &)
Notification of a session logging off or disconnecting.
Definition: Application.h:115
FIX::NullApplication::fromAdmin
void fromAdmin(const Message &, const SessionID &)
Notification of admin message being received from target.
Definition: Application.h:119
FIX::NullApplication::toApp
void toApp(Message &, const SessionID &)
Notification of app message being sent to target.
Definition: Application.h:117
FIX::NullApplication::toAdmin
void toAdmin(Message &, const SessionID &)
Notification of admin message being sent to target.
Definition: Application.h:116
FIX::NullApplication::onLogon
void onLogon(const SessionID &)
Notification of a session successfully logging on.
Definition: Application.h:114
FIX::SessionID
Unique session id consists of BeginString, SenderCompID and TargetCompID.
Definition: SessionID.h:31
FIX::SynchronizedApplication
This is a special implementation of the Application interface that takes in another Application inter...
Definition: Application.h:77
FIX::SynchronizedApplication::m_app
Application & m_app
Definition: Application.h:102
FIX::SynchronizedApplication::onLogout
void onLogout(const SessionID &sessionID)
Notification of a session logging off or disconnecting.
Definition: Application.h:85
FIX::SynchronizedApplication::onLogon
void onLogon(const SessionID &sessionID)
Notification of a session successfully logging on.
Definition: Application.h:83
FIX::SynchronizedApplication::toApp
void toApp(Message &message, const SessionID &sessionID)
Notification of app message being sent to target.
Definition: Application.h:89
FIX::SynchronizedApplication::fromAdmin
void fromAdmin(const Message &message, const SessionID &sessionID)
Notification of admin message being received from target.
Definition: Application.h:92
FIX::SynchronizedApplication::toAdmin
void toAdmin(Message &message, const SessionID &sessionID)
Notification of admin message being sent to target.
Definition: Application.h:87
FIX::SynchronizedApplication::m_mutex
Mutex m_mutex
Definition: Application.h:99
FIX::SynchronizedApplication::app
Application & app()
Definition: Application.h:101
FIX::SynchronizedApplication::SynchronizedApplication
SynchronizedApplication(Application &app)
Definition: Application.h:79
FIX::SynchronizedApplication::onCreate
void onCreate(const SessionID &sessionID)
Notification of a session begin created.
Definition: Application.h:81
FIX::SynchronizedApplication::fromApp
void fromApp(const Message &message, const SessionID &sessionID)
Notification of app message being received from target.
Definition: Application.h:95
FIX
Definition: Acceptor.cpp:35
FIX::DoNotSend
Indicates user does not want to send a message.
Definition: Exceptions.h:218
FIX::FieldNotFound
Field not found inside a message.
Definition: Exceptions.h:58
FIX::IncorrectDataFormat
Field has a badly formatted value.
Definition: Exceptions.h:147
FIX::IncorrectTagValue
Field has a value that is out of range.
Definition: Exceptions.h:138
FIX::RejectLogon
User wants to reject permission to logon.
Definition: Exceptions.h:225
FIX::UnsupportedMessageType
Message type not supported by application.
Definition: Exceptions.h:177