OnixS C++ FIX Engine  4.7.0
API Documentation
SessionConnectionSettings.h
Go to the documentation of this file.
1 /*
2 * Copyright Onix Solutions Limited [OnixS]. All rights reserved.
3 *
4 * This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law
5 * and international copyright treaties.
6 *
7 * Access to and use of the software is governed by the terms of the applicable OnixS Software
8 * Services Agreement (the Agreement) and Customer end user license agreements granting
9 * a non-assignable, non-transferable and non-exclusive license to use the software
10 * for it's own data processing purposes under the terms defined in the Agreement.
11 *
12 * Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
13 * of this source code or associated reference material to any other location for further reproduction
14 * or redistribution, and any amendments to this copyright notice, are expressly prohibited.
15 *
16 * Any reproduction or redistribution for sale or hiring of the Software not in accordance with
17 * the terms of the Agreement is a violation of copyright law.
18 */
19 
20 #pragma once
21 
22 #include <string>
23 #include <vector>
24 
26 
27 namespace OnixS {
28 namespace FIX {
29 namespace Scheduling {
30 /// Counterparty host name.
31 typedef std::string Host;
32 
33 /// Counterparty socket port.
34 typedef unsigned Port;
35 
36 /// Collection of parameters required to establish
37 /// connection with counterparty (session-acceptor).
39 {
40 public:
41  /// Initializes blank instance.
42  Counterparty();
43 
44  /// Fully identified counterparty.
45  Counterparty(const Host & host, Port port);
46 
47  /// Initializes as clone of the other instance.
48  Counterparty(const Counterparty & other);
49 
50  /// Cleans everything up.
51  ~Counterparty();
52 
53  /// Defines remote host to which session must connect to.
54  const Host & host() const;
55 
56  /// Defines port number to which session must connect to.
57  Port port() const;
58 
59  /// Reinitializes instance from the other one.
60  Counterparty & operator = (const Counterparty & other);
61 
62 private:
63  Host * host_;
64  Port port_;
65 };
66 
67 
68 /// Ordered series of counterparties.
69 typedef std::vector<Counterparty> Counterparties;
70 
71 
72 /// Collection of connection-related attributes for the session.
74 {
75 public:
76  /// Initializes instance from the other one.
78  const SessionConnectionSettings & other);
79 
80  /// Cleans instance up.
81  virtual ~SessionConnectionSettings();
82 
83  /// Specifies whether session must be
84  /// connected as acceptor or initiator.
85  SessionRole::Enum role() const;
86 
87  /// If session must be logged on in role of initiator,
88  /// defines value for heartbeat interval in seconds.
89  /// Otherwise has undefined value.
90  unsigned heartBeatInterval() const;
91 
92  /// If session must be logged on in role of initiator,
93  /// defines whether 'SetResetSequenceNumbers' flag must be
94  /// sent within logon message. Otherwise has undefined value.
95  bool setResetSequenceNumbers() const;
96 
97  /// If session must be logged on in role of initiator,
98  /// defines custom logon message which must be sent at
99  /// logon. Otherwise returns NULL value.
100  Message * logonMessage() const;
101 
102  /// List of all counterparties.
103  /// Not used if session must be logged on as acceptor.
104  const Counterparties & counterparties() const;
105 
106  /// Copies all settings from the other instance.
108  operator = (const SessionConnectionSettings & other);
109 
110 protected:
111  /// Initializes instance with given session role.
113 
114  /// Updates heartbeat interval value.
115  void heartBeatInterval(unsigned interval);
116 
117  /// Updates session reset seq. numbers policy.
118  void setResetSequenceNumbers(bool resetSeqNumbers);
119 
120  /// Assigns custom logon message.
121  void logonMessage(const Message & message);
122 
123  /// Editable collection of counterparties.
124  Counterparties & counterparties();
125 
126 private:
127  SessionRole::Enum role_;
128 
129  unsigned heartBeatInterval_;
130 
131  bool resetSeqNumbers_;
132 
133  Message * logonMessage_;
134 
135  Counterparties * counterparties_;
136 };
137 
138 inline
141 {
142  return role_;
143 }
144 
145 inline
146 unsigned
148 {
149  return heartBeatInterval_;
150 }
151 
152 inline
153 bool
155 {
156  return resetSeqNumbers_;
157 }
158 
159 inline
160 Message *
162 {
163  return logonMessage_;
164 }
165 
166 inline
167 const Counterparties &
169 {
170  return *counterparties_;
171 }
172 
173 /// Session connection settings for session-acceptors.
174 class
178 {
179 public:
180  /// Initializes settings for sessions-acceptors.
182 };
183 
184 /// Session connection settings for session-initiators.
185 class
189 {
190 public:
191  /// Initializes instance with session-initiator related attributes.
192  /// @param host Defines remote host to which session must connect to.
193  /// @param port Defines port number to which session must connect to.
195  const Host & host, Port port);
196 
197  /// Initializes instance with session-initiator related attributes.
198  /// @param host Defines remote host to which session must connect to.
199  /// @param port Defines port number to which session must connect to.
200  /// @param resetSessionSequenceNumbers Defines whether
201  /// 'SetResetSequenceNumbers' flag must be sent within logon message.
203  const Host & host, Port port,
204  bool resetSessionSequenceNumbers);
205 
206  /// Initializes instance with session-initiator related attributes.
207  /// @param host Defines remote host to which session must connect to.
208  /// @param port Defines port number to which session must connect to.
209  /// @param heartbeatInterval Defines time interval between heartbeat
210  /// messages.
212  const Host & host, Port port,
213  unsigned heartbeatInterval);
214 
215  /// Initializes instance with session-initiator related attributes.
216  /// @param host Defines remote host to which session must connect to.
217  /// @param port Defines port number to which session must connect to.
218  /// @param customLogonMessage Defines custom logon message which should
219  /// be used at logon.
221  const Host & host, Port port,
222  const Message & customLogonMessage);
223 
224  /// Initializes instance with session-initiator related attributes.
225  /// @param host Defines remote host to which session must connect to.
226  /// @param port Defines port number to which session must connect to.
227  /// @param heartbeatInterval Defines time interval between heartbeat
228  /// @param resetSessionSequenceNumbers Defines whether
229  /// 'SetResetSequenceNumbers' flag must be sent within logon message.
230  /// @param customLogonMessage Optionally defines custom logon message
231  /// which should be used at logon.
233  const Host & host,
234  Port port,
235  unsigned heartbeatInterval,
236  bool resetSessionSequenceNumbers,
237  const Message * customLogonMessage = ONIXS_FIXENGINE_NULLPTR);
238 
239  /// Adds one more counterparty for the list of counterparties session should try to connect to.
240  void addCounterparty(const Host & host, Port port);
241 };
242 }
243 }
244 }
Collection of connection-related attributes for the session.
std::string Host
Counterparty host name.
#define ONIXS_FIXENGINE_API
Definition: ABI.h:45
Message * logonMessage() const
If session must be logged on in role of initiator, defines custom logon message which must be sent at...
Session connection settings for session-initiators.
Collection of parameters required to establish connection with counterparty (session-acceptor).
unsigned heartBeatInterval() const
If session must be logged on in role of initiator, defines value for heartbeat interval in seconds...
Session connection settings for session-acceptors.
SessionRole::Enum role() const
Specifies whether session must be connected as acceptor or initiator.
unsigned Port
Counterparty socket port.
const Counterparties & counterparties() const
List of all counterparties.
Encapsulates operations over a FIX Message.
Definition: Message.h:49
bool setResetSequenceNumbers() const
If session must be logged on in role of initiator, defines whether &#39;SetResetSequenceNumbers&#39; flag mus...
std::vector< Counterparty > Counterparties
Ordered series of counterparties.