]> git.tdb.fi Git - builder.git/blobdiff - source/lib/task.h
Report timings of the build
[builder.git] / source / lib / task.h
index 3520a91ae04ab3fe584a873ec6e56123d7f8e8ae..e493e3b188e99efaef18a81db22b266b3820d0f9 100644 (file)
@@ -4,6 +4,8 @@
 #include <string>
 #include <vector>
 #include <sigc++/signal.h>
+#include <msp/time/timedelta.h>
+#include <msp/time/timestamp.h>
 #include "libbuilder_api.h"
 
 class FileTarget;
@@ -28,6 +30,8 @@ public:
 protected:
        std::vector<const FileTarget *> targets;
        bool unlink = false;
+       Msp::Time::TimeStamp start_time;
+       Msp::Time::TimeDelta duration;
 
        Task() = default;
 public:
@@ -40,6 +44,8 @@ public:
        started. */
        void set_unlink(bool = true);
 
+       const std::vector<const FileTarget *> &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;
@@ -51,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