Index  Source Files  Annotated Class List  Alphabetical Class List  Class Hierarchy  Graphical Class Hierarchy 

TimeRange.h

Go to the documentation of this file.
00001 /* -*- C++ -*- */
00002 
00003 /****************************************************************************
00004 ** Copyright (c) quickfixengine.org  All rights reserved.
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   {
00057     return isInRange
00058       ( (DateTime)startTime, (DateTime)endTime, 
00059         startDay, endDay, 
00060         (DateTime)time );
00061   }
00062 
00063   static bool isInSameRange( const UtcTimeOnly& start,
00064                              const UtcTimeOnly& end,
00065                              const DateTime& time1,
00066                              const DateTime& time2 )
00067   {
00068     return isInSameRange
00069       ( (DateTime)start, (DateTime)end, 
00070         (DateTime)time1, (DateTime)time2 );
00071   }
00072 
00073   static bool isInSameRange( const UtcTimeOnly& startTime,
00074                              const UtcTimeOnly& endTime,
00075                              int startDay,
00076                              int endDay,
00077                              const DateTime& time1,
00078                              const DateTime& time2 )
00079   {
00080     return isInSameRange
00081       ( (DateTime)startTime, (DateTime)endTime, 
00082         startDay, endDay, 
00083         (DateTime)time1, (DateTime)time2 );
00084   }
00085 
00086   static bool isInRange( const LocalTimeOnly& start,
00087                          const LocalTimeOnly& end,
00088                          const DateTime& time )
00089   {
00090     return isInRange
00091       ( (DateTime)start, (DateTime)end, (DateTime)time );
00092   }
00093 
00094   static bool isInRange( const LocalTimeOnly& startTime,
00095                          const LocalTimeOnly& endTime,
00096                          int startDay,
00097                          int endDay,
00098                          const DateTime& time )
00099   {
00100     return isInRange
00101       ( (DateTime)startTime, (DateTime)endTime, 
00102         startDay, endDay, 
00103         (DateTime)time );
00104   }
00105 
00106   static bool isInSameRange( const LocalTimeOnly& start,
00107                              const LocalTimeOnly& end,
00108                              const DateTime& time1,
00109                              const DateTime& time2 )
00110   {
00111     return isInSameRange
00112       ( (DateTime)start, (DateTime)end, 
00113         (DateTime)time1, (DateTime)time2 );
00114   }
00115 
00116   static bool isInSameRange( const LocalTimeOnly& startTime,
00117                              const LocalTimeOnly& endTime,
00118                              int startDay,
00119                              int endDay,
00120                              const DateTime& time1,
00121                              const DateTime& time2 )
00122   {
00123     return isInSameRange
00124       ( (DateTime)startTime, (DateTime)endTime, 
00125         startDay, endDay, 
00126         (DateTime)time1, (DateTime)time2 );
00127   }
00128 
00129 private:
00130   static bool isInRange( const DateTime& start,
00131                          const DateTime& end,
00132                          const DateTime& time );
00133 
00134   static bool isInRange( const DateTime& startTime,
00135                          const DateTime& endTime,
00136                          int startDay,
00137                          int endDay,
00138                          const DateTime& time );
00139 
00140   static bool isInSameRange( const DateTime& start,
00141                              const DateTime& end,
00142                              const DateTime& time1,
00143                              const DateTime& time2 );
00144 
00145   static bool isInSameRange( const DateTime& startTime,
00146                              const DateTime& endTime,
00147                              int startDay,
00148                              int endDay,
00149                              const DateTime& time1,
00150                              const DateTime& time2 );
00151 public:
00152   bool isInRange( const DateTime& dateTime )
00153   {
00154     if( m_startDay < 0 && m_endDay < 0 )
00155       return isInRange( m_startTime, m_endTime, dateTime );
00156     else
00157       return isInRange
00158         ( m_startTime, m_endTime, m_startDay, m_endDay, dateTime );
00159   }
00160 
00161   bool isInSameRange( const UtcTimeStamp& time1, const UtcTimeStamp& time2 )
00162   {
00163     return isInSameRange( (DateTime)time1, (DateTime)time2 );
00164   }
00165 
00166   bool isInSameRange( const LocalTimeStamp& time1, const LocalTimeStamp& time2 )
00167   {
00168     return isInSameRange( (DateTime)time1, (DateTime)time2 );
00169   }
00170 
00171 private:
00172   bool isInSameRange( const DateTime& time1, const DateTime& time2 )
00173   {
00174     if( m_startDay < 0 && m_endDay < 0 )
00175       return isInSameRange( m_startTime, m_endTime, time1, time2 );
00176     else
00177       return isInSameRange
00178         ( m_startTime, m_endTime, m_startDay, m_endDay, time1, time2 );
00179   }
00180 
00181   UtcTimeOnly m_startTime;
00182   UtcTimeOnly m_endTime;
00183   int m_startDay;
00184   int m_endDay;
00185 };
00186 }
00187 
00188 #endif

Generated on Mon Apr 5 20:59:51 2010 for QuickFIX by doxygen 1.6.1 written by Dimitri van Heesch, © 1997-2001