X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fjob.h;h=97e3fc29637d292597d943f4c9e70a77cdd8dfad;hb=4265db19ba68a995fca42bdd5fa815aead9c5c50;hp=40e90b73c72b3c136f0570cf7198018746610a29;hpb=237a0052c60af768f4d62b00321932918b7ba4d9;p=dcpomatic.git diff --git a/src/lib/job.h b/src/lib/job.h index 40e90b73c..97e3fc296 100644 --- a/src/lib/job.h +++ b/src/lib/job.h @@ -35,10 +35,10 @@ class Film; /** @class Job * @brief A parent class to represent long-running tasks which are run in their own thread. */ -class Job : public boost::enable_shared_from_this +class Job : public boost::enable_shared_from_this, public boost::noncopyable { public: - Job (boost::shared_ptr); + Job (boost::shared_ptr); virtual ~Job() {} /** @return user-readable name of this job */ @@ -64,14 +64,24 @@ public: int elapsed_time () const; virtual std::string status () const; + std::string sub_name () const { + return _sub_name; + } void set_progress_unknown (); - void set_progress (float); - void ascend (); - void descend (float); - float overall_progress () const; - - /** Emitted by the JobManagerView from the UI thread */ + void set_progress (float, bool force = false); + void sub (std::string); + float progress () const; + bool progress_unknown () const { + return !_progress; + } + + boost::shared_ptr film () const { + return _film; + } + + boost::signals2::signal Progress; + /** Emitted from the UI thread when the job is finished */ boost::signals2::signal Finished; protected: @@ -80,10 +90,10 @@ protected: /** Description of a job's state */ enum State { - NEW, ///< the job hasn't been started yet - RUNNING, ///< the job is running - PAUSED, ///< the job has been paused - FINISHED_OK, ///< the job has finished successfully + NEW, ///< the job hasn't been started yet + RUNNING, ///< the job is running + PAUSED, ///< the job has been paused + FINISHED_OK, ///< the job has finished successfully FINISHED_ERROR, ///< the job has finished in error FINISHED_CANCELLED ///< the job was cancelled }; @@ -91,7 +101,7 @@ protected: void set_state (State); void set_error (std::string s, std::string d); - boost::shared_ptr _film; + boost::shared_ptr _film; private: @@ -107,23 +117,13 @@ private: std::string _error_summary; std::string _error_details; - /** time that this job was started */ + /** time that this sub-job was started */ time_t _start_time; + std::string _sub_name; - /** mutex for _stack and _progress_unknown */ + /** mutex for _progress */ mutable boost::mutex _progress_mutex; - - struct Level { - Level (float a) : allocation (a), normalised (0) {} - - float allocation; - float normalised; - }; - - std::list _stack; - - /** true if this job's progress will always be unknown */ - bool _progress_unknown; + boost::optional _progress; int _ran_for; };