Creating Your Application

Creating a FIX application is as easy as implementing the QuickFIX Application interface. The C++ interface is defined in the following code segment:

See this code in JAVA or C#
  namespace FIX
  {
    class Application
    {
    public:
      virtual ~Application() {};
      virtual void onCreate( const SessionID& ) = 0;
      virtual void onLogon( const SessionID& )
      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;
    };
  }
  

By implementing these functions in your derived class, you are requesting to be notified of events that occur on the FIX engine. The function you that you should be most aware of is fromApp. Also remember that everything is in the FIX namespace, so when overloading your class, you must refer to classes as FIX::Session, and FIX::Message etc...

Here are explanations of what these functions provide for you.

The sample code below shows how you might start up a FIX acceptor which listens on a socket. If you wanted an initiator, you would simply replace the acceptor in this code fragment with a SocketInitiator, ThreadedSocketInitiator and ThreadedSocketAcceptor classes are also available. These will supply a thread to each session that is created. If you use these you must make sure your application is thread safe. A portable mutex class is supplied with QuickFIX.

See this code in JAVA or C#
  #include "quickfix/FileStore.h"
  #include "quickfix/FileLog.h"
  #include "quickfix/SocketAcceptor.h"
  #include "quickfix/Session.h"
  #include "quickfix/SessionSettings.h"
  #include "quickfix/Application.h"

  int main( int argc, char** argv )
  {
    try
    {
      if(argc < 2) return 1;
      std::string fileName = argv[0];

      FIX::SessionSettings settings(file);

      MyApplication application;
      FIX::FileStoreFactory storeFactory(settings);
      FIX::FileLogFactory logFactory(settings);
      FIX::Socketacceptor acceptor
        (application, storeFactory, settings, logFactory /*optional*/);
      acceptor.start();
      // while( condition == true ) { do something; }
      acceptor.stop();
      return 0;
    }
    catch(FIX::ConfigError& e)
    {
      std::cout << e.what();
      return 1;
    }
  }