diff options
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; } |