Try to move XML bits out into parse/ subdir.
[libdcp.git] / src / cpl.h
1 /*
2     Copyright (C) 2012 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 #include <list>
21 #include <boost/shared_ptr.hpp>
22 #include <boost/function.hpp>
23 #include "types.h"
24
25 namespace libdcp {
26
27 namespace parse {
28         class AssetMap;
29 }
30         
31 class Asset;
32 class Reel;
33 class XMLMetadata;
34
35 /** @brief A CPL within a DCP */
36 class CPL
37 {
38 public:
39         CPL (std::string directory, std::string name, ContentKind content_kind, int length, int frames_per_second);
40         CPL (std::string directory, std::string file, boost::shared_ptr<const parse::AssetMap> asset_map, bool require_mxfs = true);
41
42         void add_reel (boost::shared_ptr<const Reel> reel);
43         
44         /** @return the length in frames */
45         int length () const {
46                 return _length;
47         }
48
49         /** @return the type of the content, used by media servers
50          *  to categorise things (e.g. feature, trailer, etc.)
51          */
52         ContentKind content_kind () const {
53                 return _content_kind;
54         }
55
56         std::list<boost::shared_ptr<const Reel> > reels () const {
57                 return _reels;
58         }
59
60         /** @return the CPL's name, as will be presented on projector
61          *  media servers and theatre management systems.
62          */
63         std::string name () const {
64                 return _name;
65         }
66
67         /** @return the number of frames per second */
68         int frames_per_second () const {
69                 return _fps;
70         }
71
72         std::list<boost::shared_ptr<const Asset> > assets () const;
73         
74         bool equals (CPL const & other, EqualityOptions options, boost::function<void (NoteType, std::string)> note) const;
75         
76         void write_xml (XMLMetadata const &) const;
77         void write_to_assetmap (std::ostream& s) const;
78         void write_to_pkl (std::ostream& s) const;
79         
80 private:
81         std::string _directory;
82         /** the name of the DCP */
83         std::string _name;
84         /** the content kind of the CPL */
85         ContentKind _content_kind;
86         /** length in frames */
87         mutable int _length;
88         /** frames per second */
89         int _fps;
90         /** reels */
91         std::list<boost::shared_ptr<const Reel> > _reels;
92
93         /** our UUID */
94         std::string _uuid;
95         /** a SHA1 digest of our XML */
96         mutable std::string _digest;
97 };
98
99 }