diff options
Diffstat (limited to 'src/client/PluginModel.cpp')
-rw-r--r-- | src/client/PluginModel.cpp | 80 |
1 files changed, 44 insertions, 36 deletions
diff --git a/src/client/PluginModel.cpp b/src/client/PluginModel.cpp index 4dddd147..f4dfccd2 100644 --- a/src/client/PluginModel.cpp +++ b/src/client/PluginModel.cpp @@ -14,25 +14,29 @@ along with Ingen. If not, see <http://www.gnu.org/licenses/>. */ -#include "ingen/client/PluginModel.hpp" - -#include "ingen/Atom.hpp" -#include "ingen/client/PluginUI.hpp" -#include "lv2/core/lv2.h" - -#include <boost/optional/optional.hpp> +#include <ingen/client/PluginModel.hpp> + +#include <ingen/Atom.hpp> +#include <ingen/Forge.hpp> +#include <ingen/Properties.hpp> +#include <ingen/Resource.hpp> +#include <ingen/URI.hpp> +#include <ingen/URIs.hpp> +#include <ingen/client/PluginUI.hpp> +#include <lilv/lilv.h> +#include <lv2/core/lv2.h> +#include <raul/Symbol.hpp> +#include <sigc++/signal.h> #include <cctype> #include <cstring> -#include <iosfwd> #include <memory> #include <string> #include <utility> using std::string; -namespace ingen { -namespace client { +namespace ingen::client { LilvWorld* PluginModel::_lilv_world = nullptr; const LilvPlugins* PluginModel::_lilv_plugins = nullptr; @@ -45,13 +49,12 @@ PluginModel::PluginModel(URIs& uris, const Properties& properties) : Resource(uris, uri) , _type(type) - , _fetched(false) { if (!_type.is_valid()) { if (uri.string().find("ingen-internals") != string::npos) { _type = uris.ingen_Internal.urid_atom(); } else { - _type = uris.lv2_Plugin.urid_atom(); // Assume LV2 and hope for the best... + _type = uris.lv2_Plugin.urid_atom(); // Assume LV2 and hope for the best... } } @@ -106,37 +109,43 @@ PluginModel::get_property(const URI& key) const size_t last_delim = last_uri_delim(str); while (last_delim != string::npos && !contains_alpha_after(str, last_delim)) { - str = str.substr(0, last_delim); + str.resize(last_delim); last_delim = last_uri_delim(str); } str = str.substr(last_delim + 1); - std::string symbol = raul::Symbol::symbolify(str); + const std::string symbol = raul::Symbol::symbolify(str); set_property(_uris.lv2_symbol, _uris.forge.alloc(symbol)); return get_property(key); } if (_lilv_plugin) { - boost::optional<const Atom&> ret; - LilvNode* lv2_pred = lilv_new_uri(_lilv_world, key.c_str()); - LilvNodes* values = lilv_plugin_get_value(_lilv_plugin, lv2_pred); + const Atom* ret = nullptr; + LilvNode* lv2_pred = lilv_new_uri(_lilv_world, key.c_str()); + LilvNodes* values = lilv_plugin_get_value(_lilv_plugin, lv2_pred); lilv_node_free(lv2_pred); - LILV_FOREACH(nodes, i, values) { + LILV_FOREACH (nodes, i, values) { const LilvNode* value = lilv_nodes_get(values, i); if (lilv_node_is_uri(value)) { - ret = set_property( + ret = &set_property( key, _uris.forge.make_urid(URI(lilv_node_as_uri(value)))); break; - } else if (lilv_node_is_string(value)) { - ret = set_property( + } + + if (lilv_node_is_string(value)) { + ret = &set_property( key, _uris.forge.alloc(lilv_node_as_string(value))); break; - } else if (lilv_node_is_float(value)) { - ret = set_property( + } + + if (lilv_node_is_float(value)) { + ret = &set_property( key, _uris.forge.make(lilv_node_as_float(value))); break; - } else if (lilv_node_is_int(value)) { - ret = set_property( + } + + if (lilv_node_is_int(value)) { + ret = &set_property( key, _uris.forge.make(lilv_node_as_int(value))); break; } @@ -181,9 +190,9 @@ PluginModel::default_block_symbol() const const Atom& name_atom = get_property(_uris.lv2_symbol); if (name_atom.is_valid() && name_atom.type() == _uris.forge.String) { return raul::Symbol::symbolify(name_atom.ptr<char>()); - } else { - return raul::Symbol("_"); } + + return raul::Symbol("_"); } string @@ -192,9 +201,9 @@ PluginModel::human_name() const const Atom& name_atom = get_property(_uris.doap_name); if (name_atom.type() == _uris.forge.String) { return name_atom.ptr<char>(); - } else { - return default_block_symbol().c_str(); } + + return default_block_symbol().c_str(); } string @@ -218,7 +227,7 @@ PluginModel::port_scale_points(const uint32_t index) const if (_lilv_plugin) { const LilvPort* port = lilv_plugin_get_port_by_index(_lilv_plugin, index); LilvScalePoints* sp = lilv_port_get_scale_points(_lilv_plugin, port); - LILV_FOREACH(scale_points, i, sp) { + LILV_FOREACH (scale_points, i, sp) { const LilvScalePoint* p = lilv_scale_points_get(sp, i); points.emplace( lilv_node_as_float(lilv_scale_point_get_value(p)), @@ -257,9 +266,9 @@ heading(const std::string& text, bool html, unsigned level) if (html) { const std::string tag = std::string("h") + std::to_string(level); return std::string("<") + tag + ">" + text + "</" + tag + ">\n"; - } else { - return text + ":\n\n"; } + + return text + ":\n\n"; } static std::string @@ -267,9 +276,9 @@ link(const std::string& addr, bool html) { if (html) { return std::string("<a href=\"") + addr + "\">" + addr + "</a>"; - } else { - return addr; } + + return addr; } std::string @@ -357,5 +366,4 @@ PluginModel::set_lilv_world(LilvWorld* world) _lilv_plugins = lilv_world_get_all_plugins(_lilv_world); } -} // namespace client -} // namespace ingen +} // namespace ingen::client |