swaroop: allow ScreenKDM subclasses for different KDM types.
[dcpomatic.git] / src / lib / screen_kdm.h
1 /*
2     Copyright (C) 2013-2019 Carl Hetherington <cth@carlh.net>
3
4     This file is part of DCP-o-matic.
5
6     DCP-o-matic is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     DCP-o-matic is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
18
19 */
20
21 #ifndef DCPOMATIC_SCREEN_KDM_H
22 #define DCPOMATIC_SCREEN_KDM_H
23
24 #ifdef DCPOMATIC_VARIANT_SWAROOP
25 #include "encrypted_ecinema_kdm.h"
26 #endif
27 #include <dcp/encrypted_kdm.h>
28 #include <dcp/name_format.h>
29 #include <boost/shared_ptr.hpp>
30
31 namespace dcpomatic {
32         class Screen;
33 }
34
35 /** Simple class to collect a screen and an encrypted KDM */
36 class ScreenKDM
37 {
38 public:
39         ScreenKDM (boost::shared_ptr<dcpomatic::Screen> s)
40                 : screen (s)
41         {}
42
43         virtual std::string kdm_as_xml () const = 0;
44         virtual void kdm_as_xml (boost::filesystem::path out) const = 0;
45         virtual std::string kdm_id () const = 0;
46
47         static int write_files (
48                 std::list<boost::shared_ptr<ScreenKDM> > screen_kdms, boost::filesystem::path directory,
49                 dcp::NameFormat name_format, dcp::NameFormat::Map name_values,
50                 boost::function<bool (boost::filesystem::path)> confirm_overwrite
51                 );
52
53         boost::shared_ptr<dcpomatic::Screen> screen;
54 };
55
56 class DCPScreenKDM : public ScreenKDM
57 {
58 public:
59         DCPScreenKDM (boost::shared_ptr<dcpomatic::Screen> s, dcp::EncryptedKDM k)
60                 : ScreenKDM (s)
61                 , kdm (k)
62         {}
63
64         std::string kdm_as_xml () const {
65                 return kdm.as_xml ();
66         }
67
68         void kdm_as_xml (boost::filesystem::path out) const {
69                 return kdm.as_xml (out);
70         }
71
72         std::string kdm_id () const {
73                 return kdm.cpl_id ();
74         }
75
76         dcp::EncryptedKDM kdm;
77 };
78
79 #ifdef DCPOMATIC_VARIANT_SWAROOP
80 class ECinemaScreenKDM : public ScreenKDM
81 {
82 public:
83         ECinemaScreenKDM (boost::shared_ptr<dcpomatic::Screen> s, EncryptedECinemaKDM k)
84                 : ScreenKDM (s)
85                 , kdm (k)
86         {}
87
88         std::string kdm_as_xml () const {
89                 return kdm.as_xml ();
90         }
91
92         void kdm_as_xml (boost::filesystem::path out) const {
93                 return kdm.as_xml (out);
94         }
95
96         std::string kdm_id () const {
97                 return kdm.id ();
98         }
99
100         EncryptedECinemaKDM kdm;
101 };
102 #endif
103
104 #endif