OnixS C++ CME iLink 3 Binary Order Entry Handler  1.9.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 <OnixS/CME/iLink3/ABI.h>
23 
24 #include <string>
25 #include <vector>
26 
27 #if !defined (MINMAX_ABUSER)
28 #define UNDEF_MINMAX_ABUSER
29 #define MINMAX_ABUSER
30 #endif
31 
32 namespace OnixS {
33 namespace CME {
34 namespace iLink3 {
35 namespace Scheduling {
36 
37 /// The day of the week.
38 struct
40  DayOfWeek {
41  enum Enum {
49  Total
50  };
51 
52  /// Transforms the string presentation into a valid constant.
53  static Enum parse(const std::string & value);
54 
55  /// \return the string presentation for a given constant.
56  static std::string toString(Enum value);
57 
58  /// \return the current day of the week.
59  static Enum now();
60 
61  /// \return the current UTC day of the week.
62  static Enum utcNow();
63 };
64 
65 // Alias of the number of hours.
66 typedef int Hours;
67 
68 // Alias of the number of minutes.
69 typedef int Minutes;
70 
71 // Alias of the number of seconds.
72 typedef int Seconds;
73 
74 /// Time of day.
76 {
77 public:
78  TimeOfDay();
79 
80  TimeOfDay(Hours hours, Minutes minutes, Seconds = 0);
81 
82  /// \return hours.
83  Hours hours() const;
84 
85  /// \return minutes.
86  Minutes minutes() const;
87 
88  /// \return seconds.
89  Seconds seconds() const;
90 
91  /// \return the total number of seconds since the midnight.
92  Seconds sinceMidnight() const;
93 
94  /// \return the string presentation.
95  std::string toString() const;
96 
97  /// Checks whether the instance is equal to the given one.
98  bool operator == (const TimeOfDay & other) const;
99 
100  /// Checks whether the instance is unequal to the given one.
101  bool operator != (const TimeOfDay & other) const;
102 
103  /// \return the current time of day.
104  static TimeOfDay now();
105 
106  /// \return the 'Zero' point of the time of day.
107  static TimeOfDay midnight();
108 
109  /// \return the instance of an ill-formed time of day.
110  static TimeOfDay bad();
111 
112  /// Parses the time of day from the given string presentation.
113  static TimeOfDay parse(const std::string &);
114 
115 private:
116  Seconds seconds_;
117 
118  TimeOfDay(Seconds);
119 };
120 
121 inline
123 {
124  return seconds_;
125 }
126 
127 inline
128 bool TimeOfDay::operator == (const TimeOfDay & other) const
129 {
130  return seconds_ == other.seconds_;
131 }
132 
133 inline
134 bool TimeOfDay::operator != (const TimeOfDay & other) const
135 {
136  return seconds_ != other.seconds_;
137 }
138 
139 /// Collection of time of day values indexed by the day of week.
141 
142 /// Session Schedule.
144 {
145 public:
146  /// Constructor.
147  ///
148  /// \param firstDay the first day of the week.
149  ///
150  /// \param lastDay the last day of the week.
151  ///
152  /// \param logonTime the logon time.
153  ///
154  /// \param logoutTime the logout time.
155  SessionSchedule(DayOfWeek::Enum firstDay, DayOfWeek::Enum lastDay, TimeOfDay logonTime, TimeOfDay logoutTime);
156 
157  SessionSchedule(const SessionSchedule & other);
158 
159  /// \return the logon time.
160  ///
161  /// If the logon is not performed on the given day,
162  /// returns the result of TimeOfDay::bad().
163  TimeOfDay logonTime(DayOfWeek::Enum day) const;
164 
165  /// Sets the logon time.
166  SessionSchedule& logonTime(DayOfWeek::Enum day, TimeOfDay time);
167 
168  /// \return the logout time.
169  ///
170  /// If the logout is not performed on the given day,
171  /// returns the result of TimeOfDay::bad().
172  TimeOfDay logoutTime(DayOfWeek::Enum day) const;
173 
174  /// Sets the logout time.
175  SessionSchedule &logoutTime(DayOfWeek::Enum day, TimeOfDay time);
176 
177  /// \return the day of the week on which the session is reset.
178  DayOfWeek::Enum resetDay() const;
179 
180  SessionSchedule & operator = (const SessionSchedule & other);
181 
182 private:
183  friend class SessionStateChanger;
184 
185  TimeOfDayOfWeek logonTimes_;
186  TimeOfDayOfWeek logoutTimes_;
187 
188  DayOfWeek::Enum startOfWeek_;
189 };
190 
191 inline
193 {
194  return logonTimes_[day];
195 }
196 
197 inline
199 {
200  logonTimes_[day] = logonTime;
201  return *this;
202 }
203 
204 inline
206 {
207  return logoutTimes_[day];
208 }
209 
210 inline
212 {
213  logoutTimes_[day] = logoutTime;
214  return *this;
215 }
216 
217 inline
219 {
220  return startOfWeek_;
221 }
222 }
223 }
224 }
225 }
TimeOfDay logonTime(DayOfWeek::Enum day) const
bool operator==(const TimeOfDay &other) const
Checks whether the instance is equal to the given one.
bool operator!=(const TimeOfDay &other) const
Checks whether the instance is unequal to the given one.
TimeOfDay TimeOfDayOfWeek[DayOfWeek::Total]
Collection of time of day values indexed by the day of week.
Definition: Defines.h:40
#define ONIXS_ILINK3_EXPORTED
Definition: Compiler.h:162
TimeOfDay logoutTime(DayOfWeek::Enum day) const
bool operator!=(const FixedPointDecimal< Mantissa, Exponent > &left, const FixedPointDecimal< Mantissa, Exponent > &right)
Compares two fixed-point decimals.