diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2007-04-11 13:07:51 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2007-04-11 13:07:51 +0000 |
commit | 45d3ec1437cf661533bc7750c623865def4424df (patch) | |
tree | 80cdeb58bc51a22042b91c50334bdd8ee37deed6 /libs/pbd/controllable.cc | |
parent | 4bf712f501e21cbf1e555bf010553aaca55edd39 (diff) |
merged with 1697 revision of trunk (which is post-rc1 but pre-rc2
git-svn-id: svn://localhost/ardour2/branches/2.1-staging@1698 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/pbd/controllable.cc')
-rw-r--r-- | libs/pbd/controllable.cc | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/libs/pbd/controllable.cc b/libs/pbd/controllable.cc index 049ad0aa21..00638e6c06 100644 --- a/libs/pbd/controllable.cc +++ b/libs/pbd/controllable.cc @@ -10,9 +10,64 @@ sigc::signal<void,Controllable*> Controllable::Destroyed; sigc::signal<bool,Controllable*> Controllable::StartLearning; sigc::signal<void,Controllable*> Controllable::StopLearning; +Glib::Mutex* Controllable::registry_lock = 0; +Controllable::Controllables Controllable::registry; + Controllable::Controllable (std::string name) : _name (name) { + if (registry_lock == 0) { + registry_lock = new Glib::Mutex; + } + + add (); +} + +void +Controllable::add () +{ + Glib::Mutex::Lock lm (*registry_lock); + registry.insert (this); + this->GoingAway.connect (mem_fun (this, &Controllable::remove)); +} + +void +Controllable::remove () +{ + Glib::Mutex::Lock lm (*registry_lock); + for (Controllables::iterator i = registry.begin(); i != registry.end(); ++i) { + if ((*i) == this) { + registry.erase (i); + break; + } + } +} + +Controllable* +Controllable::by_id (const ID& id) +{ + Glib::Mutex::Lock lm (*registry_lock); + + for (Controllables::iterator i = registry.begin(); i != registry.end(); ++i) { + if ((*i)->id() == id) { + return (*i); + } + } + return 0; +} + + +Controllable* +Controllable::by_name (const std::string& str) +{ + Glib::Mutex::Lock lm (*registry_lock); + + for (Controllables::iterator i = registry.begin(); i != registry.end(); ++i) { + if ((*i)->_name == str) { + return (*i); + } + } + return 0; } XMLNode& |