00001 /* 00002 * Worldvisions Weaver Software: 00003 * Copyright (C) 1997-2002 Net Integration Technologies, Inc. 00004 * 00005 * A simple class that can trigger an event on a timed basis. 00006 * - if given an hour, triggers once per day, on that hour. 00007 * - if given a number of times per day, triggers that many times per 00008 * day, evenly, starting at midnight. (Needed to get a Microbackup 00009 * going every 15 minutes.) 00010 * 00011 * Presently has a one-hour granularity in the first case, but that can be 00012 * extended one day when someone cares. 00013 * 00014 */ 00015 00016 #ifndef __WVDAILYEVENT_H 00017 #define __WVDAILYEVENT_H 00018 00019 #include "wvstream.h" 00020 00021 class WvDailyEvent : public WvStream 00022 /**********************************/ 00023 { 00024 public: 00025 WvDailyEvent( int _first_hour, int _num_per_day=0 ); 00026 00027 virtual bool pre_select( SelectInfo& si ); 00028 virtual bool post_select( SelectInfo& si ); 00029 00030 // execute() and any overridden versions of it must call reset(). 00031 virtual void execute(); 00032 void reset(); 00033 00034 virtual bool isok() const; 00035 00036 void configure( int _first_hour, int _num_per_day=0 ); 00037 void set_hour( int h ) 00038 { configure( h, num_per_day ); } 00039 00040 private: 00041 int first_hour; 00042 int num_per_day; 00043 bool need_reset; 00044 int last_hour; 00045 int last_minute; 00046 }; 00047 00048 #endif