Remoto - VFS: VFS_cron.h Source File
Remoto - VFS
VFS_cron.h
Go to the documentation of this file.
1 #ifndef VFS_CRON_H
2 #define VFS_CRON_H
3 
4 #include <bitset>
5 
6 #include "VFS_base/VFS_node.h"
7 
8 class VFS_cron : public VFS_node
9 {
10  Q_OBJECT
11 
12  public:
13  Q_INVOKABLE explicit VFS_cron(QString crontab);//, QString settings);
14  virtual ~VFS_cron();
15 
16  virtual VFS_node *find(VFS_request *r);
17 
18  virtual QString reportDetails();
19 
20  virtual bool isContainer();
21 
22  private:
23  class crontime
24  {
25  public:
26  crontime(QString time="");
27 
28  bool matches(quint8 s, quint8 m, quint8 h, quint8 d, quint8 mo, quint8 w, quint16 y);
29  bool valid();
30  QString toString() const;
31  QString toCrontime() const;
32 
33  private:
34  bool _valid;
35 
36  std::bitset<60> _seconds;
37  std::bitset<60> _minutes;
38  std::bitset<24> _hours;
39  std::bitset<32> _dates;
40  std::bitset<13> _months;
41  std::bitset<7> _weekdays;
42  QList<quint16> _years;
43 
44  quint64 parseField(QString field);
45  quint64 parseRange(QString range);
46  QList<quint16> parseYear(QString y);
47 
48  QString toCrontimeString(QString which) const;
49  };
50 
51  protected:
52  QMultiMap<QString, crontime> _crontab;
53  int _cronID;
54 
55  virtual QByteArray icon();
56 
57  virtual void timerEvent(QTimerEvent *event);
58 
59  virtual void subscribe(VFS_request *r);
60  virtual void unsubscribe(VFS_request *r);
61 
62  virtual void ls(VFS_request *r);
63  virtual void read(VFS_request *r);
64  //virtual void write(VFS_request *r); //FIXME: should implement!
65  //virtual void metadata(VFS_request *r);
66  //virtual void report(VFS_request *r);
67  //virtual void submit(VFS_request *r);
68  //virtual void rm(VFS_request *r);
69 
70  private:
71  virtual void parseCrontab(QString tab);
72 
73  protected slots:
74  virtual void initialize();
75  virtual void startCron();
76 };
77 
78 #endif // VFS_CRON_H
A class to represent a crontime, which can be matched against a (current) time to see if it is active...
Definition: VFS_cron.h:24
bool valid()
Vailidty of a VFS_cron::crontime.
Definition: VFS_cron.cpp:598
std::bitset< 60 > _minutes
bitset of minutes
Definition: VFS_cron.h:37
bool _valid
Is the crontime valid?
Definition: VFS_cron.h:34
crontime(QString time="")
Definition: VFS_cron.cpp:453
QList< quint16 > parseYear(QString y)
Parse the year component of a crontime string.
Definition: VFS_cron.cpp:543
std::bitset< 7 > _weekdays
bitset of weekdays
Definition: VFS_cron.h:41
QString toString() const
A pretty print version of a crontime.
Definition: VFS_cron.cpp:636
quint64 parseRange(QString range)
Parse a range component from a crontime string.
Definition: VFS_cron.cpp:497
std::bitset< 24 > _hours
bitset of hours
Definition: VFS_cron.h:38
QList< quint16 > _years
list of years
Definition: VFS_cron.h:42
std::bitset< 60 > _seconds
bitset of seconds
Definition: VFS_cron.h:36
std::bitset< 32 > _dates
bitset of dates
Definition: VFS_cron.h:39
QString toCrontime() const
Create a parseable crontime string.
Definition: VFS_cron.cpp:667
bool matches(quint8 s, quint8 m, quint8 h, quint8 d, quint8 mo, quint8 w, quint16 y)
Check if a crontime matches.
Definition: VFS_cron.cpp:614
QString toCrontimeString(QString which) const
Generate a crontime string component.
Definition: VFS_cron.cpp:688
quint64 parseField(QString field)
VFS_cron::crontime::parseField.
Definition: VFS_cron.cpp:479
std::bitset< 13 > _months
bitset of months
Definition: VFS_cron.h:40
VFS_cron will emit diffs to subscribers based on wall-clock time.
Definition: VFS_cron.h:9
virtual void unsubscribe(VFS_request *r)
Definition: VFS_cron.cpp:435
virtual QString reportDetails()
Definition: VFS_cron.cpp:162
virtual QByteArray icon()
Return the clock icon from VFS_icons.
Definition: VFS_cron.cpp:194
virtual void parseCrontab(QString tab)
Definition: VFS_cron.cpp:300
virtual bool isContainer()
A VFS_cron node cannot contain children, however listing the contents will return the entry list.
Definition: VFS_cron.cpp:184
virtual void subscribe(VFS_request *r)
Definition: VFS_cron.cpp:330
virtual ~VFS_cron()
Definition: VFS_cron.cpp:126
virtual void timerEvent(QTimerEvent *event)
Scan the event map for entries that match the current time.
Definition: VFS_cron.cpp:248
Q_INVOKABLE VFS_cron(QString crontab)
Definition: VFS_cron.cpp:115
int _cronID
the timerID of the cron node
Definition: VFS_cron.h:53
virtual VFS_node * find(VFS_request *r)
Definition: VFS_cron.cpp:138
virtual void initialize()
Schedule a start for the scheduler.
Definition: VFS_cron.cpp:207
virtual void startCron()
Start the scheduler.
Definition: VFS_cron.cpp:228
virtual void read(VFS_request *r)
Read or list the event entries.
Definition: VFS_cron.cpp:389
virtual void ls(VFS_request *r)
List all entries in the crontab by name.
Definition: VFS_cron.cpp:373
QMultiMap< QString, crontime > _crontab
map of "event:crontime" fields
Definition: VFS_cron.h:52
VFS_node is the base class from which all other VFS_node classes derive.
Definition: VFS_node.h:143
The base class for all requests between nodes.
Definition: VFS_node.h:54