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

FIX::SessionTime Class Reference

Keeps track of when session is active. More...

#include <SessionTime.h>

Collaboration diagram for FIX::SessionTime:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 SessionTime (const UtcTimeOnly &startTime, const UtcTimeOnly &endTime, int startDay=-1, int endDay=-1)
bool isSessionTime ()
bool isSameSession (const UtcTimeStamp &time1, const UtcTimeStamp &time2)

Static Public Member Functions

bool isSessionTime (const UtcTimeOnly &start, const UtcTimeOnly &end, const UtcTimeStamp &time)
bool isSessionTime (const UtcTimeOnly &startTime, const UtcTimeOnly &endTime, int startDay, int endDay, const UtcTimeStamp &time)
bool isSameSession (const UtcTimeOnly &start, const UtcTimeOnly &end, const UtcTimeStamp &time1, const UtcTimeStamp &time2)
bool isSameSession (const UtcTimeOnly &startTime, const UtcTimeOnly &endTime, int startDay, int endDay, const UtcTimeStamp &time1, const UtcTimeStamp &time2)

Private Attributes

UtcTimeOnly m_startTime
UtcTimeOnly m_endTime
int m_startDay
int m_endDay

Detailed Description

Keeps track of when session is active.

Definition at line 34 of file SessionTime.h.


Constructor & Destructor Documentation

FIX::SessionTime::SessionTime const UtcTimeOnly startTime,
const UtcTimeOnly endTime,
int  startDay = -1,
int  endDay = -1
 

Definition at line 32 of file SessionTime.cpp.

References m_endTime, and m_startTime.

00036   : m_startTime( startTime ), m_endTime( endTime ),
00037     m_startDay( startDay ), m_endDay( endDay )
00038   {
00039     if( startDay > 0
00040         && endDay > 0
00041         && startDay == endDay
00042         && endTime > startTime )
00043     { m_endTime = m_startTime; }
00044   }


Member Function Documentation

bool FIX::SessionTime::isSameSession const UtcTimeStamp time1,
const UtcTimeStamp time2
[inline]
 

Definition at line 71 of file SessionTime.h.

References isSameSession(), m_endDay, m_endTime, m_startDay, and m_startTime.

00072   {
00073     if( m_startDay < 0 && m_endDay < 0 )
00074       return isSameSession( m_startTime, m_endTime, time1, time2 );
00075     else
00076       return isSameSession
00077         ( m_startTime, m_endTime, m_startDay, m_endDay, time1, time2 );
00078   }

bool FIX::SessionTime::isSameSession const UtcTimeOnly startTime,
const UtcTimeOnly endTime,
int  startDay,
int  endDay,
const UtcTimeStamp time1,
const UtcTimeStamp time2
[static]
 

Definition at line 139 of file SessionTime.cpp.

References FIX::DateTime::getJulianDate(), FIX::DateTime::getWeekDay(), isSessionTime(), QF_STACK_POP, and QF_STACK_PUSH.

00145   { QF_STACK_PUSH(SessionTime::isSameSession)
00146 
00147     if( !isSessionTime( startTime, endTime, startDay, endDay, time1 ) )
00148       return false;
00149 
00150     if( !isSessionTime( startTime, endTime, startDay, endDay, time2 ) )
00151       return false;
00152 
00153     int absoluteDay1 = time1.getJulianDate() - time1.getWeekDay();
00154     int absoluteDay2 = time2.getJulianDate() - time2.getWeekDay();
00155     return absoluteDay1 == absoluteDay2;
00156 
00157     QF_STACK_POP
00158   }

bool FIX::SessionTime::isSameSession const UtcTimeOnly start,
const UtcTimeOnly end,
const UtcTimeStamp time1,
const UtcTimeStamp time2
[static]
 

Definition at line 98 of file SessionTime.cpp.

References isSessionTime(), QF_STACK_POP, and QF_STACK_PUSH.

Referenced by FIX::Session::checkSessionTime(), and isSameSession().

