TimeRange.h
Go to the documentation of this file.
00001 /* -*- C++ -*- */
00002 
00003 /****************************************************************************
00004 ** Copyright (c) 2001-2014
00005 **
00006 ** This file is part of the QuickFIX FIX Engine
00007 **
00008 ** This file may be distributed under the terms of the quickfixengine.org
00009 ** license as defined by quickfixengine.org and appearing in the file
00010 ** LICENSE included in the packaging of this file.
00011 **
00012 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00013 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00014 **
00015 ** See http://www.quickfixengine.org/LICENSE for licensing information.
00016 **
00017 ** Contact ask@quickfixengine.org if any conditions of this licensing are
00018 ** not clear to you.
00019 **
00020 ****************************************************************************/
00021 
00022 #ifndef FIX_TIMERANGE_H
00023 #define FIX_TIMERANGE_H
00024 
00025 #ifdef _MSC_VER
00026 #pragma warning( disable : 4503 4355 4786 4290 )
00027 #endif
00028 
00029 #include "FieldTypes.h"
00030 
00031 namespace FIX
00032 {
00034 class TimeRange
00035 {
00036 public:
00037   TimeRange( const UtcTimeOnly& startTime, const UtcTimeOnly& endTime,
00038                int startDay = -1, int endDay = -1 );
00039 
00040   TimeRange( const LocalTimeOnly& startTime, const LocalTimeOnly& endTime,
00041                int startDay = -1, int endDay = -1 );
00042 
00043   static bool isInRange( const UtcTimeOnly& start,
00044                          const UtcTimeOnly& end,
00045                          const DateTime& time )
00046   {
00047     return isInRange
00048       ( (DateTime)start, (DateTime)end, (DateTime)time );
00049   }
00050 
00051   static bool isInRange( const UtcTimeOnly& startTime,
00052                          const UtcTimeOnly& endTime,
00053                          int startDay,
00054                          int endDay,
00055                          const DateTime& time,
00056                          int day )
00057   {
00058     return isInRange
00059       ( (DateTime)startTime, (DateTime)endTime, 
00060         startDay, endDay, 
00061         (DateTime)time, day );
00062   }
00063 
00064   static bool isInRange( const UtcTimeOnly& startTime,
00065                          const UtcTimeOnly& endTime,
00066                          int startDay,
00067                          int endDay,
00068                          const DateTime& time )
00069   {
00070     return isInRange
00071       ( (DateTime)startTime, (DateTime)endTime, 
00072         startDay, endDay, 
00073         (DateTime)time );
00074   }
00075 
00076   static bool isInSameRange( const UtcTimeOnly& start,
00077                              const UtcTimeOnly& end,
00078                              const DateTime& time1,
00079                              const DateTime& time2 )
00080   {
00081     return isInSameRange
00082       ( (DateTime)start, (DateTime)end, 
00083         (DateTime)time1, (DateTime)time2 );
00084   }
00085 
00086   static bool isInSameRange( const UtcTimeOnly& startTime,
00087                              const UtcTimeOnly& endTime,
00088                              int startDay,
00089                              int endDay,
00090                              const DateTime& time1,
00091                              const DateTime& time2 )
00092   {
00093     return isInSameRange
00094       ( (DateTime)startTime, (DateTime)endTime, 
00095         startDay, endDay, 
00096         (DateTime)time1, (DateTime)time2 );
00097   }
00098 
00099   static bool isInRange( const LocalTimeOnly& start,
00100                          const LocalTimeOnly& end,
00101                          const DateTime& time )
00102   {
00103     return isInRange
00104       ( (DateTime)start, (DateTime)end, (DateTime)time );
00105   }
00106 
00107   static bool isInRange( const LocalTimeOnly& startTime,
00108                          const LocalTimeOnly& endTime,
00109                          int startDay,
00110                          int endDay,
00111                          const DateTime& time,
00112                          int day )
00113   {
00114     return isInRange
00115       ( (DateTime)startTime, (DateTime)endTime, 
00116         startDay, endDay, 
00117         (DateTime)time, day );
00118   }
00119 
00120   static bool isInRange( const LocalTimeOnly& startTime,
00121                          const LocalTimeOnly& endTime,
00122                          int startDay,
00123                          int endDay,
00124                          const DateTime& time )
00125   {
00126     return isInRange
00127       ( (DateTime)startTime, (DateTime)endTime, 
00128         startDay, endDay, 
00129         (DateTime)time );
00130   }
00131 
00132   static bool isInSameRange( const LocalTimeOnly& start,
00133                              const LocalTimeOnly& end,
00134                              const DateTime& time1,
00135                              const DateTime& time2 )
00136   {
00137     return isInSameRange
00138       ( (DateTime)start, (DateTime)end, 
00139         (DateTime)time1, (DateTime)time2 );
00140   }
00141 
00142   static bool isInSameRange( const LocalTimeOnly& startTime,
00143                              const LocalTimeOnly& endTime,
00144                              int startDay,
00145                              int endDay,
00146                              const DateTime& time1,
00147                              const DateTime& time2 )
00148   {
00149     return isInSameRange
00150       ( (DateTime)startTime, (DateTime)endTime, 
00151         startDay, endDay, 
00152         (DateTime)time1, (DateTime)time2 );
00153   }
00154 
00155 private:
00156   static bool isInRange( const DateTime& start,
00157                          const DateTime& end,
00158                          const DateTime& time );
00159 
00160   static bool isInRange( const DateTime& startTime,
00161                          const DateTime& endTime,
00162                          int startDay,
00163                          int endDay,
00164                          const DateTime& time,
00165                          int day );
00166 
00167   static bool isInRange( const DateTime& startTime,
00168                          const DateTime& endTime,
00169                          int startDay,
00170                          int endDay,
00171                          const DateTime& time );
00172 
00173   static bool isInSameRange( const DateTime& start,
00174                              const DateTime& end,
00175                              const DateTime& time1,
00176                              const DateTime& time2 );
00177 
00178   static bool isInSameRange( const DateTime& startTime,
00179                              const DateTime& endTime,
00180                              int startDay,
00181                              int endDay,
00182                              const DateTime& time1,
00183                              const DateTime& time2 );
00184 public:  
00185   bool isInRange( const DateTime& dateTime, int day )
00186   {
00187     if( m_startDay < 0 && m_endDay < 0 )
00188       return isInRange( m_startTime, m_endTime, dateTime );
00189     else
00190       return isInRange
00191         ( m_startTime, m_endTime, m_startDay, m_endDay, dateTime, day );
00192   }
00193 
00194   bool isInRange( const UtcTimeStamp& dateTime )
00195   {
00196     if( m_useLocalTime )
00197     {
00198       LocalTimeStamp localDateTime( dateTime.getTimeT() );
00199       return isInRange( localDateTime, localDateTime.getWeekDay() );
00200     }
00201 
00202     return isInRange( dateTime, dateTime.getWeekDay() );
00203   }
00204 
00205   bool isInRange( const LocalTimeStamp& dateTime )
00206   {
00207     if( !m_useLocalTime )
00208     {
00209       LocalTimeStamp utcDateTime( dateTime.getTimeT() );
00210       return isInRange( utcDateTime, utcDateTime.getWeekDay() );
00211     }
00212 
00213     return isInRange( dateTime, dateTime.getWeekDay() );
00214   }
00215 
00216   bool isInSameRange( const UtcTimeStamp& time1, const UtcTimeStamp& time2 )
00217   {
00218     if( m_useLocalTime )
00219     {
00220       LocalTimeStamp localTime1( time1.getTimeT() );
00221       LocalTimeStamp localTime2( time2.getTimeT() );
00222       return isInSameRange( (DateTime)localTime1, (DateTime)localTime2 );
00223     }
00224 
00225     return isInSameRange( (DateTime)time1, (DateTime)time2 );
00226   }
00227 
00228   bool isInSameRange( const LocalTimeStamp& time1, const LocalTimeStamp& time2 )
00229   {
00230     if( !m_useLocalTime )
00231     {
00232       UtcTimeStamp utcTime1( time1.getTimeT() );
00233       UtcTimeStamp utcTime2( time2.getTimeT() );
00234       return isInSameRange( (DateTime)utcTime1, (DateTime)utcTime2 );
00235     }
00236 
00237     return isInSameRange( (DateTime)time1, (DateTime)time2 );
00238   }
00239 
00240 private:
00241   bool isInSameRange( const DateTime& time1, const DateTime& time2 )
00242   {
00243     if( m_startDay < 0 && m_endDay < 0 )
00244       return isInSameRange( m_startTime, m_endTime, time1, time2 );
00245     else
00246       return isInSameRange
00247         ( m_startTime, m_endTime, m_startDay, m_endDay, time1, time2 );
00248   }
00249 
00250   UtcTimeOnly m_startTime;
00251   UtcTimeOnly m_endTime;
00252   int m_startDay;
00253   int m_endDay;
00254   bool m_useLocalTime;
00255 };
00256 }
00257 
00258 #endif

Generated on Mon Sep 15 2014 01:23:55 for QuickFIX by doxygen 1.7.6.1 written by Dimitri van Heesch, © 1997-2001