OnixS C++ FIX Engine  4.12.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 an activity time frame for the session.
36 struct
39  enum Enum {
40  /// The session continues not more than 24 hours.
41  /// That is the session logon and logout are
42  /// performed within bounds of the single day.
43  Day,
44 
45  /// The session logon/logout occurs only once per week.
46  Week
47  };
48 
49  /// Transforms the string presentation into a valid constant.
50  static Enum parse(const std::string & value);
51 
52  /// Builds the string presentation for a given constant.
53  static std::string toString(Enum value);
54 };
55 
56 /// Defines the session sequence number reset policy.
57 struct
60  enum Enum {
61  /// The session sequence number must never
62  /// be reset by scheduling services.
64 
65  /// The session sequence number reset
66  /// is performed on daily basis.
68 
69  /// The session sequence number reset
70  /// is performed once per week.
71  Weekly
72  };
73 
74  /// Transforms the string presentation into a valid constant.
75  static Enum parse(const std::string & value);
76 
77  /// Builds the string presentation for a given constant.
78  static std::string toString(Enum value);
79 };
80 
81 /// Specifies a day of the week.
82 struct
84  DayOfWeek {
85  enum Enum {
93  Total
94  };
95 
96  /// Transforms the string presentation into a valid constant.
97  static Enum parse(const std::string & value);
98 
99  /// Builds the string presentation for a given constant.
100  static std::string toString(Enum value);
101 };
102 
103 // The alias of the number of hours.
104 typedef int Hours;
105 
106 // The alias of the number of minutes.
107 typedef int Minutes;
108 
109 // The alias of the number of seconds.
110 typedef int Seconds;
111 
112 /// Represents the time of the day.
114 {
115 public:
116  /// The default initialization.
117  TimeOfDay();
118 
119  /// Initializes an 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 another instance.
127  TimeOfDay(const TimeOfDay &);
128 
129  /// Gets hours of the time of the day.
130  Hours hours() const;
131 
132  /// Gets minutes of the time of the day.
133  Minutes minutes() const;
134 
135  /// Gets the seconds component of the time of the day.
136  Seconds seconds() const;
137 
138  /// Gets the total number of seconds since the midnight.
139  Seconds sinceMidnight() const;
140 
141  /// Builds the string presentation.
142  std::string toString() const;
143 
144  /// Checks whether the instance is equal to another one.
145  bool operator == (const TimeOfDay & other) const;
146 
147  /// Checks whether the instance is unequal to another one.
148  bool operator != (const TimeOfDay & other) const;
149 
150  // Reinitializes the instance from another one.
151  TimeOfDay & operator = (const TimeOfDay &);
152 
153  /// Returns the current time of the day value.
154  static TimeOfDay now();
155 
156  /// The 'Zero' point of the time of the day.
157  static TimeOfDay midnight();
158 
159  /// An instance of the ill-formed time of the day.
160  static TimeOfDay bad();
161 
162  /// Parses the 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 /// The collection of the time of day values indexed by the day of the week.
196 
197 /// Defines activity time frames for the session.
198 /// Also provides the ability to define the sequence number
199 /// reset policy for the session.
201 {
202 public:
203  /// Initializes the session schedule according to the given parameters.
204  ///
205  /// If the session duration is a single day, then logon and logout
206  /// are performed each day from the first day of the week till the last
207  /// day of the week. If the session duration is defined as the entire week
208  /// then the session logon occurs on the first day of the week and
209  /// the corresponding logout is performed on the last day of the week.
210  ///
211  /// The session sequence number reset policy must correspond to
212  /// the session duration time. In particular, if the session continues
213  /// for an entire week it's not possible to request the scheduler to reset
214  /// the session sequence number on daily basis.
215  ///
216  /// @param firstDay Defines the first day of an activity week for the session.
217  ///
218  /// @param lastDay Defines the last day of an activity week for the session.
219  ///
220  /// @param logonTime Defines the time of the logon for the session for each
221  /// activity day if the session duration is a single day. If the session must
222  /// continue for an entire week, defines the time of the logon performed on
223  /// the first day of an activity week.
224  ///
225  /// @param logoutTime Defines the time of the logout for the session for each
226  /// activity day if the session duration is a single day. If the session must
227  /// continue for an entire week, defines the time of the logout performed on the
228  /// last day of an activity week.
229  ///
230  /// @param sessionDuration Defines whether the session continues
231  /// for an entire week or the activity time frame is limited for a single day.
232  ///
233  /// @param seqNumberResetPolicy Defines the 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 a clone of the given instance.
243  SessionSchedule(const SessionSchedule & other);
244 
245  /// The logon time for the session for the given day.
246  ///
247  /// If the logon is not performed on the given day, it returns
248  /// the corresponding value equals to the TimeOfDay::bad() value.
249  TimeOfDay logonTime(DayOfWeek::Enum day) const;
250 
251  /// Defines the logon time for the session for the given day.
252  void logonTime(DayOfWeek::Enum day, TimeOfDay time);
253 
254  /// The logout time for the session for the given day.
255  ///
256  /// If the logout is not performed on the given day, it returns
257  /// the corresponding value equals to the TimeOfDay::bad() value.
258  TimeOfDay logoutTime(DayOfWeek::Enum day) const;
259 
260  /// Defines logout time for the session for given day.
261  void logoutTime(DayOfWeek::Enum day, TimeOfDay time);
262 
263  /// Defines whether the session continues the entire week
264  /// or an activity time frame is limited for the single day.
265  SessionDuration::Enum sessionDuration() const;
266 
267  /// Defines the session sequence number reset policy.
268  SequenceNumberResetPolicy::Enum sequenceNumberResetPolicy() const;
269 
270  /// The day of the week on which the session message sequence numbers are reset.
271  DayOfWeek::Enum sequenceNumberWeeklyResetDay() const;
272 
273  /// Reinitializes the instance from another one.
274  SessionSchedule & operator = (const SessionSchedule & other);
275 
276  std::string toString() const;
277 
278 private:
279  friend class SessionStateChanger;
280 
281  TimeOfDayOfWeek logonTimes_;
282  TimeOfDayOfWeek logoutTimes_;
283 
284  SessionDuration::Enum sessionDuration_;
285  SequenceNumberResetPolicy::Enum seqNumberResetPolicy_;
286 
287  DayOfWeek::Enum startOfWeek_;
288  DayOfWeek::Enum endOfWeek_;
289 };
290 
291 inline
292 TimeOfDay
294 {
295  return logonTimes_[day];
296 }
297 
298 inline
299 void
301  DayOfWeek::Enum day, TimeOfDay logonTime)
302 {
303  logonTimes_[day] = logonTime;
304 }
305 
306 inline
307 TimeOfDay
309 {
310  return logoutTimes_[day];
311 }
312 
313 inline
314 void
316  DayOfWeek::Enum day, TimeOfDay logoutTime)
317 {
318  logoutTimes_[day] = logoutTime;
319 }
320 
321 inline
324 {
325  return sessionDuration_;
326 }
327 
328 inline
331 {
332  return seqNumberResetPolicy_;
333 }
334 
335 inline
338 {
339  return startOfWeek_;
340 }
341 }
342 }
343 }
TimeOfDay TimeOfDayOfWeek[DayOfWeek::Total]
The collection of the time of day values indexed by the day of the week.
Seconds sinceMidnight() const
Gets the total number of seconds since the midnight.
SessionDuration::Enum sessionDuration() const
Defines whether the session continues the entire week or an activity time frame is limited for the si...
bool operator!=(const TimeOfDay &other) const
Checks whether the instance is unequal to another one.
SequenceNumberResetPolicy::Enum sequenceNumberResetPolicy() const
Defines the session sequence number reset policy.
The session sequence number must never be reset by scheduling services.
#define ONIXS_FIXENGINE_API
Definition: ABI.h:45
TimeOfDay logoutTime(DayOfWeek::Enum day) const
The logout time for the session for the given day.
The session sequence number reset is performed on daily basis.
DayOfWeek::Enum sequenceNumberWeeklyResetDay() const
The day of the week on which the session message sequence numbers are reset.
Specifies an activity time frame for the session.
Defines activity time frames for the session.
The session continues not more than 24 hours.
TimeOfDay logonTime(DayOfWeek::Enum day) const
The logon time for the session for the given day.
Represents the time of the day.
bool operator==(const FieldValueRef &ref, const std::string &str)
Defines the session sequence number reset policy.
bool operator==(const TimeOfDay &other) const
Checks whether the instance is equal to another one.
Specifies a day of the week.
bool operator!=(const FieldValueRef &ref, const std::string &str)