X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Ftask.h;h=0890007279518446e5ebae900be1422b6a84e2af;hb=302977793935e100a5bf37822836531cafb03bf3;hp=531316be71d1ee98a46d3f86bcd55a8b8b796b39;hpb=64cd148dcd762ea368d9a552e982fdff83781ef2;p=builder.git diff --git a/source/task.h b/source/task.h index 531316b..0890007 100644 --- a/source/task.h +++ b/source/task.h @@ -3,7 +3,13 @@ #include #include +#include +/** +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 +provided should it be necessary to wait for a task to finish. +*/ class Task { public: @@ -17,13 +23,37 @@ public: sigc::signal signal_finished; protected: - Task() { } + std::list files; + bool unlink; + + Task(); public: virtual ~Task() { } + /** Associate the task with a file. */ + void add_file(const Msp::FS::Path &); + + /** If set to true, the associated files are removed before the task is + started. */ + void set_unlink(bool = true); + + /** Returns the command being executed for this task. Only makes sense if + an external command is involved. */ virtual std::string get_command() const = 0; + + /// Starts the task. virtual void start() = 0; + +protected: + /// Ensures that the output directory exists and removes files if necessary. + void prepare(); + +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; }; #endif