2 Copyright (C) 2013-2018 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
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.
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.
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/>.
21 #ifndef DCPOMATIC_RATIO_H
22 #define DCPOMATIC_RATIO_H
25 #include <boost/utility.hpp>
29 * @brief Description of an image ratio.
31 class Ratio : public boost::noncopyable
34 Ratio (float ratio, std::string id, std::string in, boost::optional<std::string> cn, std::string d)
37 , _image_nickname (in)
38 , _container_nickname (cn)
42 std::string id () const {
46 std::string image_nickname () const {
47 return _image_nickname;
50 std::string container_nickname () const;
52 bool used_for_container () const {
53 return static_cast<bool> (_container_nickname);
56 std::string isdcf_name () const {
60 float ratio () const {
64 static void setup_ratios ();
65 static Ratio const * from_id (std::string i);
66 static Ratio const * from_ratio (float r);
67 static Ratio const * nearest_from_ratio (float r);
69 static std::vector<Ratio const *> all () {
73 static std::vector<Ratio const *> containers ();
77 /** id for use in metadata */
79 /** nickname when used to describe an image ratio (e.g. Flat, Scope) */
80 std::string _image_nickname;
81 /** nickname when used to describe a container ratio */
82 boost::optional<std::string> _container_nickname;
83 std::string _isdcf_name;
85 static std::vector<Ratio const *> _ratios;