Add some explicit declarations to constructors.
[libdcp.git] / src / asset.h
1 /*
2     Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
3
4     This file is part of libdcp.
5
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.
10
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.
15
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/>.
18 */
19
20 /** @file  src/asset.h
21  *  @brief Asset class.
22  */
23
24 #ifndef LIBDCP_ASSET_H
25 #define LIBDCP_ASSET_H
26
27 #include "object.h"
28 #include "types.h"
29 #include <boost/filesystem.hpp>
30 #include <boost/function.hpp>
31 #include <boost/bind.hpp>
32 #include <boost/optional.hpp>
33
34 namespace xmlpp {
35         class Node;
36 }
37
38 struct asset_test;
39
40 namespace dcp {
41
42 /** @class Asset
43  *  @brief Parent class for DCP assets, i.e. picture, sound, subtitles, CPLs, fonts.
44  *
45  *  Note that this class is not used for ReelAssets; those are just for the metadata
46  *  that gets put into &lt;Reel&gt;s.
47  */
48 class Asset : public Object
49 {
50 public:
51         Asset ();
52         explicit Asset (boost::filesystem::path file);
53         Asset (std::string id, boost::filesystem::path file);
54
55         virtual bool equals (
56                 boost::shared_ptr<const Asset> other,
57                 EqualityOptions opt,
58                 NoteHandler note
59                 ) const;
60
61         /** Write details of the asset to a ASSETMAP.
62          *  @param node Parent node.
63          */
64         void write_to_assetmap (xmlpp::Node* node, boost::filesystem::path root) const;
65
66         /** Write details of the asset to a PKL AssetList node.
67          *  @param node Parent node.
68          *  @param standard Standard to use.
69          */
70         void write_to_pkl (xmlpp::Node* node, boost::filesystem::path root, Standard standard) const;
71
72         /** @return the most recent disk file used to read or write this asset; may be empty */
73         boost::filesystem::path file () const {
74                 return _file;
75         }
76
77         void set_file (boost::filesystem::path file) const;
78
79         /** @return the hash of this asset's file */
80         std::string hash (boost::function<void (float)> progress = 0) const;
81
82         void set_hash (std::string hash);
83
84 protected:
85
86         /** The most recent disk file used to read or write this asset; may be empty */
87         mutable boost::filesystem::path _file;
88
89 private:
90         friend struct ::asset_test;
91
92         virtual std::string pkl_type (Standard standard) const = 0;
93
94         /** Hash of _file if it has been computed */
95         mutable boost::optional<std::string> _hash;
96 };
97
98 }
99
100 #endif