fix8  version 1.4.0
Open Source C++ FIX Framework
FIX8::Schedule Struct Reference

#include <session.hpp>

Public Member Functions

 Schedule ()
 
 Schedule (Tickval start, Tickval end, Tickval duration=Tickval(), int utc_offset=0, int start_day=-1, int end_day=-1)
 
 Schedule (const Schedule &from)
 
Scheduleoperator= (const Schedule &that)
 
bool is_valid () const
 
bool test (bool prev=false) const
 

Public Attributes

Tickval _start
 
Tickval _end
 
Tickval _duration
 
int _utc_offset
 
int _start_day
 
int _end_day
 
Tickval::ticks _toffset
 

Friends

std::ostream & operator<< (std::ostream &os, const Schedule &what)
 

Detailed Description

Definition at line 200 of file session.hpp.

Constructor & Destructor Documentation

FIX8::Schedule::Schedule ( )
inline

Definition at line 206 of file session.hpp.

207  _start_day(-1), _end_day(-1) {}
static const ticks & errorticks()
Definition: tickval.hpp:69
Tickval _start
Definition: session.hpp:202
Tickval _end
Definition: session.hpp:202
FIX8::Schedule::Schedule ( Tickval  start,
Tickval  end,
Tickval  duration = Tickval(),
int  utc_offset = 0,
int  start_day = -1,
int  end_day = -1 
)
inline

Definition at line 209 of file session.hpp.

210  :
211  _start(start), _end(end), _duration(duration),
212  _utc_offset(utc_offset), _start_day(start_day), _end_day(end_day),
213  _toffset(static_cast<Tickval::ticks>(_utc_offset) * Tickval::minute)
214  {
215  }
Tickval _duration
Definition: session.hpp:202
static const ticks minute
Definition: tickval.hpp:79
Tickval::ticks _toffset
Definition: session.hpp:204
Tickval _start
Definition: session.hpp:202
Tickval _end
Definition: session.hpp:202
FIX8::Schedule::Schedule ( const Schedule from)
inline

Definition at line 217 of file session.hpp.

217  :
218  _start(from._start), _end(from._end), _duration(from._duration),
219  _utc_offset(from._utc_offset), _start_day(from._start_day), _end_day(from._end_day),
220  _toffset(from._toffset)
221  {
222  }
Tickval _duration
Definition: session.hpp:202
Tickval::ticks _toffset
Definition: session.hpp:204
Tickval _start
Definition: session.hpp:202
Tickval _end
Definition: session.hpp:202

Member Function Documentation

bool FIX8::Schedule::is_valid ( ) const
inline

Determine if this schdule is valid

Returns
true if this schedule is valid

Definition at line 242 of file session.hpp.

References FIX8::Tickval::is_errorval().

Referenced by FIX8::Session::handle_logon().

242 { return !_start.is_errorval(); }
bool is_errorval() const
Definition: tickval.hpp:173
Tickval _start
Definition: session.hpp:202
Schedule& FIX8::Schedule::operator= ( const Schedule that)
inline

Definition at line 224 of file session.hpp.

References _duration, _end, _end_day, _start, _start_day, _toffset, and _utc_offset.

225  {
226  if (this != &that)
227  {
228  _start = that._start;
229  _end = that._end;
230  _duration = that._duration;
231  _utc_offset = that._utc_offset;
232  _start_day = that._start_day;
233  _end_day = that._end_day;
234  _toffset = that._toffset;
235  }
236 
237  return *this;
238  }
Tickval _duration
Definition: session.hpp:202
Tickval::ticks _toffset
Definition: session.hpp:204
Tickval _start
Definition: session.hpp:202
Tickval _end
Definition: session.hpp:202
bool FIX8::Schedule::test ( bool  prev = false) const
inline

Take the current local time and test if it is within the range of this schedule

Parameters
prevcurrent bool state that we will toggle
Returns
new toggle state

Definition at line 247 of file session.hpp.

References _end, FIX8::Tickval::adjust(), FIX8::Tickval::day, FIX8::Tickval::get_ticks(), FIX8::Tickval::get_tm(), and FIX8::Tickval::in_range().

Referenced by FIX8::Session::activation_service(), and FIX8::Session::handle_logon().

248  {
249  Tickval now(true);
250  now.adjust(_toffset); // adjust for local utc offset
251  const Tickval today(now.get_ticks() - (now.get_ticks() % Tickval::day));
252  bool active(prev);
253 
254  if (_start_day < 0) // start/end day not specified; daily only
255  {
256  //cout >> now << ' ' >> (today + _start) << ' ' >> (today + _end) << endl;
257 
258  if (now.in_range(today + _start, today + _end))
259  {
260  if (!prev)
261  active = true;
262  }
263  else if (prev)
264  active = false;
265  }
266  else
267  {
268  const tm result(now.get_tm());
269 
270  //cout >> now << ' ' >> (today + _start) << ' ' >> (today + _end) << ' ' << result.tm_wday << endl;
271 
272  if (!prev)
273  {
274  if ( ((_start_day > _end_day && (result.tm_wday >= _start_day || result.tm_wday <= _end_day))
275  || (_start_day < _end_day && result.tm_wday >= _start_day && result.tm_wday <= _end_day))
276  && now.in_range(today + _start, today + _end))
277  active = true;
278  }
279  else if ( ((_start_day > _end_day && (result.tm_wday < _start_day && result.tm_wday > _end_day))
280  || (_start_day < _end_day && result.tm_wday >= _end_day))
281  && now > today + _end)
282  active = false;
283  }
284 
285  return active;
286  }
static const ticks day
Definition: tickval.hpp:81
Tickval::ticks _toffset
Definition: session.hpp:204
Tickval _start
Definition: session.hpp:202
Tickval _end
Definition: session.hpp:202

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const Schedule what 
)
friend

Inserter friend.

Parameters
osstream to send to
whatSession_Schedule reference
Returns
stream

Definition at line 292 of file session.hpp.

293  {
294  os << "start:" >> what._start << " end:" >> what._end << " duration:" << what._duration
295  << " utc_offset:" << what._utc_offset << " start day:" << what._start_day << " end day:" << what._end_day;
296  return os;
297  }

Member Data Documentation

Tickval FIX8::Schedule::_duration

Definition at line 202 of file session.hpp.

Referenced by operator=().

Tickval FIX8::Schedule::_end

Definition at line 202 of file session.hpp.

Referenced by operator=(), and test().

int FIX8::Schedule::_end_day

Definition at line 203 of file session.hpp.

Referenced by operator=().

Tickval FIX8::Schedule::_start

Definition at line 202 of file session.hpp.

Referenced by operator=().

int FIX8::Schedule::_start_day

Definition at line 203 of file session.hpp.

Referenced by operator=().

Tickval::ticks FIX8::Schedule::_toffset

Definition at line 204 of file session.hpp.

Referenced by operator=().

int FIX8::Schedule::_utc_offset

Definition at line 203 of file session.hpp.

Referenced by operator=().


The documentation for this struct was generated from the following file: