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
29class WvDailyEvent : public WvStream
30/**********************************/
31{
32public:
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
81private:
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
90public:
91 const char *wstype() const { return "WvDailyEvent"; }
92};
93
94#endif
A simple class that can trigger an event on a timed basis.
void set_hour(int h)
Modifies the first hour in which the event should occur and leaves the number of times per day unmodi...
void set_num_per_day(int _num_per_day)
Set number of times per day the event should occur - ONLY FOR TESTING!
virtual void pre_select(SelectInfo &si)
Munges SelectInfo such that the stream will select when the time is right for the event to occur.
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...
virtual bool post_select(SelectInfo &si)
post_select() is called after select(), and returns true if this object is now ready.
time_t next_event() const
return the time when the next event will occur
Unified support for streams, that is, sequences of bytes that may or may not be ready for read/write ...
Definition wvstream.h:25
the data structure used by pre_select()/post_select() and internally by select().
Definition iwvstream.h:50