Files
2019-02-11 17:36:12 +00:00

221 lines
8.4 KiB
C++

/*
* Copyright Onix Solutions Limited [OnixS]. All rights reserved.
*
* This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law
* and international copyright treaties.
*
* Access to and use of the software is governed by the terms of the applicable OnixS Software
* Services Agreement (the Agreement) and Customer end user license agreements granting
* a non-assignable, non-transferable and non-exclusive license to use the software
* for it's own data processing purposes under the terms defined in the Agreement.
*
* Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
* of this source code or associated reference material to any other location for further reproduction
* or redistribution, and any amendments to this copyright notice, are expressly prohibited.
*
* Any reproduction or redistribution for sale or hiring of the Software not in accordance with
* the terms of the Agreement is a violation of copyright law.
*/
#pragma once
#include <string>
#include <OnixS/ICE/iMpact/MarketData/ABI.h>
#include <OnixS/ICE/iMpact/MarketData/OrderBookChangeListener.h>
#include <OnixS/ICE/iMpact/MarketData/OrderBookUpdateListener.h>
#include <OnixS/ICE/iMpact/MarketData/OrderBookBundleUpdateListener.h>
#include <OnixS/ICE/iMpact/MarketData/ErrorListener.h>
#include <OnixS/ICE/iMpact/MarketData/ExchangeListener.h>
#include <OnixS/ICE/iMpact/MarketData/FeedListener.h>
#include <OnixS/ICE/iMpact/MarketData/HandlerSettings.h>
#include <OnixS/ICE/iMpact/MarketData/HandlerStateChangeListener.h>
#include <OnixS/ICE/iMpact/MarketData/LogReplayListener.h>
#include <OnixS/ICE/iMpact/MarketData/MarketSubscription.h>
#include <OnixS/ICE/iMpact/MarketData/WarningListener.h>
#include <OnixS/ICE/iMpact/MarketData/TcpSettings.h>
namespace OnixS { namespace ICE { namespace iMpact { namespace MarketData {
/// Manipulates ICE iMpact Multicast Price Feeds. Provides flexible services to
/// subscribe to the multicast groups which are best suitable for certain needs.
class ONIXS_ICE_IMPACT_MD_API Handler
{
public:
/// Performs instance initialization.
///
/// \param handlerSettings defines values for various settings
/// which affect handler behavior like enabling logging
/// during execution of the handler.
Handler(const HandlerSettings& handlerSettings);
/// Finalizes the Handler.
virtual ~Handler();
/// Date when license for the Handler will expire.
std::string licenseExpirationDate() const;
/// Get version of Handler.
static const std::string& version();
/// Log a debug message.
void logDebug(const std::string& message);
/// Log an error message.
void logError(const std::string& message);
/// Log an information message.
void logMessage(const std::string& message);
/// Log a warning message.
void logWarning(const std::string& message);
/// Registers the order book change listener.
///
/// Only single instance of listener can be associated with
/// the Handler. Registering new listener removes previous one.
///
/// Listeners are to be associated before starting market data
/// processing.
///
/// \throw exception in case of Handler is in active state.
void registerOrderBookChangeListener(OrderBookChangeListener* listener);
/// Registers the order book update listener.
///
/// Only single instance of listener can be associated with
/// the Handler. Registering new listener removes previous one.
///
/// Listeners are to be associated before starting market data
/// processing.
///
/// \throw exception in case of Handler is in active state.
void registerOrderBookUpdateListener(OrderBookUpdateListener* listener);
/// Registers the order book bundle update listener.
///
/// Only single instance of listener can be associated with
/// the Handler. Registering new listener removes previous one.
///
/// Listeners are to be associated before starting market data
/// processing.
///
/// \throw exception in case of Handler is in active state.
void registerOrderBookBundleUpdateListener(OrderBookBundleUpdateListener* listener);
/// Registers the error listener.
///
/// Only single instance of listener can be associated with
/// the Handler. Registering new listener removes previous one.
///
/// Listeners are to be associated before starting market data
/// processing.
///
/// \throw exception in case of Handler is in active state.
void registerErrorListener(ErrorListener* listener);
/// Registers the warning listener.
///
/// Only single instance of listener can be associated with
/// the Handler. Registering new listener removes previous one.
///
/// Listeners are to be associated before starting market data
/// processing.
///
/// \throw exception in case of Handler is in active state.
void registerWarningListener(WarningListener* listener);
/// Registers the Exchange listener.
///
/// Only single instance of listener can be associated with
/// the Handler. Registering new listener removes previous one.
///
/// Listeners are to be associated before starting market data
/// processing.
///
/// \throw exception in case of Handler is in active state.
void registerExchangeListener(ExchangeListener* listener);
/// Registers the feed listener.
///
/// Only single instance of listener can be associated with
/// the Handler. Registering new listener removes previous one.
///
/// Listeners are to be associated before starting market data
/// processing.
///
/// \throw exception in case of Handler is in active state.
void registerFeedListener(FeedListener* listener);
/// Registers the Handler state change listener.
///
/// Only single instance of listener can be associated with
/// the Handler. Registering new listener removes previous one.
///
/// Listeners are to be associated before starting market data
/// processing.
///
/// \throw exception in case of Handler is in active state.
void registerHandlerStateChangeListener(HandlerStateChangeListener* listener);
/// Registers the log replay listener.
///
/// Only single instance of listener can be associated with
/// the Handler. Registering new listener removes previous one.
///
/// Listeners are to be associated before starting market data
/// processing.
///
/// \throw exception in case of Handler is in active state.
void registerLogReplayListener(LogReplayListener* listener);
/// Subscribes to the given market. Subscribers are get notified
/// about certain events through previously registered handlers.
/// Notifications will occur until 'stop' member will be called.
///
/// \param marketSubscription - subscription attributes for a
/// particular market type.
///
/// \throw exception in case of unable to establish TCP connection.
void start(const MarketSubscription& marketSubscription);
/// Subscribes to the given markets. Subscribers are get notified
/// about certain events through previously registered handlers.
/// Notifications will occur until 'stop' member will be called.
/// \param marketSubscriptions - collection of subscriptions each
/// entry of which defines subscription attributes for a particular
/// market type.
///
/// \throw exception in case of unable to establish TCP connection.
void start(const MarketSubscriptions& marketSubscriptions);
/// Interrupts all subscriptions.
void stop();
/// Indicates whether subscriptions are being handled.
bool active() const;
/// Get handler state.
HandlerStates::Enum state() const;
/// Set TCP settings.
///
/// \param tcpSettings New TCP Settings.
void setTcpSettings(const TcpSettings& tcpSettings);
/// Get TCP options.
///
/// \returns TCP settings.
const TcpSettings& getTcpSettings() const;
private:
Handler(const Handler&) /*= delete */; // no implementation
Handler& operator=(const Handler&) /*= delete */; // no implementation
private:
class Implementation;
Implementation* impl_;
};
}}}} // namespace MarketData, iMpact, ICE, OnixS