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" */
64 _flags = Flag (string_2_enum (f, _flags)|GroupOrderSet);
70 PresentationInfo::parse (uint32_t n, Flag f)
73 assert (f != Flag (0));
75 _flags = Flag (f|GroupOrderSet);
77 _order = (n & 0xffff);
78 _flags = Flag ((n >> 16)|GroupOrderSet);
85 PresentationInfo::to_string() const
89 /* Do not save or selected hidden status, or group-order set bit */
91 Flag f = Flag (_flags & ~(Hidden|Selected|GroupOrderSet));
93 ss << _order << ':' << enum_2_string (f);
98 PresentationInfo::Flag
99 PresentationInfo::get_flags (XMLNode const& node)
101 const XMLProperty *prop;
102 XMLNodeList nlist = node.children ();
103 XMLNodeConstIterator niter;
106 for (niter = nlist.begin(); niter != nlist.end(); ++niter){
109 if (child->name() == X_("PresentationInfo")) {
110 if ((prop = child->property (X_("value"))) != 0) {
111 PresentationInfo pi (prop->value());
120 operator<<(std::ostream& o, ARDOUR::PresentationInfo const& rid)
122 return o << rid.to_string ();