mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-29 07:57:20 +02:00
Dependencies - TDB
- Allowed const access to the internal lists of the TDB object.
This commit is contained in:
parent
27a56d15db
commit
19b803312f
2 changed files with 38 additions and 4 deletions
37
src/TDB.cpp
37
src/TDB.cpp
|
@ -167,6 +167,7 @@ void TDB::clear ()
|
||||||
mId = 1;
|
mId = 1;
|
||||||
mPending.clear ();
|
mPending.clear ();
|
||||||
mNew.clear ();
|
mNew.clear ();
|
||||||
|
mCompleted.clear ();
|
||||||
mModified.clear ();
|
mModified.clear ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,7 +192,8 @@ void TDB::lock (bool lockFile /* = true */)
|
||||||
|
|
||||||
mPending.clear ();
|
mPending.clear ();
|
||||||
mNew.clear ();
|
mNew.clear ();
|
||||||
mPending.clear ();
|
mCompleted.clear ();
|
||||||
|
mModified.clear ();
|
||||||
|
|
||||||
foreach (location, mLocations)
|
foreach (location, mLocations)
|
||||||
{
|
{
|
||||||
|
@ -208,9 +210,10 @@ void TDB::lock (bool lockFile /* = true */)
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void TDB::unlock ()
|
void TDB::unlock ()
|
||||||
{
|
{
|
||||||
mPending.clear ();
|
// Do not clear out these items, as they may be used in a read-only fashion.
|
||||||
mNew.clear ();
|
// mPending.clear ();
|
||||||
mModified.clear ();
|
// mNew.clear ();
|
||||||
|
// mModified.clear ();
|
||||||
|
|
||||||
foreach (location, mLocations)
|
foreach (location, mLocations)
|
||||||
{
|
{
|
||||||
|
@ -306,6 +309,8 @@ int TDB::loadPending (std::vector <Task>& tasks, Filter& filter)
|
||||||
mPending.push_back (task);
|
mPending.push_back (task);
|
||||||
|
|
||||||
// Maintain mapping for ease of link/dependency resolution.
|
// 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");
|
mI2U[task.id] = task.get ("uuid");
|
||||||
mU2I[task.get ("uuid")] = task.id;
|
mU2I[task.get ("uuid")] = task.id;
|
||||||
}
|
}
|
||||||
|
@ -424,6 +429,30 @@ int TDB::loadCompleted (std::vector <Task>& tasks, Filter& filter)
|
||||||
return tasks.size ();
|
return tasks.size ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
const std::vector <Task>& TDB::getAllPending ()
|
||||||
|
{
|
||||||
|
return mPending;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
const std::vector <Task>& TDB::getAllNew ()
|
||||||
|
{
|
||||||
|
return mNew;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
const std::vector <Task>& TDB::getAllCompleted ()
|
||||||
|
{
|
||||||
|
return mCompleted;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
const std::vector <Task>& TDB::getAllModified ()
|
||||||
|
{
|
||||||
|
return mModified;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Note: mLocations[0] is where all tasks are written.
|
// Note: mLocations[0] is where all tasks are written.
|
||||||
void TDB::add (const Task& task)
|
void TDB::add (const Task& task)
|
||||||
|
|
|
@ -56,6 +56,11 @@ public:
|
||||||
int loadPending (std::vector <Task>&, Filter&);
|
int loadPending (std::vector <Task>&, Filter&);
|
||||||
int loadCompleted (std::vector <Task>&, Filter&);
|
int loadCompleted (std::vector <Task>&, Filter&);
|
||||||
|
|
||||||
|
const std::vector <Task>& getAllPending ();
|
||||||
|
const std::vector <Task>& getAllNew ();
|
||||||
|
const std::vector <Task>& getAllCompleted ();
|
||||||
|
const std::vector <Task>& getAllModified ();
|
||||||
|
|
||||||
void add (const Task&); // Single task add to pending
|
void add (const Task&); // Single task add to pending
|
||||||
void update (const Task&); // Single task update to pending
|
void update (const Task&); // Single task update to pending
|
||||||
int commit (); // Write out all tasks
|
int commit (); // Write out all tasks
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue