From 22368b9a40f047425873092ce20d2184d3f091a3 Mon Sep 17 00:00:00 2001 From: Tomas Babej Date: Fri, 30 Oct 2015 00:56:22 +0100 Subject: [PATCH] Revive TDB2::has and TF2::has methods This reverts commit fa920f02aa108d666190d4340c9daa213182fca2. Methods found their usage after all. --- src/TDB2.cpp | 21 +++++++++++++++++++++ src/TDB2.h | 2 ++ 2 files changed, 23 insertions(+) diff --git a/src/TDB2.cpp b/src/TDB2.cpp index ad555561b..02f41e698 100644 --- a/src/TDB2.cpp +++ b/src/TDB2.cpp @@ -149,6 +149,19 @@ bool TF2::get (const std::string& uuid, Task& task) return false; } +//////////////////////////////////////////////////////////////////////////////// +bool TF2::has (const std::string& uuid) +{ + if (! _loaded_tasks) + load_tasks (); + + for (auto& i : _tasks) + if (i.get ("uuid") == uuid) + return true; + + return false; +} + //////////////////////////////////////////////////////////////////////////////// void TF2::add_task (Task& task) { @@ -1350,6 +1363,14 @@ bool TDB2::get (const std::string& uuid, Task& task) completed.get (uuid, task); } +//////////////////////////////////////////////////////////////////////////////// +// Locate task by UUID, wherever it is. +bool TDB2::has (const std::string& uuid) +{ + return pending.has (uuid) || + completed.has (uuid); +} + //////////////////////////////////////////////////////////////////////////////// const std::vector TDB2::siblings (Task& task) { diff --git a/src/TDB2.h b/src/TDB2.h index d61bbdce0..4353a4ee5 100644 --- a/src/TDB2.h +++ b/src/TDB2.h @@ -50,6 +50,7 @@ public: bool get (int, Task&); bool get (const std::string&, Task&); + bool has (const std::string&); void add_task (Task&); bool modify_task (const Task&); @@ -121,6 +122,7 @@ public: const std::vector all_tasks (); bool get (int, Task&); bool get (const std::string&, Task&); + bool has (const std::string&); const std::vector siblings (Task&); const std::vector children (Task&);