Change header include order to try and avoid INFINITE define on windows
[ardour.git] / libs / ardour / chan_mapping.cc
index 1d59faff00033def1aa2858cac7f1d6dcc39a4de..ecec38865659b157c830cef040dbc3d0d3b89489 100644 (file)
 
 #include <stdint.h>
 #include <iostream>
+#include "ardour/types_convert.h"
 #include "ardour/chan_mapping.h"
 
-#include "i18n.h"
+#include "pbd/i18n.h"
 
 static const char* state_node_name = "Channelmap";
 
@@ -59,10 +60,13 @@ ChanMapping::ChanMapping (const XMLNode& node)
        XMLNodeConstIterator iter = node.children().begin();
        for ( ; iter != node.children().end(); ++iter) {
                if ((*iter)->name() == X_(state_node_name)) {
-                       const string& type_str  = (*iter)->property("type")->value();
-                       const string& from_str = (*iter)->property("from")->value();
-                       const string& to_str = (*iter)->property("to")->value();
-                       set(DataType(type_str), atol (from_str.c_str()), atol (to_str.c_str()));
+                       DataType type(DataType::NIL);
+                       uint32_t from;
+                       uint32_t to;
+                       (*iter)->get_property("type", type);
+                       (*iter)->get_property("from", from);
+                       (*iter)->get_property("to", to);
+                       set(type, from, to);
                }
        }
 }
@@ -160,9 +164,9 @@ ChanMapping::state(const std::string& name) const
        for (Mappings::const_iterator tm = mp.begin(); tm != mp.end(); ++tm) {
                for (TypeMapping::const_iterator i = tm->second.begin(); i != tm->second.end(); ++i) {
                        XMLNode* n = new XMLNode(X_(state_node_name));
-                       n->add_property("type", tm->first.to_string());
-                       n->add_property("from", i->first);
-                       n->add_property("to", i->second);
+                       n->set_property("type", tm->first.to_string());
+                       n->set_property("from", i->first);
+                       n->set_property("to", i->second);
                        node->add_child_nocopy(*n);
                }
        }
@@ -219,8 +223,9 @@ ChanMapping::is_identity (ChanCount offset) const
 }
 
 uint32_t
-ChanMapping::count () const
+ChanMapping::n_total () const
 {
+       // fast version of count().n_total();
        uint32_t rv = 0;
        const Mappings& mp (mappings());
        for (Mappings::const_iterator tm = mp.begin(); tm != mp.end(); ++tm) {
@@ -229,6 +234,19 @@ ChanMapping::count () const
        return rv;
 }
 
+ChanCount
+ChanMapping::count () const
+{
+       ChanCount rv;
+       const Mappings& mp (mappings());
+       for (Mappings::const_iterator tm = mp.begin(); tm != mp.end(); ++tm) {
+               rv.set (tm->first, tm->second.size ());
+       }
+       return rv;
+}
+
+
+
 } // namespace ARDOUR
 
 std::ostream& operator<<(std::ostream& o, const ARDOUR::ChanMapping& cm)