Cleanup: use some more vector instead of list.
[dcpomatic.git] / src / lib / job.h
index 8b89fd0c383fbbb41c4bb76183588b2a583b08b0..dc5f7bc34074041b85536978aa8554dc336a9db4 100644 (file)
@@ -91,13 +91,19 @@ public:
                return _film;
        }
 
-       void when_finished (boost::signals2::connection& connection, std::function<void()> finished);
+       enum class Result {
+               RESULT_OK,
+               RESULT_ERROR,     // we can't have plain ERROR on Windows
+               RESULT_CANCELLED
+       };
+
+       void when_finished(boost::signals2::connection& connection, std::function<void(Result)> finished);
 
        boost::signals2::signal<void()> Progress;
        /** Emitted from the UI thread when the job is finished */
-       boost::signals2::signal<void()> Finished;
+       boost::signals2::signal<void (Result)> Finished;
        /** Emitted from the job thread when the job is finished */
-       boost::signals2::signal<void()> FinishedImmediate;
+       boost::signals2::signal<void (Result)> FinishedImmediate;
 
 protected:
 
@@ -114,8 +120,9 @@ protected:
                FINISHED_CANCELLED ///< the job was cancelled
        };
 
+       Result state_to_result(State state) const;
        void set_state (State);
-       void set_error (std::string s, std::string d);
+       void set_error (std::string s, std::string d = "");
        void set_message (std::string m);
        int elapsed_sub_time () const;
        void check_for_interruption_or_pause ();
@@ -123,6 +130,9 @@ protected:
 
        std::shared_ptr<const Film> _film;
 
+       time_t _start_time = 0;
+       time_t _finish_time = 0;
+
 private:
 
        void run_wrapper ();
@@ -140,8 +150,6 @@ private:
        /** a message that should be given to the user when the job finishes */
        boost::optional<std::string> _message;
 
-       /** time that this job was started */
-       time_t _start_time;
        /** time that this sub-job was started */
        time_t _sub_start_time;
        std::string _sub_name;
@@ -155,8 +163,6 @@ private:
            this could be a general _state_change if it made more sense.
        */
        boost::condition_variable _pause_changed;
-
-       int _ran_for;
 };
 
 #endif