00001
00010 #ifndef _TAPE_SCHEDULE_H
00011 #define _TAPE_SCHEDULE_H
00012
00013
00014
00015 #include "tape.h"
00016
00017 EXPORT void new_schedule(MODULE *mod);
00018
00019 class range_list{
00020 public:
00021 int min, max;
00022 int children;
00023 range_list *next;
00024
00025 range_list(int lo, int hi, range_list *list=0){min = lo; max = hi; next = list; children = -1;}
00026 ~range_list(){if(next != 0){delete next;}}
00027
00028
00029 int get_count(){if(children < 0) return count(); else return children+1;}
00030 int count(){if(next != 0){children = next->count(); return children+1;} else {children = 0; return 1;}}
00031
00032
00033 int check(int lo, int hi){return (next ? next->check(lo, hi) : 1) && (min >= lo && max <= hi);}
00034 };
00035
00036 range_list *cron_part(char *, int);
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053 class schedule_list {
00054 public:
00055 static const int wor_skip = 0;
00056 static const int wor_week = 1;
00057 static const int wor_month = 2;
00058 static const int wor_both = 3;
00059 schedule_list *next, *group_left, *group_right;
00060 int moh_start, moh_end;
00061 int hod_start, hod_end;
00062 int dom_start, dom_end;
00063 int dow_start, dow_end;
00064 int moy_start, moy_end;
00065 double scale;
00066 int dow_or_dom;
00067 public:
00068 schedule_list();
00069 schedule_list(range_list *, range_list *, range_list *, range_list *, range_list *, double);
00070 ~schedule_list();
00071 };
00072
00073
00074
00075
00076
00077 schedule_list *parse_cron(char *);
00078
00079 schedule_list *new_slist();
00080 int delete_slist(schedule_list *);
00081
00082 class schedule {
00083 private:
00084 int parse_schedule();
00085 int open_sched_file();
00086
00087 schedule_list *sched_list;
00088 public:
00089 double currval;
00090 double default_value;
00091 TIMESTAMP next_ts;
00092 TAPESTATUS state;
00093 char256 errmsg;
00094 char256 filename;
00095 char1024 sched;
00096 public:
00097 static CLASS *oclass;
00098 static schedule *defaults;
00099
00100 schedule(MODULE *module);
00101 int create();
00102 int init(OBJECT *parent);
00103 TIMESTAMP presync(TIMESTAMP t0, TIMESTAMP t1);
00104 TIMESTAMP sync(TIMESTAMP t0, TIMESTAMP t1);
00105
00106 };
00107
00108 #endif // _SCHEDULE_H
00109