X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Ftask.h;h=0732453bfd460b0f0fe8ae881899c6d33581d89a;hb=ac1f35e436dbe86f903dce2f49b002ff17f1ca50;hp=9cf2bac9081b7b2c8df1627342aa1dd14600d8ff;hpb=afeb81fb97b8ee4e50a3679707deb17e5b79a74f;p=builder.git diff --git a/source/task.h b/source/task.h index 9cf2bac..0732453 100644 --- a/source/task.h +++ b/source/task.h @@ -3,10 +3,12 @@ #include #include +#include /** Tasks are used to manage other programs and worker threads involved in the -build process. They are run asynchronously. +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 { @@ -20,14 +22,38 @@ public: sigc::signal signal_finished; + Msp::FS::Path file; + bool unlink; + protected: - Task() { } + Task(); public: virtual ~Task() { } + /** Associate the task with a file. */ + void set_file(const Msp::FS::Path &); + + /** If set to true, the associated file is 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 the file 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; };