Pass options only to jobs that need them.
authorCarl Hetherington <cth@carlh.net>
Sun, 21 Oct 2012 12:17:04 +0000 (13:17 +0100)
committerCarl Hetherington <cth@carlh.net>
Sun, 21 Oct 2012 12:17:04 +0000 (13:17 +0100)
14 files changed:
src/lib/ab_transcode_job.cc
src/lib/ab_transcode_job.h
src/lib/check_hashes_job.cc
src/lib/check_hashes_job.h
src/lib/copy_from_dvd_job.cc
src/lib/examine_content_job.cc
src/lib/job.cc
src/lib/job.h
src/lib/make_dcp_job.cc
src/lib/make_dcp_job.h
src/lib/scp_dcp_job.cc
src/lib/transcode_job.cc
src/lib/transcode_job.h
test/test.cc

index 89967bfcac42e7b47d33868fb4bef1a048e7954a..cffb2cef178d3472a36eec66f34798bdb5388e8a 100644 (file)
@@ -36,7 +36,8 @@ using namespace boost;
  *  @Param l A log that we can write to.
  */
 ABTranscodeJob::ABTranscodeJob (shared_ptr<const FilmState> s, shared_ptr<const Options> o, Log* l, shared_ptr<Job> req)
-       : Job (s, o, l, req)
+       : Job (s, l, req)
+       , _opt (o)
 {
        _fs_b.reset (new FilmState (*_fs));
        _fs_b->set_scaler (Config::instance()->reference_scaler ());
index 4b80593f4de8c6bbdff4bee6104109226a58a8ca..2485608e6aee43fa7d34069e7398145ff8e7daa9 100644 (file)
@@ -40,6 +40,8 @@ public:
        void run ();
 
 private:
+       boost::shared_ptr<const Options> _opt;
+       
        /** Copy of our FilmState with filters removed and scaler set back to bicubic;
         *  this is the `reference' (left-half-frame) state.
         */
index eff9153d958ca6dbba7b0080dfd86312cf372b6f..478e4c91afc4649b995fcb5c74ba3686564ba8d5 100644 (file)
@@ -32,7 +32,8 @@ using namespace std;
 using namespace boost;
 
 CheckHashesJob::CheckHashesJob (shared_ptr<const FilmState> s, shared_ptr<const Options> o, Log* l, shared_ptr<Job> req)
-       : Job (s, o, l, req)
+       : Job (s, l, req)
+       , _opt (o)
        , _bad (0)
 {
 
index 6a68e936c5a746cd10699f90d7f74863f2a18804..7cf1789f69ae4b50433c4919483409c27d80313b 100644 (file)
@@ -29,5 +29,6 @@ public:
        std::string status () const;
 
 private:
+       boost::shared_ptr<const Options> _opt;
        int _bad;
 };
index f7281fc10e303479c2a0bcfdaef6e26121df059f..e087180728bd8767b39ddc299c8b51c55f102f09 100644 (file)
@@ -36,7 +36,7 @@ using namespace boost;
  *  @param l Log that we can write to.
  */
 CopyFromDVDJob::CopyFromDVDJob (shared_ptr<const FilmState> fs, Log* l, shared_ptr<Job> req)
-       : Job (fs, shared_ptr<Options> (), l, req)
+       : Job (fs, l, req)
 {
 
 }
index 5800c6f24dd643e40d2bf4db26f426be08681e04..44a9f4ce9c9a13148f24c8459cc76aecb12c06f7 100644 (file)
@@ -33,7 +33,7 @@ using namespace std;
 using namespace boost;
 
 ExamineContentJob::ExamineContentJob (shared_ptr<const FilmState> fs, Log* l, shared_ptr<Job> req)
-       : Job (fs, shared_ptr<Options> (), l, req)
+       : Job (fs, l, req)
 {
 
 }
index d3871bf7225da22ed1911416c1b2ee4df4cffd5d..2049e69b0093d2c0d94609c33aa09326b0fa1d7d 100644 (file)
@@ -31,12 +31,10 @@ using namespace std;
 using namespace boost;
 
 /** @param s FilmState for the film that we are operating on.
- *  @param o Options.
  *  @param l A log that we can write to.
  */
-Job::Job (shared_ptr<const FilmState> s, shared_ptr<const Options> o, Log* l, shared_ptr<Job> req)
+Job::Job (shared_ptr<const FilmState> s, Log* l, shared_ptr<Job> req)
        : _fs (s)
-       , _opt (o)
        , _log (l)
        , _required (req)
        , _state (NEW)
index f50ed078434efb6cd3661de2802a4c528fb18c7d..6b2b69b9dc52b6bdb68ed808a5d327290d2d5c83 100644 (file)
@@ -39,7 +39,7 @@ class Options;
 class Job : public boost::enable_shared_from_this<Job>
 {
 public:
-       Job (boost::shared_ptr<const FilmState> s, boost::shared_ptr<const Options> o, Log* l, boost::shared_ptr<Job> req);
+       Job (boost::shared_ptr<const FilmState> s, Log* l, boost::shared_ptr<Job> req);
 
        /** @return user-readable name of this job */
        virtual std::string name () const = 0;
@@ -91,8 +91,6 @@ protected:
 
        /** FilmState for this job */
        boost::shared_ptr<const FilmState> _fs;
-       /** options in use for this job */
-       boost::shared_ptr<const Options> _opt;
        /** a log that this job can write to */
        Log* _log;
 
index 83904fd60d2ce2d971132c8335e3e4acb06aad8a..fcfce4b07bccc6ada73799e79e2f68e8dc6064db 100644 (file)
@@ -44,7 +44,8 @@ using namespace boost;
  *  @param l Log.
  */
 MakeDCPJob::MakeDCPJob (shared_ptr<const FilmState> s, shared_ptr<const Options> o, Log* l, shared_ptr<Job> req)
-       : Job (s, o, l, req)
+       : Job (s, l, req)
+       , _opt (o)
 {
        
 }
index c350a819c3288214ad295136debd8c87f384d69c..d430ac3ce311f2ae232ca4eab38f4f1900e1f76f 100644 (file)
@@ -38,5 +38,7 @@ private:
        void dcp_progress (float);
        std::string j2c_path (int) const;
        std::string wav_path (libdcp::Channel) const;
+
+       boost::shared_ptr<const Options> _opt;
 };
 
index 300a8fe33c0dbec65140ea53f1b3160a30656873..3f400fca4de97099c04db9d1c4eba62e672bce7c 100644 (file)
@@ -92,7 +92,7 @@ public:
 
 
 SCPDCPJob::SCPDCPJob (shared_ptr<const FilmState> s, Log* l, shared_ptr<Job> req)
-       : Job (s, shared_ptr<const Options> (), l, req)
+       : Job (s, l, req)
        , _status ("Waiting")
 {
 
index 3776ea4c1d6404e11f5842daaea9baffc41f10ff..fe34867b250123a8722f5fe83c15ac74f403c2ab 100644 (file)
@@ -40,7 +40,8 @@ using namespace boost;
  *  @param l A log that we can write to.
  */
 TranscodeJob::TranscodeJob (shared_ptr<const FilmState> s, shared_ptr<const Options> o, Log* l, shared_ptr<Job> req)
-       : Job (s, o, l, req)
+       : Job (s, l, req)
+       , _opt (o)
 {
        
 }
index fe68a49100630dac9b9cad0bfc72cf284f016b44..d185cb65dfa6a73721865d39d2247032a8c9f6bb 100644 (file)
@@ -42,5 +42,6 @@ protected:
        int remaining_time () const;
 
 private:
+       boost::shared_ptr<const Options> _opt;
        boost::shared_ptr<Encoder> _encoder;
 };
index 468e6c1fddcfd37da4920f7bf3085ee88e65c47c..5aed18c523043512729a14533c85fbb9ccc56350 100644 (file)
@@ -426,8 +426,8 @@ BOOST_AUTO_TEST_CASE (audio_sampling_rate_test)
 class TestJob : public Job
 {
 public:
-       TestJob (shared_ptr<const FilmState> s, shared_ptr<const Options> o, Log* l, shared_ptr<Job> req)
-               : Job (s, o, l, req)
+       TestJob (shared_ptr<const FilmState> s, Log* l, shared_ptr<Job> req)
+               : Job (s, l, req)
        {
 
        }
@@ -457,11 +457,10 @@ public:
 BOOST_AUTO_TEST_CASE (job_manager_test)
 {
        shared_ptr<const FilmState> s;
-       shared_ptr<const Options> o;
        FileLog log ("build/test/job_manager_test.log");
 
        /* Single job, no dependency */
-       shared_ptr<TestJob> a (new TestJob (s, o, &log, shared_ptr<Job> ()));
+       shared_ptr<TestJob> a (new TestJob (s, &log, shared_ptr<Job> ()));
 
        JobManager::instance()->add (a);
        dvdomatic_sleep (1);
@@ -471,8 +470,8 @@ BOOST_AUTO_TEST_CASE (job_manager_test)
        BOOST_CHECK_EQUAL (a->finished_ok(), true);
 
        /* Two jobs, dependency */
-       a.reset (new TestJob (s, o, &log, shared_ptr<Job> ()));
-       shared_ptr<TestJob> b (new TestJob (s, o, &log, a));
+       a.reset (new TestJob (s, &log, shared_ptr<Job> ()));
+       shared_ptr<TestJob> b (new TestJob (s, &log, a));
 
        JobManager::instance()->add (a);
        JobManager::instance()->add (b);
@@ -488,8 +487,8 @@ BOOST_AUTO_TEST_CASE (job_manager_test)
        BOOST_CHECK_EQUAL (b->finished_ok(), true);
 
        /* Two jobs, dependency, first fails */
-       a.reset (new TestJob (s, o, &log, shared_ptr<Job> ()));
-       b.reset (new TestJob (s, o, &log, a));
+       a.reset (new TestJob (s, &log, shared_ptr<Job> ()));
+       b.reset (new TestJob (s, &log, a));
 
        JobManager::instance()->add (a);
        JobManager::instance()->add (b);