6 #include <sigc++/signal.h>
7 #include <msp/time/timedelta.h>
8 #include <msp/time/timestamp.h>
9 #include "libbuilder_api.h"
14 Tasks are used to manage other programs and worker threads involved in the
15 build process. They are run asynchronously by default, but a wait() method is
16 provided should it be necessary to wait for a task to finish.
18 class LIBBUILDER_API Task
28 sigc::signal<void, bool> signal_finished;
31 std::vector<const FileTarget *> targets;
33 Msp::Time::TimeStamp start_time;
34 Msp::Time::TimeDelta duration;
40 /** Associate the task with a target. */
41 void add_target(const FileTarget &);
43 /** If set to true, the associated files are removed before the task is
45 void set_unlink(bool = true);
47 const std::vector<const FileTarget *> &get_targets() const { return targets; }
49 /** Returns the command being executed for this task. Only makes sense if
50 an external command is involved. */
51 virtual std::string get_command() const = 0;
54 virtual void start() = 0;
57 /// Ensures that the output directory exists and removes files if necessary.
63 /// Checks the status of the task and immediately returns.
64 virtual Status check() = 0;
66 /// Waits for the task to finish and returns its final status.
67 virtual Status wait() = 0;
69 /** Returns the amount of time completing the task took. Only available
70 after the task has finished. */
71 const Msp::Time::TimeDelta &get_duration() const { return duration; }