Pull methods out of CinemaKDMs.
authorCarl Hetherington <cth@carlh.net>
Mon, 4 May 2020 21:37:22 +0000 (23:37 +0200)
committerCarl Hetherington <cth@carlh.net>
Wed, 6 May 2020 18:15:26 +0000 (20:15 +0200)
src/lib/cinema_kdms.cc
src/lib/cinema_kdms.h
src/lib/send_kdm_email_job.cc
src/tools/dcpomatic_kdm_cli.cc
src/wx/kdm_output_panel.cc

index 56b76d3..d96a95d 100644 (file)
@@ -43,13 +43,13 @@ using boost::function;
 using boost::optional;
 
 void
-CinemaKDMs::make_zip_file (boost::filesystem::path zip_file, dcp::NameFormat name_format, dcp::NameFormat::Map name_values) const
+make_zip_file (CinemaKDMs kdms, boost::filesystem::path zip_file, dcp::NameFormat name_format, dcp::NameFormat::Map name_values)
 {
        Zipper zipper (zip_file);
 
-       name_values['c'] = cinema->name;
+       name_values['c'] = kdms.cinema->name;
 
-       BOOST_FOREACH (KDMWithMetadataPtr i, screen_kdms) {
+       BOOST_FOREACH (KDMWithMetadataPtr i, kdms.screen_kdms) {
                name_values['i'] = i->kdm_id ();
                string const name = careful_string_filter(name_format.get(name_values, ".xml"));
                zipper.add (name, i->kdm_as_xml());
@@ -62,7 +62,7 @@ CinemaKDMs::make_zip_file (boost::filesystem::path zip_file, dcp::NameFormat nam
  *  CinemaKDM contains the KDMs for its cinema.
  */
 list<CinemaKDMs>
-CinemaKDMs::collect (list<KDMWithMetadataPtr> screen_kdms)
+collect (list<KDMWithMetadataPtr> screen_kdms)
 {
        list<CinemaKDMs> cinema_kdms;
 
@@ -98,7 +98,7 @@ CinemaKDMs::collect (list<KDMWithMetadataPtr> screen_kdms)
 
 /** Write one directory per cinema into another directory */
 int
-CinemaKDMs::write_directories (
+write_directories (
        list<CinemaKDMs> cinema_kdms,
        boost::filesystem::path directory,
        dcp::NameFormat container_name_format,
@@ -128,7 +128,7 @@ CinemaKDMs::write_directories (
 
 /** Write one ZIP file per cinema into a directory */
 int
-CinemaKDMs::write_zip_files (
+write_zip_files (
        list<CinemaKDMs> cinema_kdms,
        boost::filesystem::path directory,
        dcp::NameFormat container_name_format,
@@ -151,7 +151,7 @@ CinemaKDMs::write_zip_files (
                                /* Creating a new zip file over an existing one is an error */
                                boost::filesystem::remove (path);
                        }
-                       i.make_zip_file (path, filename_format, name_values);
+                       make_zip_file (i, path, filename_format, name_values);
                        written += i.screen_kdms.size();
                }
        }
@@ -167,7 +167,7 @@ CinemaKDMs::write_zip_files (
  *  @param cpl_name Name of the CPL that the KDMs are for.
  */
 void
-CinemaKDMs::email (
+email (
        list<CinemaKDMs> cinema_kdms,
        dcp::NameFormat container_name_format,
        dcp::NameFormat filename_format,
@@ -195,7 +195,7 @@ CinemaKDMs::email (
                boost::filesystem::path zip_file = boost::filesystem::temp_directory_path() / boost::filesystem::unique_path();
                boost::filesystem::create_directories (zip_file);
                zip_file /= container_name_format.get(name_values, ".zip");
-               i.make_zip_file (zip_file, filename_format, name_values);
+               make_zip_file (i, zip_file, filename_format, name_values);
 
                string subject = config->kdm_subject();
                boost::algorithm::replace_all (subject, "$CPL_NAME", cpl_name);
index 9186703..592bec9 100644 (file)
@@ -27,11 +27,15 @@ class Log;
 class CinemaKDMs
 {
 public:
-       void make_zip_file (boost::filesystem::path zip_file, dcp::NameFormat name_format, dcp::NameFormat::Map name_values) const;
+       boost::shared_ptr<Cinema> cinema;
+       std::list<KDMWithMetadataPtr > screen_kdms;
+};
+
+void make_zip_file (CinemaKDMs kdms, boost::filesystem::path zip_file, dcp::NameFormat name_format, dcp::NameFormat::Map name_values);
 
-       static std::list<CinemaKDMs> collect (std::list<KDMWithMetadataPtr > kdms);
+std::list<CinemaKDMs> collect (std::list<KDMWithMetadataPtr > kdms);
 
-       static int write_directories (
+int write_directories (
                std::list<CinemaKDMs> cinema_kdms,
                boost::filesystem::path directory,
                dcp::NameFormat container_name_format,
@@ -40,7 +44,7 @@ public:
                boost::function<bool (boost::filesystem::path)> confirm_overwrite
                );
 
-       static int write_zip_files (
+int write_zip_files (
                std::list<CinemaKDMs> cinema_kdms,
                boost::filesystem::path directory,
                dcp::NameFormat container_name_format,
@@ -49,7 +53,7 @@ public:
                boost::function<bool (boost::filesystem::path)> confirm_overwrite
                );
 
-       static void email (
+void email (
                std::list<CinemaKDMs> cinema_kdms,
                dcp::NameFormat container_name_format,
                dcp::NameFormat filename_format,
@@ -57,6 +61,3 @@ public:
                std::string cpl_name
                );
 
-       boost::shared_ptr<Cinema> cinema;
-       std::list<KDMWithMetadataPtr > screen_kdms;
-};
index 1b476fa..10a571e 100644 (file)
@@ -79,7 +79,7 @@ void
 SendKDMEmailJob::run ()
 {
        set_progress_unknown ();
-       CinemaKDMs::email (_cinema_kdms, _container_name_format, _filename_format, _name_values, _cpl_name);
+       email (_cinema_kdms, _container_name_format, _filename_format, _name_values, _cpl_name);
        set_progress (1);
        set_state (FINISHED_OK);
 }
index dd7fc82..493eea2 100644 (file)
@@ -140,8 +140,8 @@ write_files (
        )
 {
        if (zip) {
-               int const N = CinemaKDMs::write_zip_files (
-                       CinemaKDMs::collect (screen_kdms),
+               int const N = write_zip_files (
+                       collect (screen_kdms),
                        output,
                        container_name_format,
                        filename_format,
index 541674a..fe87dfc 100644 (file)
@@ -186,7 +186,7 @@ KDMOutputPanel::make (
        list<KDMWithMetadataPtr> screen_kdms, string name, KDMTimingPanel* timing, function<bool (boost::filesystem::path)> confirm_overwrite
        )
 {
-       list<CinemaKDMs> const cinema_kdms = CinemaKDMs::collect (screen_kdms);
+       list<CinemaKDMs> const cinema_kdms = collect (screen_kdms);
 
        /* Decide whether to proceed */
 
@@ -255,8 +255,8 @@ KDMOutputPanel::make (
                                        confirm_overwrite
                                        );
                        } else if (_write_folder->GetValue()) {
-                               written = CinemaKDMs::write_directories (
-                                       CinemaKDMs::collect (screen_kdms),
+                               written = write_directories (
+                                       collect (screen_kdms),
                                        directory(),
                                        _container_name_format->get(),
                                        _filename_format->get(),
@@ -264,8 +264,8 @@ KDMOutputPanel::make (
                                        confirm_overwrite
                                        );
                        } else if (_write_zip->GetValue()) {
-                               written = CinemaKDMs::write_zip_files (
-                                       CinemaKDMs::collect (screen_kdms),
+                               written = write_zip_files (
+                                       collect (screen_kdms),
                                        directory(),
                                        _container_name_format->get(),
                                        _filename_format->get(),