]> git.tdb.fi Git - builder.git/blobdiff - source/chainedtask.h
Add utility class for executing chains of tasks
[builder.git] / source / chainedtask.h
diff --git a/source/chainedtask.h b/source/chainedtask.h
new file mode 100644 (file)
index 0000000..2014f02
--- /dev/null
@@ -0,0 +1,32 @@
+#ifndef CHAINEDTASK_H_
+#define CHAINEDTASK_H_
+
+#include <vector>
+#include "task.h"
+
+/**
+Runs multiple tasks as one unit, one after the other.  Execution of the chain
+will stop if any of the component tasks terminates with an error.
+*/
+class ChainedTask: public Task
+{
+private:
+       std::vector<Task *> tasks;
+       unsigned current;
+       Status final_status;
+
+public:
+       ChainedTask(Task *);
+       ~ChainedTask();
+
+       void add_task(Task *);
+
+       virtual std::string get_command() const;
+       virtual void start();
+       virtual Status check();
+       virtual Status wait();
+private:
+       bool process(Status);
+};
+
+#endif