1 #include <msp/strings/utils.h>
2 #include "chainedtask.h"
7 ChainedTask::~ChainedTask()
13 void ChainedTask::add_task(Task *t)
18 string ChainedTask::get_command() const
22 append(cmd, "\n", t->get_command());
26 void ChainedTask::start()
31 tasks[current]->start();
34 Task::Status ChainedTask::check()
36 while(current<tasks.size() && !process(tasks[current]->check())) ;
41 Task::Status ChainedTask::wait()
43 while(current<tasks.size() && !process(tasks[current]->wait())) ;
48 bool ChainedTask::process(Status sub_status)
50 if(sub_status==SUCCESS && current+1<tasks.size())
52 // The task succeeded and there's more to run
54 tasks[current]->start();
58 if(sub_status!=RUNNING)
60 // The task is not running anymore and either failed or was the last one
61 current = tasks.size();
62 final_status = sub_status;