2 Copyright (C) 2016 Paul Davis
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.
24 #include "pbd/enumwriter.h"
25 #include "pbd/error.h"
26 #include "pbd/failed_constructor.h"
27 #include "pbd/xml++.h"
29 #include "ardour/presentation_info.h"
33 using namespace ARDOUR;
37 const PresentationInfo::order_t PresentationInfo::max_order = UINT32_MAX;
38 const PresentationInfo::Flag PresentationInfo::Bus = PresentationInfo::Flag (PresentationInfo::AudioBus|PresentationInfo::MidiBus);
39 const PresentationInfo::Flag PresentationInfo::Track = PresentationInfo::Flag (PresentationInfo::AudioTrack|PresentationInfo::MidiTrack);
40 const PresentationInfo::Flag PresentationInfo::Route = PresentationInfo::Flag (PresentationInfo::Bus|PresentationInfo::Track);
42 PresentationInfo::PresentationInfo (std::string const & str)
45 throw failed_constructor ();
50 PresentationInfo::parse (string const& str)
52 std::stringstream s (str);
54 /* new school, segmented string "NNN:TYPE" */
62 _flags = Flag (string_2_enum (f, _flags)|GroupOrderSet);
63 std::cerr << "Parsed [" << str << "] as " << _order << " + " << enum_2_string (_flags) << std::endl;
68 PresentationInfo::parse (uint32_t n, Flag f)
71 assert (f != Flag (0));
73 _flags = Flag (f|GroupOrderSet);
75 _order = (n & 0xffff);
76 _flags = Flag ((n >> 16)|GroupOrderSet);
83 PresentationInfo::to_string() const
87 /* Do not save or selected hidden status, or group-order set bit */
89 Flag f = Flag (_flags & ~(Hidden|Selected|GroupOrderSet));
91 ss << _order << ':' << enum_2_string (f);
96 PresentationInfo::Flag
97 PresentationInfo::get_flags (XMLNode const& node)
99 const XMLProperty *prop;
100 XMLNodeList nlist = node.children ();
101 XMLNodeConstIterator niter;
104 for (niter = nlist.begin(); niter != nlist.end(); ++niter){
107 if (child->name() == X_("PresentationInfo")) {
108 if ((prop = child->property (X_("value"))) != 0) {
109 PresentationInfo pi (prop->value());
118 operator<<(std::ostream& o, ARDOUR::PresentationInfo const& rid)
120 return o << rid.to_string ();