WvStreams
wvdailyevent.h
1 /* -*- Mode: C++ -*-
2  * Worldvisions Weaver Software:
3  * Copyright (C) 1997-2002 Net Integration Technologies, Inc.
4  *
5  * A period event stream.
6  */
7 
8 #ifndef __WVDAILYEVENT_H
9 #define __WVDAILYEVENT_H
10 
11 #include "wvstream.h"
12 
29 class WvDailyEvent : public WvStream
30 /**********************************/
31 {
32 public:
44  WvDailyEvent( int _first_hour, int _num_per_day=0, bool _skip_first=true );
45 
53  virtual void pre_select( SelectInfo& si );
54  virtual bool post_select( SelectInfo& si );
55 
66  void configure( int _first_hour, int _num_per_day=0, bool _skip_first=true );
67 
69  void set_num_per_day(int _num_per_day);
70 
75  void set_hour( int h )
76  { configure( h, num_per_day ); }
77 
79  time_t next_event() const;
80 
81 private:
82  int first_hour;
83  int num_per_day;
84  bool need_reset;
85  bool skip_first;
86  time_t prev;
87 
88  time_t not_until;
89 
90 public:
91  const char *wstype() const { return "WvDailyEvent"; }
92 };
93 
94 #endif
WvDailyEvent::set_num_per_day
void set_num_per_day(int _num_per_day)
Set number of times per day the event should occur - ONLY FOR TESTING!
Definition: wvdailyevent.cc:83
WvDailyEvent::configure
void configure(int _first_hour, int _num_per_day=0, bool _skip_first=true)
Modifies the first hour in which the event should occur and the number of times the event should occu...
Definition: wvdailyevent.cc:102
WvDailyEvent::post_select
virtual bool post_select(SelectInfo &si)
post_select() is called after ::select(), and returns true if this object is now ready.
Definition: wvdailyevent.cc:69
WvDailyEvent::WvDailyEvent
WvDailyEvent(int _first_hour, int _num_per_day=0, bool _skip_first=true)
Constructs WvDailyEvent.
Definition: wvdailyevent.cc:29
WvDailyEvent::set_hour
void set_hour(int h)
Modifies the first hour in which the event should occur and leaves the number of times per day unmodi...
Definition: wvdailyevent.h:75
IWvStream::SelectInfo
the data structure used by pre_select()/post_select() and internally by select().
Definition: iwvstream.h:50
WvStream
Unified support for streams, that is, sequences of bytes that may or may not be ready for read/write ...
Definition: wvstream.h:24
WvDailyEvent::pre_select
virtual void pre_select(SelectInfo &si)
Munges SelectInfo such that the stream will select when the time is right for the event to occur.
Definition: wvdailyevent.cc:39
WvDailyEvent
A simple class that can trigger an event on a timed basis.
Definition: wvdailyevent.h:29
WvDailyEvent::next_event
time_t next_event() const
return the time when the next event will occur
Definition: wvdailyevent.cc:117