2 Copyright (C) 2014 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/>.
24 #ifndef LIBDCP_ASSET_H
25 #define LIBDCP_ASSET_H
29 #include <boost/filesystem.hpp>
30 #include <boost/function.hpp>
31 #include <boost/bind.hpp>
32 #include <boost/optional.hpp>
43 * @brief Parent class for DCP assets, i.e. picture, sound, subtitles, CPLs, fonts.
45 * Note that this class is not used for ReelAssets; those are just for the metadata
46 * that gets put into <Reel>s.
48 class Asset : public Object
52 explicit Asset (boost::filesystem::path file);
53 Asset (std::string id, boost::filesystem::path file);
56 boost::shared_ptr<const Asset> other,
61 /** Write details of the asset to a ASSETMAP.
62 * @param node Parent node.
64 void write_to_assetmap (xmlpp::Node* node, boost::filesystem::path root) const;
66 /** Write details of the asset to a PKL AssetList node.
67 * @param node Parent node.
68 * @param standard Standard to use.
70 void write_to_pkl (xmlpp::Node* node, boost::filesystem::path root, Standard standard) const;
72 /** @return the most recent disk file used to read or write this asset; may be empty */
73 boost::filesystem::path file () const {
77 void set_file (boost::filesystem::path file) const;
79 /** @return the hash of this asset's file */
80 std::string hash (boost::function<void (float)> progress = 0) const;
82 void set_hash (std::string hash);
86 /** The most recent disk file used to read or write this asset; may be empty */
87 mutable boost::filesystem::path _file;
90 friend struct ::asset_test;
92 virtual std::string pkl_type (Standard standard) const = 0;
94 /** Hash of _file if it has been computed */
95 mutable boost::optional<std::string> _hash;