Datafile: Removed exclusions

This commit is contained in:
Paul Beckingham 2016-04-27 18:05:37 -04:00
parent 9c91cb599b
commit db3c3fb14c
2 changed files with 6 additions and 42 deletions

View file

@ -83,20 +83,6 @@ std::vector <std::string> Datafile::allLines ()
return _lines; return _lines;
} }
////////////////////////////////////////////////////////////////////////////////
void Datafile::setExclusions (const std::vector <std::string>& exclusions)
{
// TODO Overwrite local copy
// TODO load current exclusion set
// TODO if local copy != exclusion set
// TODO remove old exclusion set from _lines
// TODO add local copy
// TODO _dirty = true;
// TODO New exclusions should always be written.
_exclusions = exclusions;
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Accepted intervals; day1 <= interval.start < dayN // Accepted intervals; day1 <= interval.start < dayN
void Datafile::addInterval (const Interval& interval) void Datafile::addInterval (const Interval& interval)
@ -108,9 +94,6 @@ void Datafile::addInterval (const Interval& interval)
if (! _lines_loaded) if (! _lines_loaded)
load_lines (); load_lines ();
// TODO if _lines contains no exclusions
// TODO add _exclusions
// TODO if interval is not a duplicate // TODO if interval is not a duplicate
// TODO insert interval.serialize into _lines // TODO insert interval.serialize into _lines
// TODO _dirty = true; // TODO _dirty = true;
@ -173,7 +156,6 @@ std::string Datafile::dump () const
<< " dirty: " << (_dirty ? "true" : "false") << '\n' << " dirty: " << (_dirty ? "true" : "false") << '\n'
<< " lines: " << _lines.size () << '\n' << " lines: " << _lines.size () << '\n'
<< " loaded " << (_lines_loaded ? "true" : "false") << '\n' << " loaded " << (_lines_loaded ? "true" : "false") << '\n'
<< " exclusions: " << _exclusions.size () << '\n'
<< " range: " << _range.start.toISO () << " - " << " range: " << _range.start.toISO () << " - "
<< _range.end.toISO () << '\n'; << _range.end.toISO () << '\n';
@ -187,27 +169,11 @@ void Datafile::load_lines ()
{ {
_file.lock (); _file.lock ();
// File::read calls read_lines.clear (), so this prevents the exclsions from // Load the data.
// being discarded.
std::vector <std::string> read_lines; std::vector <std::string> read_lines;
_file.read (read_lines); _file.read (read_lines);
_file.close (); _file.close ();
bool hasExclusions = false;
for (auto& line : read_lines)
{
if (line[0] == 'e')
{
hasExclusions = true;
break;
}
}
// Add the exclusions to new files.
if (! hasExclusions)
for (auto& e : _exclusions)
_lines.push_back (e);
// Append the lines that were read. // Append the lines that were read.
for (auto& line : read_lines) for (auto& line : read_lines)
_lines.push_back (line); _lines.push_back (line);

View file

@ -43,7 +43,6 @@ public:
std::string lastLine (); std::string lastLine ();
std::vector <std::string> allLines (); std::vector <std::string> allLines ();
void setExclusions (const std::vector <std::string>&);
void addInterval (const Interval&); void addInterval (const Interval&);
void deleteInterval (const Interval&); void deleteInterval (const Interval&);
void commit (); void commit ();
@ -54,12 +53,11 @@ private:
void load_lines (); void load_lines ();
private: private:
File _file {}; File _file {};
bool _dirty {false}; bool _dirty {false};
std::vector <std::string> _lines {}; std::vector <std::string> _lines {};
bool _lines_loaded {false}; bool _lines_loaded {false};
std::vector <std::string> _exclusions {}; Range _range {};
Range _range {};
}; };
#endif #endif