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.)
25 #include "dcp_content_type.h"
31 vector<DCPContentType const *> DCPContentType::_dcp_content_types;
33 DCPContentType::DCPContentType (string p, libdcp::ContentKind k, string d)
42 DCPContentType::setup_dcp_content_types ()
44 _dcp_content_types.push_back (new DCPContentType (_("Feature"), libdcp::FEATURE, N_("FTR")));
45 _dcp_content_types.push_back (new DCPContentType (_("Short"), libdcp::SHORT, N_("SHR")));
46 _dcp_content_types.push_back (new DCPContentType (_("Trailer"), libdcp::TRAILER, N_("TLR")));
47 _dcp_content_types.push_back (new DCPContentType (_("Test"), libdcp::TEST, N_("TST")));
48 _dcp_content_types.push_back (new DCPContentType (_("Transitional"), libdcp::TRANSITIONAL, N_("XSN")));
49 _dcp_content_types.push_back (new DCPContentType (_("Rating"), libdcp::RATING, N_("RTG")));
50 _dcp_content_types.push_back (new DCPContentType (_("Teaser"), libdcp::TEASER, N_("TSR")));
51 _dcp_content_types.push_back (new DCPContentType (_("Policy"), libdcp::POLICY, N_("POL")));
52 _dcp_content_types.push_back (new DCPContentType (_("Public Service Announcement"), libdcp::PUBLIC_SERVICE_ANNOUNCEMENT, N_("PSA")));
53 _dcp_content_types.push_back (new DCPContentType (_("Advertisement"), libdcp::ADVERTISEMENT, N_("ADV")));
56 DCPContentType const *
57 DCPContentType::from_pretty_name (string n)
59 for (vector<DCPContentType const *>::const_iterator i = _dcp_content_types.begin(); i != _dcp_content_types.end(); ++i) {
60 if ((*i)->pretty_name() == n) {
68 DCPContentType const *
69 DCPContentType::from_dci_name (string n)
71 for (vector<DCPContentType const *>::const_iterator i = _dcp_content_types.begin(); i != _dcp_content_types.end(); ++i) {
72 if ((*i)->dci_name() == n) {
80 DCPContentType const *
81 DCPContentType::from_index (int n)
83 assert (n >= 0 && n < int (_dcp_content_types.size ()));
84 return _dcp_content_types[n];
88 DCPContentType::as_index (DCPContentType const * c)
90 vector<DCPContentType*>::size_type i = 0;
91 while (i < _dcp_content_types.size() && _dcp_content_types[i] != c) {
95 if (i == _dcp_content_types.size ()) {
102 vector<DCPContentType const *>
103 DCPContentType::all ()
105 return _dcp_content_types;