OnixS C++ FIX Engine  4.2.0
API Documentation
SessionSchedule.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 
25 #include <OnixS/FIXEngine/ABI.h>
26 
27 #if !defined (MINMAX_ABUSER)
28 #define UNDEF_MINMAX_ABUSER
29 #define MINMAX_ABUSER
30 #endif
31 
32 namespace OnixS {
33 namespace FIX {
34 namespace Scheduling {
35 /// Specifies activity time frame for the session.
36 struct
39  enum Enum {
40  /// Session continues not more than 24 hours.
41  /// That is session logon and logout are
42  /// performed within bounds of single day.
43  Day,
44 
45  /// Session logon/logout occurs only once per week.
46  Week
47  };
48 
49  /// Transforms string presentation into valid constant.
50  static Enum parse(const std::string & value);
51 
52  /// Builds string presentation for a given constant.
53  static std::string toString(Enum value);
54 };
55 
56 /// Defines session sequence number reset policy.
57 struct
60  enum Enum {
61  /// Session sequence number must never
62  /// be reset by scheduling services.
64 
65  /// Session sequence number reset
66  /// is performed on daily basis.
68 
69  /// Session sequence number reset
70  /// is performed once per week.
71  Weekly
72  };
73 
74  /// Transforms string presentation into valid constant.
75  static Enum parse(const std::string & value);
76 
77  /// Builds string presentation for a given constant.
78  static std::string toString(Enum value);
79 };
80 
81 /// Specifies day of the week.
82 struct
84  DayOfWeek {
85  enum Enum {
93  Total
94  };
95 
96  /// Transforms string presentation into valid constant.
97  static Enum parse(const std::string & value);
98 
99  /// Builds string presentation for a given constant.
100  static std::string toString(Enum value);
101 };
102 
103 // Alias of the number of hours.
104 typedef int Hours;
105 
106 // Alias of the number of minutes.
107 typedef int Minutes;
108 
109 // Alias of the number of seconds.
110 typedef int Seconds;
111 
112 /// Represents time of day.
114 {
115 public:
116  /// Default initialization.
117  TimeOfDay();
118 
119  /// Initializes instance to a specified
120  /// number of hours, minutes, and seconds.
121  TimeOfDay(
122  Hours hours,
123  Minutes minutes,
124  Seconds = 0);
125 
126  /// Initializes from the other instance.
127  TimeOfDay(const TimeOfDay &);
128 
129  /// Gets hours of the time of day.
130  Hours hours() const;
131 
132  /// Gets minutes of the time of day.
133  Minutes minutes() const;
134 
135  /// Gets seconds component of the time of day.
136  Seconds seconds() const;
137 
138  /// Gets total number of seconds since the midnight.
139  Seconds sinceMidnight() const;
140 
141  /// Builds string presentation.
142  std::string toString() const;
143 
144  /// Checks whether the instance is equal to the other one.
145  bool operator == (const TimeOfDay & other) const;
146 
147  /// Checks whether the instance is unequal to the other one.
148  bool operator != (const TimeOfDay & other) const;
149 
150  // Reinitializes the instance from the other one.
151  TimeOfDay & operator = (const TimeOfDay &);
152 
153  /// Returns current time of day value.
154  static TimeOfDay now();
155 
156  /// 'Zero' point of the time of day.
157  static TimeOfDay midnight();
158 
159  /// Instance of ill-formed time of day.
160  static TimeOfDay bad();
161 
162  /// Parses time of day from its string presentation.
163  static TimeOfDay parse(const std::string &);
164 
165 private:
166  Seconds seconds_;
167 
168  TimeOfDay(Seconds);
169 };
170 
171 inline
172 Seconds
174 {
175  return seconds_;
176 }
177 
178 inline
179 bool
181  const TimeOfDay & other) const
182 {
183  return seconds_ == other.seconds_;
184 }
185 
186 inline
187 bool
189  const TimeOfDay & other) const
190 {
191  return seconds_ != other.seconds_;
192 }
193 
194 /// Collection of time of day values indexed by day of week.
196 
197 /// Defines activity time frames for the session.
198 /// Also provides the ability to define sequence number
199 /// reset policy for the session.
201 {
202 public:
203  /// Initializes session schedule according to given parameters.
204  ///
205  /// If session duration is single day, then logon and logout
206  /// performed each day from the first day of week till the last
207  /// day of week. Is session duration is defined as entire week
208  /// then session logon occurs on the first day of week and
209  /// corresponding logout performed on the last day of week.
210  ///
211  /// Session sequence number reset policy must correspond to
212  /// the session duration time. In particular, if session continues
213  /// entire week it's not possible to request scheduler to reset
214  /// session sequence number on daily basis.
215  ///
216  /// @param firstDay Defines first day of activity week for the session.
217  ///
218  /// @param lastDay Defines last day of activity week for the session.
219  ///
220  /// @param logonTime Defines time of logon for session for each
221  /// activity day if session duration is single day. If session must
222  /// continue entire week, defines time of logon performed on
223  /// the first day of activity week.
224  ///
225  /// @param logoutTime Defines time of logout for session for each
226  /// activity day if session duration is single day. If session must
227  /// continue entire week, defines time of logout performed on the
228  /// last day of activity week.
229  ///
230  /// @param sessionDuration Defines whether session continues
231  /// entire week or activity time frame is limited for single day.
232  ///
233  /// @param seqNumberResetPolicy Defines session sequence number reset policy.
235  DayOfWeek::Enum firstDay,
236  DayOfWeek::Enum lastDay,
237  TimeOfDay logonTime,
238  TimeOfDay logoutTime,
239  SessionDuration::Enum sessionDuration,
240  SequenceNumberResetPolicy::Enum seqNumberResetPolicy);
241 
242  /// Initializes clone of the given instance.
243  SessionSchedule(const SessionSchedule & other);
244 
245  /// Logon time for the session for given day.
246  ///
247  /// If logon is not performed on given day, returned
248  /// value correspondent equals to TimeOfDay::bad() value.
249  TimeOfDay logonTime(DayOfWeek::Enum day) const;
250 
251  /// Defines logon time for the session for given day.
252  ///
253  /// If logon is not performed on given day, returned
254  /// value correspondent equals to TimeOfDay::bad() value.
255  void logonTime(DayOfWeek::Enum day, TimeOfDay time);
256 
257  /// Logout time for the session for given day.
258  ///
259  /// If logout is not performed on given day, returned
260  /// value correspondent equals to TimeOfDay::bad() value.
261  TimeOfDay logoutTime(DayOfWeek::Enum day) const;
262 
263  /// Defines logout time for the session for given day.
264  ///
265  /// If logout is not performed on given day, returned
266  /// value correspondent equals to TimeOfDay::bad() value.
267  void logoutTime(DayOfWeek::Enum day, TimeOfDay time);
268 
269  /// Defines whether session continues entire week
270  /// or activity time frame is limited for single day.
271  SessionDuration::Enum sessionDuration() const;
272 
273  /// Defines session sequence number reset policy.
274  SequenceNumberResetPolicy::Enum sequenceNumberResetPolicy() const;
275 
276  /// Day of week on which session message sequence numbers are reset.
277  DayOfWeek::Enum sequenceNumberWeeklyResetDay() const;
278 
279  /// Reinitializes the instance from the other one.
280  SessionSchedule & operator = (const SessionSchedule & other);
281 
282 private:
283  friend class SessionStateChanger;
284 
285  TimeOfDayOfWeek logonTimes_;
286  TimeOfDayOfWeek logoutTimes_;
287 
288  SessionDuration::Enum sessionDuration_;
289  SequenceNumberResetPolicy::Enum seqNumberResetPolicy_;
290 
291  DayOfWeek::Enum startOfWeek_;
292 };
293 
294 inline
295 TimeOfDay
297 {
298  return logonTimes_[day];
299 }
300 
301 inline
302 void
304  DayOfWeek::Enum day, TimeOfDay logonTime)
305 {
306  logonTimes_[day] = logonTime;
307 }
308 
309 inline
310 TimeOfDay
312 {
313  return logoutTimes_[day];
314 }
315 
316 inline
317 void
319  DayOfWeek::Enum day, TimeOfDay logoutTime)
320 {
321  logoutTimes_[day] = logoutTime;
322 }
323 
324 inline
327 {
328  return sessionDuration_;
329 }
330 
331 inline
334 {
335  return seqNumberResetPolicy_;
336 }
337 
338 inline
341 {
342  return startOfWeek_;
343 }
344 }
345 }
346 }
SequenceNumberResetPolicy::Enum sequenceNumberResetPolicy() const
Defines session sequence number reset policy.
Seconds sinceMidnight() const
Gets total number of seconds since the midnight.
DayOfWeek::Enum sequenceNumberWeeklyResetDay() const
Day of week on which session message sequence numbers are reset.
bool operator==(const TimeOfDay &other) const
Checks whether the instance is equal to the other one.
bool operator!=(const FieldValueRef &ref, const std::string &str)
Represents time of day.
SessionDuration::Enum sessionDuration() const
Defines whether session continues entire week or activity time frame is limited for single day...
#define ONIXS_FIXENGINE_API
Definition: ABI.h:45
Session sequence number must never be reset by scheduling services.
Defines session sequence number reset policy.
Specifies activity time frame for the session.
Specifies day of the week.
TimeOfDay logoutTime(DayOfWeek::Enum day) const
Logout time for the session for given day.
bool operator!=(const TimeOfDay &other) const
Checks whether the instance is unequal to the other one.
Defines activity time frames for the session.
Session sequence number reset is performed on daily basis.
TimeOfDay TimeOfDayOfWeek[DayOfWeek::Total]
Collection of time of day values indexed by day of week.
bool operator==(const FieldValueRef &ref, const std::string &str)
Session continues not more than 24 hours.
TimeOfDay logonTime(DayOfWeek::Enum day) const
Logon time for the session for given day.