taskwarrior/src/TDB2.h
Paul Beckingham 79e2c591f1 Bug #1022
- Fixed bug #1022, where dependencies were note released when a blocking task
  was completed (thanks to Arkady Grudzinsky).
- The Task object now caches ::is_blocked and ::is_blocking Booleans that are
  determined on pending.data load.
- Simplified and sped up color rule processing using cached values, reducing
  the number of map lookups, and removed loop invariants when the rules are
  not defined.
- Simplified urgency calculations given the cached values for blocked/blocking.
- On load, pending.data is scanned for accurate blocked/blocking status
  determination.
- Obsoleted and removed complex single-task dependency calculations.
- Sped up 'nag' processing by using cached values..
- Modified the 'show' command to consider color.blocking to be valid.
- Added default config value for color.blocking, and included it in the
  precedence list ahead of blocked, as it is more important.
- Updated taskrc.5 man page to include the new color.blocking rule, and its
  place in the rule precedence.
2012-07-09 01:29:51 -04:00

145 lines
3.7 KiB
C++

////////////////////////////////////////////////////////////////////////////////
// taskwarrior - a command line task list manager.
//
// Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
// http://www.opensource.org/licenses/mit-license.php
//
////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDED_TDB2
#define INCLUDED_TDB2
#define L10N // Localization complete.
#include <map>
#include <vector>
#include <string>
#include <stdio.h>
#include <ViewText.h>
#include <File.h>
#include <Task.h>
// TF2 Class represents a single file in the task database.
class TF2
{
public:
TF2 ();
~TF2 ();
void target (const std::string&);
const std::vector <Task>& get_tasks ();
const std::vector <std::string>& get_lines ();
bool get (int, Task&);
bool get (const std::string&, Task&);
void add_task (const Task&);
bool modify_task (const Task&);
void add_line (const std::string&);
void clear_lines ();
void commit ();
void load_tasks ();
void load_lines ();
// ID <--> UUID mapping.
std::string uuid (int);
int id (const std::string&);
void has_ids ();
void auto_dep_scan ();
void clear ();
const std::string dump ();
private:
void dependency_scan ();
public:
bool _read_only;
bool _dirty;
bool _loaded_tasks;
bool _loaded_lines;
bool _has_ids;
bool _auto_dep_scan;
std::vector <Task> _tasks;
std::vector <Task> _added_tasks;
std::vector <Task> _modified_tasks;
std::vector <std::string> _lines;
std::vector <std::string> _added_lines;
File _file;
private:
std::map <int, std::string> _I2U; // ID -> UUID map
std::map <std::string, int> _U2I; // UUID -> ID map
};
// TDB2 Class represents all the files in the task database.
class TDB2
{
public:
TDB2 ();
~TDB2 ();
void set_location (const std::string&);
void add (Task&);
void modify (Task&);
void commit ();
void synch ();
void merge (const std::string&);
void revert ();
int gc ();
int next_id ();
// Generalized task accessors.
const std::vector <Task> all_tasks ();
bool get (int, Task&);
bool get (const std::string&, Task&);
const std::vector <Task> siblings (Task&);
const std::vector <Task> children (Task&);
// ID <--> UUID mapping.
std::string uuid (int);
int id (const std::string&);
// Read-only mode.
bool read_only ();
void clear ();
void dump ();
private:
bool verifyUniqueUUID (const std::string&);
public:
TF2 pending;
TF2 completed;
TF2 undo;
// TF2 backlog;
// TF2 synch_key;
private:
std::string _location;
int _id;
};
#endif
////////////////////////////////////////////////////////////////////////////////