summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/message.h5
-rw-r--r--src/messageparser.h6
-rw-r--r--src/taskmanager.cc28
-rw-r--r--src/taskmanager.h4
4 files changed, 30 insertions, 13 deletions
diff --git a/src/message.h b/src/message.h
index dc4386b..383fa73 100644
--- a/src/message.h
+++ b/src/message.h
@@ -75,7 +75,7 @@ typedef struct {
typedef struct {
cmd::cmd_t cmd;
-
+
union {
observe_t observe;
unobserve_t unobserve;
@@ -87,6 +87,9 @@ typedef struct {
TaskIdList nodes;
+ // tagret node id (observed task id) used for transmissions only.
+ taskid_t tid;
+
} message_t;
diff --git a/src/messageparser.h b/src/messageparser.h
index b39548d..6ebac3e 100644
--- a/src/messageparser.h
+++ b/src/messageparser.h
@@ -35,8 +35,8 @@ MessageList parse_msg(std::string msg);
//message_t create_msg(cmd::cmd_t type, task_t task);
std::string msg_tostring(message_t msg);
-message_t create_msg_create(taskid_t task);
-message_t create_msg_update(taskid_t task);
-message_t create_msg_remove(taskid_t task);
+message_t create_msg_create(task_t task);
+message_t create_msg_update(task_t task);
+message_t create_msg_remove(task_t task);
#endif/*__MUNIA_MESSAGEPARSER_H__*/
diff --git a/src/taskmanager.cc b/src/taskmanager.cc
index f757694..b1fa34e 100644
--- a/src/taskmanager.cc
+++ b/src/taskmanager.cc
@@ -64,6 +64,10 @@ TaskManager::TaskManager() {
TaskManager::~TaskManager() {
}
+task_t TaskManager::task(taskid_t t) {
+ return tree.getData(t);
+}
+
taskid_t TaskManager::createId() {
return idCount++;
}
@@ -82,13 +86,11 @@ TaskIdList TaskManager::moveTask(taskid_t id, taskid_t to)
try {
affectedTasks = tree.move(id, to);
- goto finish;
}
catch (std::exception& e) {
throw e;
}
- finish:
return affectedTasks;
}
@@ -98,13 +100,11 @@ TaskIdList TaskManager::deleteTask(taskid_t id)
try {
affectedTasks = tree.remove(id);
- goto finish;
}
catch(std::exception& e) {
throw e;
}
- finish:
return affectedTasks;
}
@@ -115,13 +115,11 @@ TaskIdList TaskManager::updateTask(taskid_t id, task_t t)
try {
affectedTasks = tree.updateData(id, t);
- goto finish;
}
catch (std::exception& e) {
throw e;
}
- finish:
return affectedTasks;
}
@@ -133,14 +131,26 @@ TaskIdList TaskManager::addTask(task_t t, taskid_t parentid)
try {
affectedTasks = tree.insertAsChild(parentid, id, t);
- goto finish;
}
catch (std::exception& e) {
throw e;
}
- finish:
- printf("Returning %d nodes\n", affectedTasks.size());
+ return affectedTasks;
+}
+
+TaskIdList TaskManager::subTasks(taskid_t t)
+ throw (std::exception) {
+
+ TaskIdList affectedTasks;
+
+ try {
+ affectedTasks = tree.bfs(t);
+ }
+ catch (std::exception& e) {
+ throw e;
+ }
+
return affectedTasks;
}
diff --git a/src/taskmanager.h b/src/taskmanager.h
index 47c6c10..d8fd751 100644
--- a/src/taskmanager.h
+++ b/src/taskmanager.h
@@ -47,8 +47,12 @@ public:
TaskIdList deleteTask(taskid_t id) throw (std::exception);
TaskIdList moveTask(taskid_t id, taskid_t newParent) throw (std::exception);
+ TaskIdList subTasks(taskid_t) throw (std::exception);
+
TaskTree tree;
+ task_t task(taskid_t t);
+
private:
// TaskIdList ancestorList(taskid_t task);
taskid_t createId();