Fix the build for older macOS.
[dcpomatic.git] / src / lib / ratio.h
1 /*
2     Copyright (C) 2013-2021 Carl Hetherington <cth@carlh.net>
3
4     This file is part of DCP-o-matic.
5
6     DCP-o-matic 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     DCP-o-matic 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 DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
18
19 */
20
21
22 #ifndef DCPOMATIC_RATIO_H
23 #define DCPOMATIC_RATIO_H
24
25
26 #include <dcp/util.h>
27 #include <boost/utility.hpp>
28 #include <vector>
29
30
31 /** @class Ratio
32  *  @brief Description of an image ratio.
33  */
34 class Ratio
35 {
36 public:
37         Ratio (float ratio, std::string id, std::string in, boost::optional<std::string> cn, std::string d)
38                 : _ratio (ratio)
39                 , _id (id)
40                 , _image_nickname (in)
41                 , _container_nickname (cn)
42                 , _isdcf_name (d)
43         {}
44
45         Ratio (Ratio const&) = delete;
46         Ratio& operator= (Ratio const&) = delete;
47
48         std::string id () const {
49                 return _id;
50         }
51
52         std::string image_nickname () const {
53                 return _image_nickname;
54         }
55
56         std::string container_nickname () const;
57
58         bool used_for_container () const {
59                 return static_cast<bool>(_container_nickname);
60         }
61
62         std::string isdcf_name () const {
63                 return _isdcf_name;
64         }
65
66         float ratio () const {
67                 return _ratio;
68         }
69
70         static void setup_ratios ();
71         static Ratio const * from_id (std::string i);
72         static Ratio const * from_ratio (float r);
73         static Ratio const * nearest_from_ratio (float r);
74
75         static std::vector<Ratio const *> all () {
76                 return _ratios;
77         }
78
79         static std::vector<Ratio const *> containers ();
80
81 private:
82         float _ratio;
83         /** id for use in metadata */
84         std::string _id;
85         /** nickname when used to describe an image ratio (e.g. Flat, Scope) */
86         std::string _image_nickname;
87         /** nickname when used to describe a container ratio */
88         boost::optional<std::string> _container_nickname;
89         std::string _isdcf_name;
90
91         static std::vector<Ratio const *> _ratios;
92 };
93
94
95 #endif