245 lines
7.8 KiB
C++
245 lines
7.8 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 <vector>
|
|
|
|
#include <OnixS/FIXEngine/FIX/Session.h>
|
|
|
|
namespace OnixS {
|
|
namespace FIX {
|
|
namespace Scheduling {
|
|
/// The counterparty host name.
|
|
typedef std::string Host;
|
|
|
|
/// The counterparty socket port.
|
|
typedef unsigned Port;
|
|
|
|
/// The collection of parameters required to establish
|
|
/// a connection with a counterparty (session-acceptor).
|
|
class ONIXS_FIXENGINE_API Counterparty
|
|
{
|
|
public:
|
|
/// Initializes the blank instance.
|
|
Counterparty();
|
|
|
|
/// Identifies a counterparty.
|
|
Counterparty(const Host & host, Port port);
|
|
|
|
/// Initializes as a clone of another instance.
|
|
Counterparty(const Counterparty & other);
|
|
|
|
/// Cleans everything up.
|
|
~Counterparty();
|
|
|
|
/// Defines the remote host to which the session must connect to.
|
|
const Host & host() const;
|
|
|
|
/// Defines the port number to which the session must connect to.
|
|
Port port() const;
|
|
|
|
/// Reinitializes an instance from another one.
|
|
Counterparty & operator = (const Counterparty & other);
|
|
|
|
private:
|
|
Host * host_;
|
|
Port port_;
|
|
};
|
|
|
|
|
|
/// The ordered series of counterparties.
|
|
typedef std::vector<Counterparty> Counterparties;
|
|
|
|
|
|
/// The collection of connection-related attributes for the session.
|
|
class ONIXS_FIXENGINE_API SessionConnectionSettings
|
|
{
|
|
public:
|
|
/// Initializes an instance from another one.
|
|
SessionConnectionSettings(
|
|
const SessionConnectionSettings & other);
|
|
|
|
/// Cleans an instance up.
|
|
virtual ~SessionConnectionSettings();
|
|
|
|
/// Specifies whether the session must be
|
|
/// connected as an acceptor or initiator.
|
|
SessionRole::Enum role() const;
|
|
|
|
/// If the session must be logged on in the role of an initiator,
|
|
/// defines the value for the heartbeat interval in seconds.
|
|
/// Otherwise it has an undefined value.
|
|
unsigned heartBeatInterval() const;
|
|
|
|
/// If the session must be logged on in the role of an initiator,
|
|
/// defines whether the 'SetResetSequenceNumbers' flag must be
|
|
/// sent within the logon message. Otherwise it has an undefined value.
|
|
bool setResetSequenceNumbers() const;
|
|
|
|
/// If the session must be logged on in the role of an initiator,
|
|
/// defines the custom logon message which must be sent at
|
|
/// the logon. Otherwise it returns the NULL value.
|
|
Message * logonMessage() const;
|
|
|
|
/// The list of all counterparties.
|
|
/// It is not used if the session must be logged on as an acceptor.
|
|
const Counterparties & counterparties() const;
|
|
|
|
/// Copies all settings from another instance.
|
|
SessionConnectionSettings &
|
|
operator = (const SessionConnectionSettings & other);
|
|
|
|
protected:
|
|
/// Initializes an instance with the given session role.
|
|
SessionConnectionSettings(SessionRole::Enum role);
|
|
|
|
/// Updates the heartbeat interval value.
|
|
void heartBeatInterval(unsigned interval);
|
|
|
|
/// Updates the session reset sequence numbers policy.
|
|
void setResetSequenceNumbers(bool resetSeqNumbers);
|
|
|
|
/// Assigns the custom logon message.
|
|
void logonMessage(const Message & message);
|
|
|
|
/// The editable collection of counterparties.
|
|
Counterparties & counterparties();
|
|
|
|
private:
|
|
SessionRole::Enum role_;
|
|
|
|
unsigned heartBeatInterval_;
|
|
|
|
bool resetSeqNumbers_;
|
|
|
|
Message * logonMessage_;
|
|
|
|
Counterparties * counterparties_;
|
|
};
|
|
|
|
inline
|
|
SessionRole::Enum
|
|
SessionConnectionSettings::role() const
|
|
{
|
|
return role_;
|
|
}
|
|
|
|
inline
|
|
unsigned
|
|
SessionConnectionSettings::heartBeatInterval() const
|
|
{
|
|
return heartBeatInterval_;
|
|
}
|
|
|
|
inline
|
|
bool
|
|
SessionConnectionSettings::setResetSequenceNumbers() const
|
|
{
|
|
return resetSeqNumbers_;
|
|
}
|
|
|
|
inline
|
|
Message *
|
|
SessionConnectionSettings::logonMessage() const
|
|
{
|
|
return logonMessage_;
|
|
}
|
|
|
|
inline
|
|
const Counterparties &
|
|
SessionConnectionSettings::counterparties() const
|
|
{
|
|
return *counterparties_;
|
|
}
|
|
|
|
/// Session connection settings for session-acceptors.
|
|
class
|
|
ONIXS_FIXENGINE_API
|
|
AcceptorConnectionSettings
|
|
: public SessionConnectionSettings
|
|
{
|
|
public:
|
|
/// Initializes settings for sessions-acceptors.
|
|
AcceptorConnectionSettings();
|
|
};
|
|
|
|
/// Session connection settings for session-initiators.
|
|
class
|
|
ONIXS_FIXENGINE_API
|
|
InitiatorConnectionSettings
|
|
: public SessionConnectionSettings
|
|
{
|
|
public:
|
|
/// Initializes an instance with session-initiator related attributes.
|
|
/// @param host Defines the remote host to which the session must connect to.
|
|
/// @param port Defines the port number to which the session must connect to.
|
|
InitiatorConnectionSettings(
|
|
const Host & host, Port port);
|
|
|
|
/// Initializes an instance with session-initiator related attributes.
|
|
/// @param host Defines the remote host to which the session must connect to.
|
|
/// @param port Defines the port number to which the session must connect to.
|
|
/// @param resetSessionSequenceNumbers Defines whether
|
|
/// the 'SetResetSequenceNumbers' flag must be sent within the logon message.
|
|
InitiatorConnectionSettings(
|
|
const Host & host, Port port,
|
|
bool resetSessionSequenceNumbers);
|
|
|
|
/// Initializes an instance with session-initiator related attributes.
|
|
/// @param host Defines the remote host to which the session must connect to.
|
|
/// @param port Defines the port number to which the session must connect to.
|
|
/// @param heartbeatInterval Defines the time interval between heartbeats
|
|
/// messages.
|
|
InitiatorConnectionSettings(
|
|
const Host & host, Port port,
|
|
unsigned heartbeatInterval);
|
|
|
|
/// Initializes an instance with session-initiator related attributes.
|
|
/// @param host Defines the remote host to which the session must connect to.
|
|
/// @param port Defines the port number to which the session must connect to.
|
|
/// @param customLogonMessage Defines the custom logon message which should
|
|
/// be used at the logon.
|
|
InitiatorConnectionSettings(
|
|
const Host & host, Port port,
|
|
const Message & customLogonMessage);
|
|
|
|
/// Initializes an instance with session-initiator related attributes.
|
|
/// @param host Defines the remote host to which the session must connect to.
|
|
/// @param port Defines the port number to which the session must connect to.
|
|
/// @param heartbeatInterval Defines the time interval between heartbeats
|
|
/// @param resetSessionSequenceNumbers Defines whether
|
|
/// the 'SetResetSequenceNumbers' flag must be sent within the logon message.
|
|
/// @param customLogonMessage Optionally defines the custom logon message
|
|
/// which should be used at the logon.
|
|
InitiatorConnectionSettings(
|
|
const Host & host,
|
|
Port port,
|
|
unsigned heartbeatInterval,
|
|
bool resetSessionSequenceNumbers,
|
|
const Message * customLogonMessage = ONIXS_FIXENGINE_NULLPTR);
|
|
|
|
/// Adds one more counterparty for the list of counterparties session should try to connect to.
|
|
void addCounterparty(const Host & host, Port port);
|
|
};
|
|
}
|
|
}
|
|
}
|