00102   { QF_STACK_PUSH(SessionTime::isSameSession)
00103 
00104     if( !isSessionTime( start, end, time1 ) ) return false;
00105     if( !isSessionTime( start, end, time2 ) ) return false;
00106 
00107     if( time1 == time2 ) return true;
00108 
00109     if( start < end || start == end )
00110     {
00111       UtcDate time1Date( time1 );
00112       UtcDate time2Date( time2 );
00113  
00114       return time1Date == time2Date;
00115     }
00116     else
00117     {
00118       int sessionLength = DateTime::SECONDS_PER_DAY - (start - end);
00119 
00120       if( time1 > time2 )
00121       {
00122         UtcTimeOnly time2TimeOnly = UtcTimeOnly(time2);
00123                   
00124         long delta = time2TimeOnly - start;
00125         if( delta < 0 )
00126           delta = DateTime::SECONDS_PER_DAY - labs(delta);
00127 
00128         return (time1 - time2) < (sessionLength - delta);
00129       }
00130       else
00131       {
00132         return (time2 - time1) < sessionLength;
00133       }
00134     }
00135         
00136     QF_STACK_POP
00137   }

bool FIX::SessionTime::isSessionTime  )  [inline]
 

Definition at line 62 of file SessionTime.h.

References m_endDay, m_endTime, m_startDay, and m_startTime.

Referenced by isSameSession().

00063   {
00064     if( m_startDay < 0 && m_endDay < 0 )
00065       return isSessionTime( m_startTime, m_endTime, UtcTimeStamp() );
00066     else
00067       return isSessionTime
00068         ( m_startTime, m_endTime, m_startDay, m_endDay, UtcTimeStamp() );
00069   }

bool FIX::SessionTime::isSessionTime const UtcTimeOnly startTime,
const UtcTimeOnly endTime,
int  startDay,
int  endDay,
const UtcTimeStamp time
[static]
 

Definition at line 61 of file SessionTime.cpp.

References FIX::DateTime::getWeekDay(), QF_STACK_POP, and QF_STACK_PUSH.

00066   { QF_STACK_PUSH(SessionTime::isSessionTime)
00067 
00068     int currentDay = time.getWeekDay();
00069     UtcTimeOnly timeOnly (time);
00070 
00071     if( startDay == endDay )
00072     {
00073       if( timeOnly < startTime && timeOnly > endTime )
00074         return false;
00075     }
00076     else if( startDay < endDay )
00077     {
00078       if( currentDay < startDay || currentDay > endDay )
00079         return false;
00080       else if( currentDay == startDay && timeOnly < startTime )
00081         return false;
00082       else if( currentDay == endDay && timeOnly > endTime )
00083         return false;
00084     }
00085     else if( startDay > endDay )
00086     {
00087       if( currentDay < startDay && currentDay > endDay )
00088         return false;
00089       else if( currentDay == startDay && timeOnly < startTime )
00090         return false;
00091       else if( currentDay == endDay && timeOnly > endTime )
00092         return false;
00093     }
00094     return true;
00095     QF_STACK_POP
00096   }

bool FIX::SessionTime::isSessionTime const UtcTimeOnly start,
const UtcTimeOnly end,
const UtcTimeStamp time
[static]
 

Definition at line 46 of file SessionTime.cpp.

References QF_STACK_POP, and QF_STACK_PUSH.

Referenced by FIX::Session::isSessionTime().

00049   { QF_STACK_PUSH(SessionTime::isSessionTime)
00050 
00051     UtcTimeOnly timeOnly (time);
00052 
00053     if( start < end )
00054       return( timeOnly >= start && timeOnly <= end );
00055     else
00056       return( timeOnly >= start || timeOnly <= end );
00057 
00058     QF_STACK_POP
00059   }


Member Data Documentation

int FIX::SessionTime::m_endDay [private]
 

Definition at line 84 of file SessionTime.h.

Referenced by isSameSession(), and isSessionTime().

UtcTimeOnly FIX::SessionTime::m_endTime [private]
 

Definition at line 82 of file SessionTime.h.

Referenced by isSameSession(), isSessionTime(), and SessionTime().

int FIX::SessionTime::m_startDay [private]
 

Definition at line 83 of file SessionTime.h.

Referenced by isSameSession(), and isSessionTime().

UtcTimeOnly FIX::SessionTime::m_startTime [private]
 

Definition at line 81 of file SessionTime.h.

Referenced by isSameSession(), isSessionTime(), and SessionTime().


The documentation for this class was generated from the following files:
Generated on Mon Jul 24 19:36:50 2006 for QuickFIX by doxygen 1.3.6-20040222 written by Dimitri van Heesch, © 1997-2001