Files
externals/linux/include/OnixS/CME/MDP3/HandlerState.h
T
2017-08-09 14:33:06 +00:00

161 lines
5.8 KiB
C++
Executable File

// 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 "OnixS/CME/MDP3/Types.h"
namespace OnixS
{
namespace CME
{
namespace MDP3
{
/// Available Handler's states.
struct ONIXS_CME_MDP3_API HandlerStates
{
/// Available Handler's states.
enum Enum
{
/// Handler is stopped.
Stopped = 0,
/// Handler is started but no data processing is performed yet.
Started,
/// Download or replay of Security Definition(d) messages is started.
SecurityDefinitionsRecoveryStarted,
/// Download or replay of Security Definition(d) messages is finished.
SecurityDefinitionsRecoveryFinished,
///
/// The correct books state is lost.
///
/// Handler switches to this state when it joins the market and the
/// initial books state is built from MarketDataSnapshotFullRefresh
/// (MsgType=W) messages or when the TCP Recovery is not used and the
/// message sequence number gap is detected, so the book state should
/// be re-built from MarketDataSnapshotFullRefresh (MsgType=W) messages
/// again.
///
/// It should be assumed at this point that all books maintained
/// in the Handler may no longer have the correct, latest state
/// maintained by CME, so they are cleared.
///
BookRecoveryStarted,
///
/// The latest books state is restored.
///
/// Handler switches to this state when the the latest books state
/// is restored from MarketDataSnapshotFullRefresh (MsgType=W) messages
/// (all snapshot data is retrieved).
///
/// It should be assumed at this point that all books maintained in
/// the Handler have the correct, latest state maintained by CME.
///
BookRecoveryFinished,
/// Handler initiated retransmission of
/// lost packets over TCP replay channel.
TcpRecoveryStarted,
/// Handler accomplished retransmission of
/// lost packets over TCP replay channel.
TcpRecoveryFinished
};
/// Returns constant from its string representation.
static Enum deserialize(const char* state);
/// Returns string representation of a state.
static const char* toString(Enum state);
};
/// States of the Handler in which it may reside.
typedef
HandlerStates::Enum
HandlerState;
/// Handler state change.
class
ONIXS_CME_MDP3_API
HandlerStateChange
{
public:
HandlerStateChange(
HandlerState newState,
HandlerState oldState);
/// New State.
HandlerState newState() const
{
return newState_;
}
/// Old state.
HandlerState oldState() const
{
return oldState_;
}
/// String representation.
std::string toString() const
{
std::string str;
toString(str);
return str;
}
/// Appends string representation.
void toString(std::string&) const;
private:
HandlerState newState_;
HandlerState oldState_;
HandlerStateChange(
const HandlerStateChange& other);
HandlerStateChange&
operator =(
const HandlerStateChange& other);
};
/// Handler state change listener.
class
ONIXS_CME_MDP3_API
HandlerStateChangeListener
{
public:
/// Is called when the handler state is changed.
virtual
void
onHandlerStateChange(
const HandlerStateChange& change,
const ChannelId& channelId) = 0;
protected:
virtual ~HandlerStateChangeListener();
};
}
}
}