X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;ds=sidebyside;f=source%2Flib%2Ftask.h;h=e493e3b188e99efaef18a81db22b266b3820d0f9;hb=b4781796aa997368f46b87b73a907bcab955ca3d;hp=b0f56f470399446d7339b1508300c2f0fd89e59f;hpb=1df42c314669f30fe1d82f02fdfeeff19f92964e;p=builder.git diff --git a/source/lib/task.h b/source/lib/task.h index b0f56f4..e493e3b 100644 --- a/source/lib/task.h +++ b/source/lib/task.h @@ -2,10 +2,14 @@ #define TASK_H_ #include +#include #include -#include +#include +#include #include "libbuilder_api.h" +class FileTarget; + /** Tasks are used to manage other programs and worker threads involved in the build process. They are run asynchronously by default, but a wait() method is @@ -24,20 +28,24 @@ public: sigc::signal signal_finished; protected: - std::vector files; + std::vector targets; bool unlink = false; + Msp::Time::TimeStamp start_time; + Msp::Time::TimeDelta duration; Task() = default; public: virtual ~Task() { } - /** Associate the task with a file. */ - void add_file(const Msp::FS::Path &); + /** Associate the task with a target. */ + void add_target(const FileTarget &); /** If set to true, the associated files are removed before the task is started. */ void set_unlink(bool = true); + const std::vector &get_targets() const { return targets; } + /** Returns the command being executed for this task. Only makes sense if an external command is involved. */ virtual std::string get_command() const = 0; @@ -49,12 +57,18 @@ protected: /// Ensures that the output directory exists and removes files if necessary. void prepare(); + void finished(bool); + public: /// Checks the status of the task and immediately returns. virtual Status check() = 0; /// Waits for the task to finish and returns its final status. virtual Status wait() = 0; + + /** Returns the amount of time completing the task took. Only available + after the task has finished. */ + const Msp::Time::TimeDelta &get_duration() const { return duration; } }; #endif