0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Hypertable::Crontab Class Reference

Tracks timing of periodic events. More...

#include <Crontab.h>

Collaboration diagram for Hypertable::Crontab:
Collaboration graph
[legend]

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_entryentry ()
 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
 

Detailed Description

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.

Definition at line 55 of file Crontab.h.

Constructor & Destructor Documentation

Hypertable::Crontab::Crontab ( )
inline

Default constructor.

Definition at line 59 of file Crontab.h.

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 * * *"
See also
Common/tests/crontab_test.cc for more examples.
Parameters
specThe crontab string describing the time interval
Exceptions
Error::COMMAND_PARSE_ERRORif the spec cannot be parsed

Definition at line 42 of file Crontab.cc.

Member Function Documentation

crontab_entry& Hypertable::Crontab::entry ( )
inline

Get the internal crontab_entry structure.

Note
Required for testing

Definition at line 83 of file Crontab.h.

time_t Crontab::next_event ( time_t  now)

Retrieves the timestamp of the next event.

Parameters
nowThe current time, in seconds since the epoch
Returns
The absolute time of the next event, in seconds since the epoch

Definition at line 46 of file Crontab.cc.

void Crontab::next_matching_day ( struct tm *  next_tm,
bool  increment 
)
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.

Parameters
next_tmStructure holding starting date and modified to hold the next day the event will occur
incrementIncrement next_tm by one day on entry to function

Definition at line 92 of file Crontab.cc.

void Crontab::parse_entry ( const String spec,
crontab_entry _entry 
)
private

Parses a crontab spec into a crontab_entry.

Parameters
specCrontab spec
_entryBinary crontab specification filled in by function

Definition at line 121 of file Crontab.cc.

template<int N>
void Crontab::parse_range ( const String spec,
std::bitset< N > &  bits,
bool  zero_based = true 
)
private

Parses a crontab field and sets corresponding bits in bits.

Template Parameters
NSizeof bits
Parameters
specCrontab field
bitsBit set to populate
zero_basedIndicates is crontab field is zero or one based.

Definition at line 206 of file Crontab.cc.

Member Data Documentation

crontab_entry Hypertable::Crontab::m_entry
private

Definition at line 111 of file Crontab.h.


The documentation for this class was generated from the following files: