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