X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fjob.h;h=5e3127dc158a432522590ffec566e5cfa1e21bbf;hb=e8c1880a2b9a40eb11ee259feee3edd799139a43;hp=791a9101b24bed0ca792049cf5bd24123b4c89a8;hpb=01791aac0b11e9f296cd31a7803e287203bd8355;p=dcpomatic.git diff --git a/src/lib/job.h b/src/lib/job.h index 791a9101b..5e3127dc1 100644 --- a/src/lib/job.h +++ b/src/lib/job.h @@ -35,7 +35,7 @@ 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); @@ -43,6 +43,7 @@ public: /** @return user-readable name of this job */ virtual std::string name () const = 0; + virtual std::string json_name () const = 0; /** Run this job in the current thread. */ virtual void run () = 0; @@ -64,13 +65,24 @@ public: int elapsed_time () const; virtual std::string status () const; + std::string json_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; - + 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; @@ -80,10 +92,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 }; @@ -107,23 +119,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; };