Template Package and bring some stuff up to there and PackageBase.
[libdcp.git] / src / package_base.h
1 /*
2     Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net>
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #ifndef LIBDCP_PACKAGE_BASE_H
21 #define LIBDCP_PACKAGE_BASE_H
22
23 #include "exceptions.h"
24 #include "types.h"
25 #include "metadata.h"
26 #include <boost/filesystem.hpp>
27
28 namespace dcp {
29
30 class Asset;
31
32 class PackageBase
33 {
34 public:
35         PackageBase (boost::filesystem::path directory);
36
37         typedef std::list<boost::shared_ptr<PackageReadError> > ReadErrors;
38
39         virtual std::list<boost::shared_ptr<Asset> > assets () const = 0;
40
41 protected:
42
43         virtual boost::shared_ptr<Asset> xml_asset_factory (boost::filesystem::path file, std::string root) const = 0;
44         virtual boost::shared_ptr<Asset> mxf_asset_factory (boost::filesystem::path file) const = 0;
45
46         std::list<boost::shared_ptr<Asset> > read_assetmap (bool keep_going, ReadErrors* errors) const;
47
48         void write_volindex (Standard standard) const;
49
50         /** Write the ASSETMAP file.
51          *  @param pkl_uuid UUID of our PKL.
52          *  @param pkl_length Length of our PKL in bytes.
53          */
54         void write_assetmap (Standard standard, std::string pkl_uuid, int pkl_length, XMLMetadata metadata) const;
55
56         /** the directory that the package is in */
57         boost::filesystem::path _directory;
58 };
59
60 }
61
62 #endif