]> git.tdb.fi Git - builder.git/blobdiff - source/task.h
Move the bpk files into a subdirectory and install them
[builder.git] / source / task.h
index 1f59473fd14f135da7933d18993f4936458e2e1c..183deee40e5c8d0b6b3b60455a2e3f14e933fdb5 100644 (file)
@@ -3,10 +3,12 @@
 
 #include <string>
 #include <sigc++/signal.h>
+#include <msp/fs/path.h>
 
 /**
 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<void, bool> signal_finished;
 
+       std::list<Msp::FS::Path> files;
+       bool unlink;
+
 protected:
-       Task() { }
+       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