1 #include "chainedtask.h"
5 ChainedTask::ChainedTask(Task *t):
12 ChainedTask::~ChainedTask()
14 for(vector<Task *>::iterator i=tasks.begin(); i!=tasks.end(); ++i)
18 void ChainedTask::add_task(Task *t)
23 string ChainedTask::get_command() const
26 for(vector<Task *>::const_iterator i=tasks.begin(); i!=tasks.end(); ++i)
30 cmd += (*i)->get_command();
35 void ChainedTask::start()
40 tasks[current]->start();
43 Task::Status ChainedTask::check()
45 while(current<tasks.size() && !process(tasks[current]->check())) ;
50 Task::Status ChainedTask::wait()
52 while(current<tasks.size() && !process(tasks[current]->wait())) ;
57 bool ChainedTask::process(Status sub_status)
59 if(sub_status==SUCCESS && current+1<tasks.size())
61 // The task succeeded and there's more to run
63 tasks[current]->start();
67 if(sub_status!=RUNNING)
69 // The task is not running anymore and either failed or was the last one
70 current = tasks.size();
71 final_status = sub_status;