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>
42 * @brief Parent class for DCP assets, i.e. picture, sound, subtitles, CPLs, fonts.
44 * Note that this class is not used for ReelAssets; those are just for the metadata
45 * that gets put into <Reel>s.
47 class Asset : public Object
51 Asset (boost::filesystem::path file);
52 Asset (std::string id, boost::filesystem::path file);
55 boost::shared_ptr<const Asset> other,
60 /** Write details of the asset to a ASSETMAP.
61 * @param node Parent node.
63 void write_to_assetmap (xmlpp::Node* node, boost::filesystem::path root) const;
65 /** Write details of the asset to a PKL AssetList node.
66 * @param node Parent node.
67 * @param standard Standard to use.
69 void write_to_pkl (xmlpp::Node* node, boost::filesystem::path root, Standard standard) const;
71 /** @return the most recent disk file used to read or write this asset; may be empty */
72 boost::filesystem::path file () const {
76 void set_file (boost::filesystem::path file) const;
78 /** @return the hash of this asset's file */
79 std::string hash (boost::function<void (float)> progress = 0) const;
82 friend struct ::asset_test;
84 virtual std::string pkl_type (Standard standard) const = 0;
86 /** The most recent disk file used to read or write this asset; may be empty */
87 mutable boost::filesystem::path _file;
88 /** Hash of _file, or empty if the hash has not yet been computed */
89 mutable std::string _hash;