std::shared_ptr
[dcpomatic.git] / src / lib / kdm_with_metadata.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_KDM_WITH_METADATA_H
22 #define DCPOMATIC_KDM_WITH_METADATA_H
23
24 #include <dcp/encrypted_kdm.h>
25 #include <dcp/name_format.h>
26
27 class Cinema;
28
29 class KDMWithMetadata
30 {
31 public:
32         KDMWithMetadata (dcp::NameFormat::Map const& name_values, void const* group, std::list<std::string> emails, dcp::EncryptedKDM kdm)
33                 : _name_values (name_values)
34                 , _group (group)
35                 , _emails (emails)
36                 , _kdm (kdm)
37         {}
38
39         std::string kdm_as_xml () const {
40                 return _kdm.as_xml ();
41         }
42
43         void kdm_as_xml (boost::filesystem::path out) const {
44                 return _kdm.as_xml (out);
45         }
46
47         dcp::NameFormat::Map const& name_values () const {
48                 return _name_values;
49         }
50
51         boost::optional<std::string> get (char k) const;
52
53         void const* group () const {
54                 return _group;
55         }
56
57         std::list<std::string> emails () const {
58                 return _emails;
59         }
60
61 private:
62         dcp::NameFormat::Map _name_values;
63         void const* _group;
64         std::list<std::string> _emails;
65         dcp::EncryptedKDM _kdm;
66 };
67
68
69 typedef std::shared_ptr<KDMWithMetadata> KDMWithMetadataPtr;
70
71
72 int write_files (
73         std::list<KDMWithMetadataPtr> screen_kdms, boost::filesystem::path directory,
74         dcp::NameFormat name_format, boost::function<bool (boost::filesystem::path)> confirm_overwrite
75         );
76
77
78 void make_zip_file (std::list<KDMWithMetadataPtr> kdms, boost::filesystem::path zip_file, dcp::NameFormat name_format);
79
80
81 std::list<std::list<KDMWithMetadataPtr> > collect (std::list<KDMWithMetadataPtr> kdms);
82
83
84 int write_directories (
85                 std::list<std::list<KDMWithMetadataPtr> > kdms,
86                 boost::filesystem::path directory,
87                 dcp::NameFormat container_name_format,
88                 dcp::NameFormat filename_format,
89                 boost::function<bool (boost::filesystem::path)> confirm_overwrite
90                 );
91
92
93 int write_zip_files (
94                 std::list<std::list<KDMWithMetadataPtr> > kdms,
95                 boost::filesystem::path directory,
96                 dcp::NameFormat container_name_format,
97                 dcp::NameFormat filename_format,
98                 boost::function<bool (boost::filesystem::path)> confirm_overwrite
99                 );
100
101
102 void email (
103                 std::list<std::list<KDMWithMetadataPtr> > kdms,
104                 dcp::NameFormat container_name_format,
105                 dcp::NameFormat filename_format,
106                 std::string cpl_name
107                 );
108
109 #endif
110