2 Copyright (C) 2018-2021 Carl Hetherington <cth@carlh.net>
4 This file is part of libdcp.
6 libdcp 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.
11 libdcp 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.
16 You should have received a copy of the GNU General Public License
17 along with libdcp. If not, see <http://www.gnu.org/licenses/>.
19 In addition, as a special exception, the copyright holders give
20 permission to link the code of portions of this program with the
21 OpenSSL library under certain conditions as described in each
22 individual source file, and distribute linked combinations
25 You must obey the GNU General Public License in all respects
26 for all of the code used other than OpenSSL. If you modify
27 file(s) with this exception, you may extend this exception to your
28 version of the file(s), but you are not obligated to do so. If you
29 do not wish to do so, delete this exception statement from your
30 version. If you delete this exception statement from all source
31 files in the program, then also delete it here.
44 #include "asset_list.h"
48 #include "certificate_chain.h"
49 #include <libcxml/cxml.h>
50 #include <boost/filesystem.hpp>
56 class PKL : public Object, public AssetList
59 PKL (Standard standard, boost::optional<std::string> annotation_text, std::string issue_date, std::string issuer, std::string creator)
60 : AssetList(standard, annotation_text, issue_date, issuer, creator)
63 explicit PKL (boost::filesystem::path file);
65 boost::optional<std::string> hash (std::string id) const;
66 boost::optional<std::string> type (std::string id) const;
69 void add_asset(std::string id, boost::optional<std::string> annotation_text, std::string hash, int64_t size, std::string type, std::string original_filename);
70 void write_xml (boost::filesystem::path file, std::shared_ptr<const CertificateChain> signer) const;
72 /** @return the most recent disk file used to read or write this PKL, if there is one */
73 boost::optional<boost::filesystem::path> file () const {
77 class Asset : public Object
80 Asset (cxml::ConstNodePtr node)
81 : Object (remove_urn_uuid(node->string_child("Id")))
82 , _annotation_text (node->optional_string_child("AnnotationText"))
83 , _hash (node->string_child("Hash"))
84 , _size (node->number_child<int64_t>("Size"))
85 , _type (node->string_child("Type"))
86 , _original_filename(node->optional_string_child("OriginalFileName"))
89 Asset(std::string id, boost::optional<std::string> annotation_text, std::string hash, int64_t size, std::string type, std::string original_filename)
91 , _annotation_text (annotation_text)
95 , _original_filename(original_filename)
98 boost::optional<std::string> annotation_text () const {
99 return _annotation_text;
102 std::string hash () const {
106 int64_t size () const {
110 std::string type () const {
114 boost::optional<std::string> original_filename() const {
115 return _original_filename;
119 boost::optional<std::string> _annotation_text;
123 boost::optional<std::string> _original_filename;
126 std::vector<std::shared_ptr<Asset>> assets() const {
131 std::vector<std::shared_ptr<Asset>> _assets;
132 /** The most recent disk file used to read or write this PKL */
133 mutable boost::optional<boost::filesystem::path> _file;