68 lines
2.5 KiB
C++
68 lines
2.5 KiB
C++
#pragma once
|
|
|
|
#include "IFixSession.h"
|
|
#include "IFixRouter.h"
|
|
#include "SecurityIndex.h"
|
|
#include "lib/md/MDConsumerHandle.h"
|
|
|
|
#include <quickfix/MessageCracker.h>
|
|
#include <quickfix/Message.h>
|
|
#include <quickfix/SessionID.h>
|
|
|
|
#include <boost/container/flat_map.hpp>
|
|
#include <string>
|
|
#include <memory>
|
|
#include <mutex>
|
|
#include <functional>
|
|
|
|
#include "lib/utils/warn_ctrl.h"
|
|
|
|
namespace bts {
|
|
namespace api { class ServiceContext; }
|
|
namespace md { class MDClient; }
|
|
namespace fix {
|
|
|
|
GCC_DIAG_OFF("-Wdeprecated")
|
|
GCC_DIAG_OFF("-Wignored-qualifiers")
|
|
|
|
|
|
class FixRouter : public IFixSession, public FIX::MessageCracker, public IFixRouter
|
|
{
|
|
public:
|
|
FixRouter(const md::MDClient&,
|
|
std::function< std::shared_ptr<IFixSession> (IFixRouter&, const FIX::SessionID&) > factory);
|
|
~FixRouter();
|
|
|
|
void send(const FIX::Message&, const FIX::SessionID&) override;
|
|
void send_session_reject(const FIX::SessionID& sess, const std::string& text, const FIX::Message* refmessage = nullptr) override;
|
|
void send_biz_reject(const FIX::SessionID sess, const std::string& text, const FIX::Message& refmessage, int reason_code = 0) override;
|
|
|
|
public:
|
|
void fromAdmin(const FIX::Message& message, const FIX::SessionID& sessionID)
|
|
throw(FIX::FieldNotFound, FIX::IncorrectDataFormat, FIX::IncorrectTagValue, FIX::RejectLogon);
|
|
void fromApp(const FIX::Message &message,const FIX::SessionID &sessionID)
|
|
throw(FIX::FieldNotFound, FIX::IncorrectDataFormat, FIX::IncorrectTagValue, FIX::UnsupportedMessageType);
|
|
void toAdmin(FIX::Message&, const FIX::SessionID&);
|
|
void toApp(FIX::Message&, const FIX::SessionID&) throw(FIX::DoNotSend);
|
|
|
|
void onCreate(const FIX::SessionID&);
|
|
void onLogon(const FIX::SessionID&);
|
|
void onLogout(const FIX::SessionID&);
|
|
|
|
private:
|
|
IFixSession& session(const FIX::SessionID&);
|
|
void handle_session_exception(const std::exception& ex, const FIX::SessionID& sessionID, const FIX::Message* message = nullptr);
|
|
void handle_field_not_found(const FIX::FieldNotFound& ex, const FIX::SessionID& sess, const FIX::Message& message);
|
|
|
|
private:
|
|
std::vector<const api::Security*> get_securities() override;
|
|
const api::Security* lookup(security_key key) override;
|
|
const api::Security* lookup(const std::string& desc) override;
|
|
|
|
private:
|
|
boost::container::flat_map< FIX::SessionID, std::shared_ptr<IFixSession> > _sessions;
|
|
md::DescHandleIndex _index;
|
|
std::mutex _lock;
|
|
};
|
|
|
|
}} |