2 Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
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.
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.
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.
20 /** @file src/content_type.cc
21 * @brief A description of the type of content for a DCP (e.g. feature, trailer etc.)
24 #include "dcp_content_type.h"
25 #include "dcpomatic_assert.h"
32 vector<DCPContentType const *> DCPContentType::_dcp_content_types;
34 DCPContentType::DCPContentType (string p, dcp::ContentKind k, string d)
43 DCPContentType::setup_dcp_content_types ()
45 _dcp_content_types.push_back (new DCPContentType (_("Feature"), dcp::FEATURE, N_("FTR")));
46 _dcp_content_types.push_back (new DCPContentType (_("Short"), dcp::SHORT, N_("SHR")));
47 _dcp_content_types.push_back (new DCPContentType (_("Trailer"), dcp::TRAILER, N_("TLR")));
48 _dcp_content_types.push_back (new DCPContentType (_("Test"), dcp::TEST, N_("TST")));
49 _dcp_content_types.push_back (new DCPContentType (_("Transitional"), dcp::TRANSITIONAL, N_("XSN")));
50 _dcp_content_types.push_back (new DCPContentType (_("Rating"), dcp::RATING, N_("RTG")));
51 _dcp_content_types.push_back (new DCPContentType (_("Teaser"), dcp::TEASER, N_("TSR")));
52 _dcp_content_types.push_back (new DCPContentType (_("Policy"), dcp::POLICY, N_("POL")));
53 _dcp_content_types.push_back (new DCPContentType (_("Public Service Announcement"), dcp::PUBLIC_SERVICE_ANNOUNCEMENT, N_("PSA")));
54 _dcp_content_types.push_back (new DCPContentType (_("Advertisement"), dcp::ADVERTISEMENT, N_("ADV")));
57 DCPContentType const *
58 DCPContentType::from_pretty_name (string n)
60 for (vector<DCPContentType const *>::const_iterator i = _dcp_content_types.begin(); i != _dcp_content_types.end(); ++i) {
61 if ((*i)->pretty_name() == n) {
69 DCPContentType const *
70 DCPContentType::from_isdcf_name (string n)
72 for (vector<DCPContentType const *>::const_iterator i = _dcp_content_types.begin(); i != _dcp_content_types.end(); ++i) {
73 if ((*i)->isdcf_name() == n) {
81 DCPContentType const *
82 DCPContentType::from_index (int n)
84 DCPOMATIC_ASSERT (n >= 0 && n < int (_dcp_content_types.size ()));
85 return _dcp_content_types[n];
89 DCPContentType::as_index (DCPContentType const * c)
91 vector<DCPContentType*>::size_type i = 0;
92 while (i < _dcp_content_types.size() && _dcp_content_types[i] != c) {
96 if (i == _dcp_content_types.size ()) {
103 vector<DCPContentType const *>
104 DCPContentType::all ()
106 return _dcp_content_types;