From e3c0c95f2ad3d25411c007ce4ffdb25084a1bc0d Mon Sep 17 00:00:00 2001 From: Jonas Suhr Christensen Date: Thu, 12 Apr 2012 15:12:18 +0200 Subject: Added observer id as prefix to server->client commands. --- src/tasktree.cc | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'src/tasktree.cc') diff --git a/src/tasktree.cc b/src/tasktree.cc index 0df23d6..3a72046 100644 --- a/src/tasktree.cc +++ b/src/tasktree.cc @@ -29,6 +29,13 @@ #include "debug.h" +static void concatTaskIdLists(TaskIdList& pre, TaskIdList& post) { + pre.insert(pre.end(), post.begin(), post.end()); + // for(TaskIdList::iterator it = post.begin(); + // it != post.end(); it++) { + // pre.push_back( + // } +} TaskTree::TaskTree() { root = NULL; @@ -60,9 +67,11 @@ TaskIdList TaskTree::insertAsChild(taskid_t parentid, taskid_t id, task_t data) child->data = data; insertChild(parent, child); - affectedNodes.push_back(parentid); + // affectedNodes.push_back(parentid); affectedNodes.push_back(id); - + TaskIdList ancestors = ancestorList(id); + concatTaskIdLists(affectedNodes, ancestors); + goto finish; } catch(std::exception& e) { @@ -112,8 +121,11 @@ TaskIdList TaskTree::move(taskid_t id, taskid_t toid) newparent->children.push_back(child); affectedNodes.push_back(id); - affectedNodes.push_back(child->parent->id); - affectedNodes.push_back(toid); + // affectedNodes.push_back(child->parent->id); + TaskIdList ancestors = ancestorList(id); + concatTaskIdLists(affectedNodes, ancestors); + affectedNodes.push_back(toid); + ancestors = ancestorList(toid); goto finish; } @@ -135,6 +147,8 @@ TaskIdList TaskTree::updateData(taskid_t id, task_t t) node->data = t; affectedNodes.push_back(id); + TaskIdList ancestors = ancestorList(id); + concatTaskIdLists(affectedNodes, ancestors); goto finish; } catch(std::exception& e) { @@ -181,6 +195,11 @@ TaskIdList TaskTree::ancestorList(taskid_t id) } finish: + printf("Collected %d ancestors to %u\n", ancestors.size(), id); + for(TaskIdList::iterator it = ancestors.begin(); + it != ancestors.end(); it++) { + printf("\tancestor %u\n", *it); + } return ancestors; } -- cgit v1.2.3