From bd315305771e98eba1d81672a47ce4fe7bcc95cc Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 21 Apr 2007 07:18:40 +0000 Subject: Loading plugins via class-based menu heirarchy in patch context menu. git-svn-id: http://svn.drobilla.net/lad/ingen@468 a436a847-0d15-0410-975c-d299462d15a1 --- src/libs/client/Makefile.am | 1 + src/libs/client/PluginModel.cpp | 52 +++++++++++++++++++++++++++++++++++++++++ src/libs/client/PluginModel.h | 18 ++++++++------ src/libs/client/Store.cpp | 2 +- src/libs/client/Store.h | 12 ++++++---- 5 files changed, 72 insertions(+), 13 deletions(-) create mode 100644 src/libs/client/PluginModel.cpp (limited to 'src/libs') diff --git a/src/libs/client/Makefile.am b/src/libs/client/Makefile.am index 89dff982..b226c381 100644 --- a/src/libs/client/Makefile.am +++ b/src/libs/client/Makefile.am @@ -28,6 +28,7 @@ libingenclient_la_SOURCES = \ PatchModel.h \ PatchModel.cpp \ PluginModel.h \ + PluginModel.cpp \ Serializer.h \ Serializer.cpp \ Loader.h \ diff --git a/src/libs/client/PluginModel.cpp b/src/libs/client/PluginModel.cpp new file mode 100644 index 00000000..89dcab6d --- /dev/null +++ b/src/libs/client/PluginModel.cpp @@ -0,0 +1,52 @@ +/* This file is part of Ingen. + * Copyright (C) 2007 Dave Robillard + * + * Ingen is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include +#include "PluginModel.h" +#include "PatchModel.h" + + +namespace Ingen { +namespace Client { + +SLV2World PluginModel::_slv2_world = NULL; + + +string +PluginModel::default_node_name(SharedPtr parent) +{ + string default_name = Raul::Path::nameify(_name); + string name; + + char num_buf[3]; + for (uint i=0; i < 99; ++i) { + name = default_name; + if (i != 0) { + snprintf(num_buf, 3, "%d", i+1); + name += num_buf; + } + if (!parent->get_node(name)) + break; + } + + return name; +} + + +} // namespace Client +} // namespace Ingen diff --git a/src/libs/client/PluginModel.h b/src/libs/client/PluginModel.h index f1c83377..6614a3b6 100644 --- a/src/libs/client/PluginModel.h +++ b/src/libs/client/PluginModel.h @@ -22,6 +22,7 @@ #include #include #include "raul/Path.h" +#include "raul/SharedPtr.h" #ifdef HAVE_SLV2 #include #endif @@ -30,6 +31,8 @@ using std::string; using std::cerr; using std::endl; namespace Ingen { namespace Client { +class PatchModel; + /** Model for a plugin available for loading. * @@ -46,13 +49,12 @@ public: { set_type_from_uri(type_uri); #ifdef HAVE_SLV2 - static SLV2World world = NULL; static SLV2Plugins plugins = NULL; - if (!world) { - world = slv2_world_new(); - slv2_world_load_all(world); - plugins = slv2_world_get_all_plugins(world); + if (!_slv2_world) { + _slv2_world = slv2_world_new(); + slv2_world_load_all(_slv2_world); + plugins = slv2_world_get_all_plugins(_slv2_world); } _slv2_plugin = slv2_plugins_get_by_uri(plugins, uri.c_str()); @@ -101,10 +103,11 @@ public: } } - string default_node_name() { return Raul::Path::nameify(_name); } + string default_node_name(SharedPtr parent); #ifdef HAVE_SLV2 - SLV2Plugin slv2_plugin() { return _slv2_plugin; } + SLV2Plugin slv2_plugin() { return _slv2_plugin; } + static SLV2World slv2_world() { return _slv2_world; } #endif private: @@ -113,6 +116,7 @@ private: string _name; #ifdef HAVE_SLV2 + static SLV2World _slv2_world; SLV2Plugin _slv2_plugin; #endif }; diff --git a/src/libs/client/Store.cpp b/src/libs/client/Store.cpp index 462b1475..fa9707d1 100644 --- a/src/libs/client/Store.cpp +++ b/src/libs/client/Store.cpp @@ -223,7 +223,7 @@ Store::add_object(SharedPtr object) { // If we already have "this" object, merge the existing one into the new // one (with precedence to the new values). - ObjectMap::iterator existing = _objects.find(object->path()); + Objects::iterator existing = _objects.find(object->path()); if (existing != _objects.end()) { existing->second->set(object); } else { diff --git a/src/libs/client/Store.h b/src/libs/client/Store.h index 60bc88c7..2059f55f 100644 --- a/src/libs/client/Store.h +++ b/src/libs/client/Store.h @@ -59,8 +59,11 @@ public: size_t num_object() { return _objects.size(); } - const map >& plugins() const { return _plugins; } - const map >& objects() const { return _objects; } + typedef map > Plugins; + const Plugins& plugins() const { return _plugins; } + + typedef map > Objects; + const Objects& objects() const { return _objects; } sigc::signal > new_object_sig; private: @@ -103,10 +106,9 @@ private: SharedPtr _engine; SharedPtr _emitter; - typedef map > ObjectMap; - ObjectMap _objects; ///< Keyed by Ingen path - map > _plugins; ///< Keyed by URI + Objects _objects; ///< Map, keyed by Ingen path + Plugins _plugins; ///< Map, keyed by plugin URI /** Objects we've received, but depend on the existance of another unknown object. * Keyed by the path of the depended-on object (for tolerance of orderless comms) */ -- cgit v1.2.1