OnixS C++ FIX Engine 2.79.1.0
C:/Users/Pasha/_Dev/fixforge-cpp/fix/cppEngine/include/OnixS/FIX/Scheduling/SessionSchedule.h
00001 /*
00002 * Copyright 2005-2011 Onix Solutions Limited [OnixS]. All rights reserved. 
00003 * 
00004 * This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law 
00005 * and international copyright treaties. 
00006 * 
00007 * Access to and use of the software is governed by the terms of the applicable ONIXS Software
00008 * Services Agreement (the Agreement) and Customer end user license agreements granting 
00009 * a non-assignable, non-transferable and non-exclusive license to use the software 
00010 * for it's own data processing purposes under the terms defined in the Agreement.
00011 * 
00012 * Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part 
00013 * of this source code or associated reference material to any other location for further reproduction
00014 * or redistribution, and any amendments to this copyright notice, are expressly prohibited. 
00015 *
00016 * Any reproduction or redistribution for sale or hiring of the Software not in accordance with 
00017 * the terms of the Agreement is a violation of copyright law. 
00018 */
00019 
00020 #if !defined(__ONIXS_FIXENGINE_SCHEDULING_SESSIONSCHEDULE_H__)
00021 #define __ONIXS_FIXENGINE_SCHEDULING_SESSIONSCHEDULE_H__
00022 
00023 #include <string>
00024 #include <vector>
00025 
00026 #include "OnixS/FIX/ABI.h"
00027 
00028 #if !defined (MINMAX_ABUSER)
00029 #define UNDEF_MINMAX_ABUSER
00030 #define MINMAX_ABUSER
00031 #endif
00032 
00033 namespace OnixS
00034 {
00035     namespace FIX
00036     {
00037         namespace Scheduling
00038         {
00040             struct ONIXS_FIXENGINE_API SessionDurations
00041             { 
00042                 enum Enum
00043                 {
00047                     Day, 
00048 
00050                     Week 
00051                 };
00052 
00054                 static Enum parse(const std::string& value);
00055 
00057                 static std::string toString(Enum value);
00058             };
00059 
00061             typedef SessionDurations::Enum SessionDuration;
00062 
00064             struct ONIXS_FIXENGINE_API SequenceNumberResetPolicies
00065             { 
00066                 enum Enum
00067                 {
00070                     Never, 
00071 
00074                     Daily, 
00075 
00078                     Weekly 
00079                 };
00080 
00082                 static Enum parse(const std::string& value);
00083 
00085                 static std::string toString(Enum value);
00086             };
00087 
00089             typedef 
00090             SequenceNumberResetPolicies::Enum 
00091             SequenceNumberResetPolicy;
00092 
00094             struct ONIXS_FIXENGINE_API DaysOfWeek
00095             { 
00096                 enum Enum
00097                 {
00098                     Sunday,
00099                     Monday,
00100                     Tuesday,
00101                     Wednesday,
00102                     Thursday,
00103                     Friday,
00104                     Saturday,
00105                     Total
00106                 };
00107 
00109                 static Enum parse(const std::string& value);
00110 
00112                 static std::string toString(Enum value);
00113             };
00114 
00116             typedef DaysOfWeek::Enum DayOfWeek;
00117 
00118             // Alias of the number of hours.
00119             typedef int Hours;
00120 
00121             // Alias of the number of minutes.
00122             typedef int Minutes;
00123 
00124             // Alias of the number of seconds.
00125             typedef int Seconds;
00126 
00128             class ONIXS_FIXENGINE_API TimeOfDay
00129             {
00130             public:
00132                 TimeOfDay();
00133 
00136                 TimeOfDay(
00137                     Hours hours, 
00138                     Minutes minutes, 
00139                     Seconds = 0);
00140 
00142                 TimeOfDay(const TimeOfDay&);
00143 
00145                 Hours hours() const;
00146 
00148                 Minutes minutes() const;
00149 
00151                 Seconds seconds() const;
00152 
00154                 Seconds sinceMidnight() const;
00155 
00157                 std::string toString() const;
00158 
00160                 bool operator ==(const TimeOfDay& other) const;
00161 
00163                 bool operator !=(const TimeOfDay& other) const;
00164 
00165                 // Reinitializes the instance from the other one.
00166                 TimeOfDay& operator =(const TimeOfDay&);
00167 
00169                 static TimeOfDay now();
00170 
00172                 static TimeOfDay midnight();
00173 
00175                 static TimeOfDay bad();
00176 
00178                 static TimeOfDay parse(const std::string&);
00179 
00180             private:
00181                 Seconds seconds_;
00182 
00183                 TimeOfDay(Seconds);
00184             };
00185 
00186             inline
00187             Seconds
00188             TimeOfDay::sinceMidnight() const
00189             {
00190                 return seconds_;
00191             }
00192 
00193             inline 
00194             bool 
00195             TimeOfDay::operator ==(const TimeOfDay& other) const
00196             {
00197                 return seconds_ == other.seconds_;
00198             }
00199 
00200             inline 
00201             bool 
00202             TimeOfDay::operator !=(const TimeOfDay& other) const
00203             {
00204                 return seconds_ != other.seconds_;
00205             }
00206 
00208             typedef TimeOfDay TimeOfDayOfWeek[DaysOfWeek::Total];
00209 
00213             class ONIXS_FIXENGINE_API SessionSchedule
00214             {
00215             public:
00247                 SessionSchedule(
00248                     DayOfWeek firstDay, 
00249                     DayOfWeek lastDay,
00250                     TimeOfDay logonTime, 
00251                     TimeOfDay logoutTime,
00252                     SessionDuration sessionDuration, 
00253                     SequenceNumberResetPolicy seqNumberResetPolicy);
00254 
00256                 SessionSchedule(const SessionSchedule& other);
00257 
00262                 TimeOfDay logonTime(DayOfWeek day) const;
00263                 
00268                 void logonTime(DayOfWeek day, TimeOfDay time);
00269 
00274                 TimeOfDay logoutTime(DayOfWeek day) const;
00275 
00280                 void logoutTime(DayOfWeek day, TimeOfDay time);
00281 
00284                 SessionDuration sessionDuration() const;
00285 
00287                 SequenceNumberResetPolicy sequenceNumberResetPolicy() const;
00288 
00290                 DayOfWeek sequenceNumberWeeklyResetDay() const;
00291 
00293                 SessionSchedule& operator =(const SessionSchedule& other);
00294 
00295             private:
00296                 friend class SessionStateChanger;
00297 
00298                 TimeOfDayOfWeek logonTimes_;
00299                 TimeOfDayOfWeek logoutTimes_;
00300 
00301                 SessionDuration sessionDuration_;
00302                 SequenceNumberResetPolicy seqNumberResetPolicy_;
00303 
00304                 DayOfWeek startOfWeek_;
00305             };
00306 
00307             inline 
00308             TimeOfDay
00309             SessionSchedule::logonTime(DayOfWeek day) const
00310             {
00311                 return logonTimes_[day];
00312             }
00313 
00314             inline 
00315             void 
00316             SessionSchedule::logonTime(
00317                 DayOfWeek day, TimeOfDay logonTime)
00318             {
00319                 logonTimes_[day] = logonTime;
00320             }
00321 
00322             inline 
00323             TimeOfDay
00324             SessionSchedule::logoutTime(DayOfWeek day) const
00325             {
00326                 return logoutTimes_[day];
00327             }
00328 
00329             inline 
00330             void 
00331             SessionSchedule::logoutTime(
00332                 DayOfWeek day, TimeOfDay logoutTime)
00333             {
00334                 logoutTimes_[day] = logoutTime;
00335             }
00336 
00337             inline 
00338             SessionDuration 
00339             SessionSchedule::sessionDuration() const
00340             {
00341                 return sessionDuration_;
00342             }
00343 
00344             inline 
00345             SequenceNumberResetPolicy 
00346             SessionSchedule::sequenceNumberResetPolicy() const
00347             {
00348                 return seqNumberResetPolicy_;
00349             }
00350 
00351             inline 
00352             DayOfWeek 
00353             SessionSchedule::sequenceNumberWeeklyResetDay() const
00354             {
00355                 return startOfWeek_;
00356             }
00357         }
00358     }
00359 }
00360 
00361 #endif // __ONIXS_FIXENGINE_SCHEDULING_SESSIONSCHEDULE_H__