diff options
author | Jonas Suhr Christensen <jsc@umbraculum.org> | 2012-04-12 15:12:18 +0200 |
---|---|---|
committer | Jonas Suhr Christensen <jsc@umbraculum.org> | 2012-04-12 15:12:18 +0200 |
commit | e3c0c95f2ad3d25411c007ce4ffdb25084a1bc0d (patch) | |
tree | 6e4179bac871a91b842ccfff4aa69466f0787ad8 /src/tasktree.cc | |
parent | fd373d0b0f580b56f3350e92207cfa499806ca4d (diff) |
Added observer id as prefix to server->client commands.
Diffstat (limited to 'src/tasktree.cc')
-rw-r--r-- | src/tasktree.cc | 27 |
1 files changed, 23 insertions, 4 deletions
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; } |