summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2009-07-04 12:40:26 +0000
committerCarl Hetherington <carl@carlh.net>2009-07-04 12:40:26 +0000
commit36564e4f910bc31fa23a6e73da8440f6ad78a2fc (patch)
treea04b741577686802733c0804311943be44bc65cb /libs
parent12bf437c6eb6677f10ef7d09b1e096cf67ed73b1 (diff)
Use std::string for order key map.
git-svn-id: svn://localhost/ardour2/branches/3.0@5318 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
-rw-r--r--libs/ardour/ardour/route.h16
-rw-r--r--libs/ardour/ardour/session.h2
-rw-r--r--libs/ardour/route.cc29
-rw-r--r--libs/ardour/session.cc2
4 files changed, 18 insertions, 31 deletions
diff --git a/libs/ardour/ardour/route.h b/libs/ardour/ardour/route.h
index 40a11cdae1..5e04837d91 100644
--- a/libs/ardour/ardour/route.h
+++ b/libs/ardour/ardour/route.h
@@ -88,8 +88,8 @@ class Route : public SessionObject, public AutomatableControls
bool set_name (const std::string& str);
- long order_key (const char* name) const;
- void set_order_key (const char* name, long n);
+ long order_key (std::string const &) const;
+ void set_order_key (std::string const &, long);
bool is_hidden() const { return _flags & Hidden; }
bool is_master() const { return _flags & MasterOut; }
@@ -312,8 +312,8 @@ class Route : public SessionObject, public AutomatableControls
uint32_t remote_control_id () const;
sigc::signal<void> RemoteControlIDChanged;
- void sync_order_keys (const char* base);
- static sigc::signal<void,const char*> SyncOrderKeys;
+ void sync_order_keys (std::string const &);
+ static sigc::signal<void, std::string const &> SyncOrderKeys;
protected:
friend class Session;
@@ -399,13 +399,7 @@ class Route : public SessionObject, public AutomatableControls
static uint32_t order_key_cnt;
- struct ltstr {
- bool operator()(const char* s1, const char* s2) const {
- return strcmp(s1, s2) < 0;
- }
- };
-
- typedef std::map<const char*,long,ltstr> OrderKeys;
+ typedef std::map<std::string, long> OrderKeys;
OrderKeys order_keys;
void input_change_handler (IOChange, void *src);
diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h
index 2be7e418dc..429d30a5c1 100644
--- a/libs/ardour/ardour/session.h
+++ b/libs/ardour/ardour/session.h
@@ -321,7 +321,7 @@ class Session : public PBD::StatefulDestructible, public boost::noncopyable
bool operator() (boost::shared_ptr<Route>, boost::shared_ptr<Route> b);
};
- void sync_order_keys (const char* base);
+ void sync_order_keys (std::string const &);
template<class T> void foreach_route (T *obj, void (T::*func)(Route&));
template<class T> void foreach_route (T *obj, void (T::*func)(boost::shared_ptr<Route>));
diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc
index 2eeaba176f..af1a7217d0 100644
--- a/libs/ardour/route.cc
+++ b/libs/ardour/route.cc
@@ -64,7 +64,7 @@ using namespace ARDOUR;
using namespace PBD;
uint32_t Route::order_key_cnt = 0;
-sigc::signal<void,const char*> Route::SyncOrderKeys;
+sigc::signal<void, string const &> Route::SyncOrderKeys;
Route::Route (Session& sess, string name, Flag flg, DataType default_type)
: SessionObject (sess, name)
@@ -121,7 +121,7 @@ Route::init ()
processor_max_streams.reset();
_solo_safe = false;
_recordable = true;
- order_keys[strdup (N_("signal"))] = order_key_cnt++;
+ order_keys[N_("signal")] = order_key_cnt++;
_silent = false;
_meter_point = MeterPostFader;
_initial_delay = 0;
@@ -162,10 +162,6 @@ Route::~Route ()
clear_processors (PreFader);
clear_processors (PostFader);
-
- for (OrderKeys::iterator i = order_keys.begin(); i != order_keys.end(); ++i) {
- free ((void*)(i->first));
- }
}
void
@@ -184,23 +180,20 @@ Route::remote_control_id() const
}
long
-Route::order_key (const char* name) const
+Route::order_key (std::string const & name) const
{
- OrderKeys::const_iterator i;
-
- for (i = order_keys.begin(); i != order_keys.end(); ++i) {
- if (!strcmp (name, i->first)) {
- return i->second;
- }
+ OrderKeys::const_iterator i = order_keys.find (name);
+ if (i == order_keys.end()) {
+ return -1;
}
- return -1;
+ return i->second;
}
void
-Route::set_order_key (const char* name, long n)
+Route::set_order_key (std::string const & name, long n)
{
- order_keys[strdup(name)] = n;
+ order_keys[name] = n;
if (Config->get_sync_all_route_ordering()) {
for (OrderKeys::iterator x = order_keys.begin(); x != order_keys.end(); ++x) {
@@ -212,7 +205,7 @@ Route::set_order_key (const char* name, long n)
}
void
-Route::sync_order_keys (const char* base)
+Route::sync_order_keys (std::string const & base)
{
if (order_keys.empty()) {
return;
@@ -1643,7 +1636,7 @@ Route::_set_state (const XMLNode& node, bool call_base)
error << string_compose (_("badly formed order key string in state file! [%1] ... ignored."), remaining)
<< endmsg;
} else {
- set_order_key (remaining.substr (0, equal).c_str(), n);
+ set_order_key (remaining.substr (0, equal), n);
}
}
diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc
index 15dffb928b..58e68cb353 100644
--- a/libs/ardour/session.cc
+++ b/libs/ardour/session.cc
@@ -4281,7 +4281,7 @@ Session::compute_initial_length ()
}
void
-Session::sync_order_keys (const char* base)
+Session::sync_order_keys (std::string const & base)
{
if (!Config->get_sync_all_route_ordering()) {
/* leave order keys as they are */