fix up file renaming code a little bit
[ArdourMidi.git] / libs / ardour / export_format_base.cc
bloba994b97ac3bbe30498efbac605a78f187949a9ad
1 /*
2 Copyright (C) 2008 Paul Davis
3 Author: Sakari Bergen
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include "ardour/export_format_base.h"
23 namespace ARDOUR
26 void
27 ExportFormatBase::SelectableCompatible::set_selected (bool value)
29 if (_selected != value) {
30 _selected = value;
31 SelectChanged (value);
35 void
36 ExportFormatBase::SelectableCompatible::set_compatible (bool value)
38 if (_compatible != value) {
39 _compatible = value;
40 CompatibleChanged (value);
42 if (!value) {
43 set_selected (false);
47 ExportFormatBase::ExportFormatBase ()
52 ExportFormatBase::ExportFormatBase (ExportFormatBase const & other) :
53 sample_formats (other.sample_formats),
54 endiannesses (other.endiannesses),
55 sample_rates (other.sample_rates),
56 format_ids (other.format_ids),
57 qualities (other.qualities)
62 ExportFormatBase::~ExportFormatBase ()
67 boost::shared_ptr<ExportFormatBase>
68 ExportFormatBase::get_intersection (ExportFormatBase const & other) const
70 return do_set_operation (other, SetIntersection);
73 boost::shared_ptr<ExportFormatBase>
74 ExportFormatBase::get_difference (ExportFormatBase const & other) const
76 return do_set_operation (other, SetDifference);
79 boost::shared_ptr<ExportFormatBase>
80 ExportFormatBase::get_union (ExportFormatBase const & other) const
82 return do_set_operation (other, SetUnion);
85 boost::shared_ptr<ExportFormatBase>
86 ExportFormatBase::do_set_operation (ExportFormatBase const & other, SetOperation operation) const
88 boost::shared_ptr<ExportFormatBase> result (new ExportFormatBase ());
90 /* Sets */
92 // Endiannesses
94 EndianSet::const_iterator start1 = endiannesses.begin();
95 EndianSet::const_iterator end1 = endiannesses.end();
96 EndianSet::const_iterator start2 = other.endiannesses.begin();
97 EndianSet::const_iterator end2 = other.endiannesses.end();
98 std::insert_iterator<EndianSet> insert (result->endiannesses, result->endiannesses.begin());
100 switch (operation) {
101 case SetIntersection:
102 std::set_intersection (start1, end1, start2, end2, insert);
103 break;
104 case SetDifference:
105 std::set_difference (start1, end1, start2, end2, insert);
106 break;
107 case SetUnion:
108 std::set_union (start1, end1, start2, end2, insert);
109 break;
113 // Sample formats
115 SampleFormatSet::const_iterator start1 = sample_formats.begin();
116 SampleFormatSet::const_iterator end1 = sample_formats.end();
117 SampleFormatSet::const_iterator start2 = other.sample_formats.begin();
118 SampleFormatSet::const_iterator end2 = other.sample_formats.end();
119 std::insert_iterator<SampleFormatSet> insert (result->sample_formats, result->sample_formats.begin());
121 switch (operation) {
122 case SetIntersection:
123 std::set_intersection (start1, end1, start2, end2, insert);
124 break;
125 case SetDifference:
126 std::set_difference (start1, end1, start2, end2, insert);
127 break;
128 case SetUnion:
129 std::set_union (start1, end1, start2, end2, insert);
130 break;
135 // Sample rates
137 SampleRateSet::const_iterator start1 = sample_rates.begin();
138 SampleRateSet::const_iterator end1 = sample_rates.end();
139 SampleRateSet::const_iterator start2 = other.sample_rates.begin();
140 SampleRateSet::const_iterator end2 = other.sample_rates.end();
141 std::insert_iterator<SampleRateSet> insert (result->sample_rates, result->sample_rates.begin());
143 switch (operation) {
144 case SetIntersection:
145 std::set_intersection (start1, end1, start2, end2, insert);
146 break;
147 case SetDifference:
148 std::set_difference (start1, end1, start2, end2, insert);
149 break;
150 case SetUnion:
151 std::set_union (start1, end1, start2, end2, insert);
152 break;
156 // Format ids
158 FormatSet::const_iterator start1 = format_ids.begin();
159 FormatSet::const_iterator end1 = format_ids.end();
160 FormatSet::const_iterator start2 = other.format_ids.begin();
161 FormatSet::const_iterator end2 = other.format_ids.end();
162 std::insert_iterator<FormatSet> insert (result->format_ids, result->format_ids.begin());
164 switch (operation) {
165 case SetIntersection:
166 std::set_intersection (start1, end1, start2, end2, insert);
167 break;
168 case SetDifference:
169 std::set_difference (start1, end1, start2, end2, insert);
170 break;
171 case SetUnion:
172 std::set_union (start1, end1, start2, end2, insert);
173 break;
177 // Qualities
179 QualitySet::const_iterator start1 = qualities.begin();
180 QualitySet::const_iterator end1 = qualities.end();
181 QualitySet::const_iterator start2 = other.qualities.begin();
182 QualitySet::const_iterator end2 = other.qualities.end();
183 std::insert_iterator<QualitySet> insert (result->qualities, result->qualities.begin());
185 switch (operation) {
186 case SetIntersection:
187 std::set_intersection (start1, end1, start2, end2, insert);
188 break;
189 case SetDifference:
190 std::set_difference (start1, end1, start2, end2, insert);
191 break;
192 case SetUnion:
193 std::set_union (start1, end1, start2, end2, insert);
194 break;
198 return result;
201 }; // namespace ARDOUR