From 19b803312fe94dd1a2c2b9dc6fb599c75df9db58 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Mon, 12 Jul 2010 20:22:51 -0400 Subject: [PATCH] Dependencies - TDB - Allowed const access to the internal lists of the TDB object. --- src/TDB.cpp | 37 +++++++++++++++++++++++++++++++++---- src/TDB.h | 5 +++++ 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/src/TDB.cpp b/src/TDB.cpp index d5e81f0a3..7b8c01a41 100644 --- a/src/TDB.cpp +++ b/src/TDB.cpp @@ -167,6 +167,7 @@ void TDB::clear () mId = 1; mPending.clear (); mNew.clear (); + mCompleted.clear (); mModified.clear (); } @@ -191,7 +192,8 @@ void TDB::lock (bool lockFile /* = true */) mPending.clear (); mNew.clear (); - mPending.clear (); + mCompleted.clear (); + mModified.clear (); foreach (location, mLocations) { @@ -208,9 +210,10 @@ void TDB::lock (bool lockFile /* = true */) //////////////////////////////////////////////////////////////////////////////// void TDB::unlock () { - mPending.clear (); - mNew.clear (); - mModified.clear (); + // Do not clear out these items, as they may be used in a read-only fashion. + // mPending.clear (); + // mNew.clear (); + // mModified.clear (); foreach (location, mLocations) { @@ -306,6 +309,8 @@ int TDB::loadPending (std::vector & tasks, Filter& filter) mPending.push_back (task); // Maintain mapping for ease of link/dependency resolution. + // Note that this mapping is not restricted by the filter, and is + // therefore a complete set. mI2U[task.id] = task.get ("uuid"); mU2I[task.get ("uuid")] = task.id; } @@ -424,6 +429,30 @@ int TDB::loadCompleted (std::vector & tasks, Filter& filter) return tasks.size (); } +//////////////////////////////////////////////////////////////////////////////// +const std::vector & TDB::getAllPending () +{ + return mPending; +} + +//////////////////////////////////////////////////////////////////////////////// +const std::vector & TDB::getAllNew () +{ + return mNew; +} + +//////////////////////////////////////////////////////////////////////////////// +const std::vector & TDB::getAllCompleted () +{ + return mCompleted; +} + +//////////////////////////////////////////////////////////////////////////////// +const std::vector & TDB::getAllModified () +{ + return mModified; +} + //////////////////////////////////////////////////////////////////////////////// // Note: mLocations[0] is where all tasks are written. void TDB::add (const Task& task) diff --git a/src/TDB.h b/src/TDB.h index add1c16b3..33fd1ae8f 100644 --- a/src/TDB.h +++ b/src/TDB.h @@ -56,6 +56,11 @@ public: int loadPending (std::vector &, Filter&); int loadCompleted (std::vector &, Filter&); + const std::vector & getAllPending (); + const std::vector & getAllNew (); + const std::vector & getAllCompleted (); + const std::vector & getAllModified (); + void add (const Task&); // Single task add to pending void update (const Task&); // Single task update to pending int commit (); // Write out all tasks