- Stubbed new ::onAdd and ::onModify interfaces.
This commit is contained in:
Paul Beckingham 2014-09-14 15:42:47 -04:00
parent 7b617a7b6e
commit ab72cdad4d
3 changed files with 15 additions and 10 deletions

View file

@ -197,8 +197,9 @@ void Hooks::onExit ()
// - all emitted non-JSON lines are considered feedback messages if the exit // - all emitted non-JSON lines are considered feedback messages if the exit
// code is zero, otherwise they are considered errors. // code is zero, otherwise they are considered errors.
// //
void Hooks::onAdd (Task& after) void Hooks::onAdd (std::vector <Task>& changes)
{ {
/*
context.timer_hooks.start (); context.timer_hooks.start ();
if (! _enabled) if (! _enabled)
return; return;
@ -249,6 +250,7 @@ void Hooks::onAdd (Task& after)
} }
context.timer_hooks.stop (); context.timer_hooks.stop ();
*/
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -266,8 +268,9 @@ void Hooks::onAdd (Task& after)
// - all emitted non-JSON lines are considered feedback messages if the exit // - all emitted non-JSON lines are considered feedback messages if the exit
// code is zero, otherwise they are considered errors. // code is zero, otherwise they are considered errors.
// //
void Hooks::onModify (const Task& before, Task& after) void Hooks::onModify (const Task& before, std::vector <Task>& changes)
{ {
/*
context.timer_hooks.start (); context.timer_hooks.start ();
if (! _enabled) if (! _enabled)
return; return;
@ -322,6 +325,7 @@ void Hooks::onModify (const Task& before, Task& after)
} }
context.timer_hooks.stop (); context.timer_hooks.stop ();
*/
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View file

@ -29,6 +29,7 @@
#include <vector> #include <vector>
#include <string> #include <string>
#include <Task.h>
class Hooks class Hooks
{ {
@ -43,8 +44,8 @@ public:
void onLaunch (); void onLaunch ();
void onExit (); void onExit ();
void onAdd (Task&); void onAdd (std::vector <Task>&);
void onModify (const Task&, Task&); void onModify (const Task&, std::vector <Task>&);
std::vector <std::string> list (); std::vector <std::string> list ();

View file

@ -570,9 +570,7 @@ void TDB2::add (Task& task, bool add_to_backlog /* = true */)
// Create a vector tasks, as hooks can cause them to multiply. // Create a vector tasks, as hooks can cause them to multiply.
std::vector <Task> changes; std::vector <Task> changes;
changes.push_back (task); changes.push_back (task);
context.hooks.onAdd (changes);
// TODO call hooks.
// context.hooks.onAdd (changes);
update (uuid, task, add_to_backlog, changes); update (uuid, task, add_to_backlog, changes);
} }
@ -584,12 +582,14 @@ void TDB2::modify (Task& task, bool add_to_backlog /* = true */)
task.validate (false); task.validate (false);
std::string uuid = task.get ("uuid"); std::string uuid = task.get ("uuid");
// Get the unmodified task as reference, so the hook can compare.
Task original;
get (uuid, original);
// Create a vector tasks, as hooks can cause them to multiply. // Create a vector tasks, as hooks can cause them to multiply.
std::vector <Task> changes; std::vector <Task> changes;
changes.push_back (task); changes.push_back (task);
context.hooks.onModify (original, changes);
// TODO call hooks.
// context.hooks.onModify (changes);
update (uuid, task, add_to_backlog, changes); update (uuid, task, add_to_backlog, changes);
} }