Exclusion: Added ::intervals and sub-method stubs

This commit is contained in:
Paul Beckingham 2016-03-30 23:18:18 -04:00
parent 345a813be8
commit 53aa740480
2 changed files with 61 additions and 1 deletions

View file

@ -35,7 +35,8 @@
// and lunch. By default there are none, but they may be configured. Once there
// are exclusions defined, the :fill functionality is enabled.
//
// Exclusions are instantiated from the 'define exclusions:' rule.
// Exclusions are instantiated from the 'define exclusions:' rule. This method
// simply validates.
//
// Syntax:
// exc holidays en-US
@ -99,3 +100,54 @@ std::vector <std::string> Exclusion::tokens () const
}
////////////////////////////////////////////////////////////////////////////////
// A single exclusion directive is expanded to a tuple of start/end timestamps,
// when evaluated within a closed range. These tuples represent windows of time
// that are not available for tracking.
std::vector <Interval> Exclusion::intervals (
const Interval& interval) const
{
if (_tokens[1] == "holidays") return expandIntervalsHolidays (interval);
else if (_tokens[1] == "work") return expandIntervalsWork (interval);
else if (_tokens[1] == "week") return expandIntervalsWeek (interval);
else if (_tokens[1] == "day") return expandIntervalsDay (interval);
throw std::string ("Exclusion is not initialized.");
}
////////////////////////////////////////////////////////////////////////////////
std::vector <Interval> Exclusion::expandIntervalsHolidays (
const Interval& interval) const
{
std::vector <Interval> result;
return result;
}
////////////////////////////////////////////////////////////////////////////////
std::vector <Interval> Exclusion::expandIntervalsWork (
const Interval& interval) const
{
std::vector <Interval> result;
return result;
}
////////////////////////////////////////////////////////////////////////////////
std::vector <Interval> Exclusion::expandIntervalsWeek (
const Interval& interval) const
{
std::vector <Interval> result;
return result;
}
////////////////////////////////////////////////////////////////////////////////
std::vector <Interval> Exclusion::expandIntervalsDay (
const Interval& interval) const
{
std::vector <Interval> result;
return result;
}
////////////////////////////////////////////////////////////////////////////////

View file

@ -27,6 +27,7 @@
#ifndef INCLUDED_EXCLUSION
#define INCLUDED_EXCLUSION
#include <Interval.h>
#include <vector>
#include <string>
@ -36,6 +37,13 @@ public:
Exclusion () = default;
void initialize (const std::string&);
std::vector <std::string> tokens () const;
std::vector <Interval> intervals (const Interval&) const;
private:
std::vector <Interval> expandIntervalsHolidays (const Interval&) const;
std::vector <Interval> expandIntervalsWork (const Interval&) const;
std::vector <Interval> expandIntervalsWeek (const Interval&) const;
std::vector <Interval> expandIntervalsDay (const Interval&) const;
private:
std::vector <std::string> _tokens;