]> git.tdb.fi Git - builder.git/blob - source/task.h
Document Task and ExternalTask methods
[builder.git] / source / task.h
1 #ifndef TASK_H_
2 #define TASK_H_
3
4 #include <string>
5 #include <sigc++/signal.h>
6
7 /**
8 Tasks are used to manage other programs and worker threads involved in the
9 build process.  They are run asynchronously by default, but a wait() method is
10 provided should it be necessary to wait for a task to finish.
11 */
12 class Task
13 {
14 public:
15         enum Status
16         {
17                 RUNNING,
18                 SUCCESS,
19                 ERROR
20         };
21
22         sigc::signal<void, bool> signal_finished;
23
24 protected:
25         Task() { }
26 public:
27         virtual ~Task() { }
28
29         /** Returns the command being executed for this task.  Only makes sense if
30         an external command is involved. */
31         virtual std::string get_command() const = 0;
32
33         /// Starts the task.
34         virtual void start() = 0;
35
36         /// Checks the status of the task and immediately returns.
37         virtual Status check() = 0;
38
39         /// Waits for the task to finish and returns its final status.
40         virtual Status wait() = 0;
41 };
42
43 #endif