Tracks timing of periodic events. More...
#include <Crontab.h>
Public Member Functions | |
Crontab () | |
Default constructor. More... | |
Crontab (const String &spec) | |
Constructor initialized with crontab(5) entry. More... | |
time_t | next_event (time_t now) |
Retrieves the timestamp of the next event. More... | |
crontab_entry & | entry () |
Get the internal crontab_entry structure. More... | |
Private Member Functions | |
void | next_matching_day (struct tm *next_tm, bool increment) |
Determines next day on which event will occur. More... | |
void | parse_entry (const String &spec, crontab_entry *_entry) |
Parses a crontab spec into a crontab_entry. More... | |
template<int N> | |
void | parse_range (const String &spec, std::bitset< N > &bits, bool zero_based=true) |
Parses a crontab field and sets corresponding bits in bits . More... | |
Private Attributes | |
crontab_entry | m_entry |
Tracks timing of periodic events.
The Crontab class is used to track the timing of a periodic event. It is constructed with a string argument that has the format of first five fields (date/time fields) of a crontab entry and is used to determine at what time an event should occcur.
|
inline |
Crontab::Crontab | ( | const String & | spec | ) |
Constructor initialized with crontab(5) entry.
initializes the Crontab from a string which is formatted like a regular unix crontab entry:
"1 1 * * * *" "1-2/2/4 1 * * *" "2-1 1 * * *" "1-8/ 1 * * *"
Common/tests/crontab_test.cc
for more examples. spec | The crontab string describing the time interval |
Error::COMMAND_PARSE_ERROR | if the spec cannot be parsed |
Definition at line 42 of file Crontab.cc.
|
inline |
Get the internal crontab_entry structure.
time_t Crontab::next_event | ( | time_t | now | ) |
Retrieves the timestamp of the next event.
now | The current time, in seconds since the epoch |
Definition at line 46 of file Crontab.cc.
|
private |
Determines next day on which event will occur.
Using the date passed in through next_tm
as the starting date, modifies it to hold the day in which the next event will occur. The tm_hour
, tm_min
, and tm_sec
fields are cleared.
next_tm | Structure holding starting date and modified to hold the next day the event will occur |
increment | Increment next_tm by one day on entry to function |
Definition at line 92 of file Crontab.cc.
|
private |
Parses a crontab spec into a crontab_entry.
spec | Crontab spec |
_entry | Binary crontab specification filled in by function |
Definition at line 121 of file Crontab.cc.
|
private |
Parses a crontab field and sets corresponding bits in bits
.
N | Sizeof bits |
spec | Crontab field |
bits | Bit set to populate |
zero_based | Indicates is crontab field is zero or one based. |
Definition at line 206 of file Crontab.cc.
|
private |