1 #include <msp/strings/utils.h>
2 #include "chainedtask.h"
7 ChainedTask::ChainedTask(Task *t):
14 ChainedTask::~ChainedTask()
20 void ChainedTask::add_task(Task *t)
25 string ChainedTask::get_command() const
29 append(cmd, "\n", t->get_command());
33 void ChainedTask::start()
38 tasks[current]->start();
41 Task::Status ChainedTask::check()
43 while(current<tasks.size() && !process(tasks[current]->check())) ;
48 Task::Status ChainedTask::wait()
50 while(current<tasks.size() && !process(tasks[current]->wait())) ;
55 bool ChainedTask::process(Status sub_status)
57 if(sub_status==SUCCESS && current+1<tasks.size())
59 // The task succeeded and there's more to run
61 tasks[current]->start();
65 if(sub_status!=RUNNING)
67 // The task is not running anymore and either failed or was the last one
68 current = tasks.size();
69 final_status = sub_status;