From 93850c202de8b073a1ce1dd8bd246d407bce4e2f Mon Sep 17 00:00:00 2001 From: David Robillard Date: Tue, 30 Sep 2008 16:50:21 +0000 Subject: Flatten ingen source directory heirarchy a bit. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@1551 a436a847-0d15-0410-975c-d299462d15a1 --- src/libs/client/NodeModel.cpp | 224 ------------------------------------------ 1 file changed, 224 deletions(-) delete mode 100644 src/libs/client/NodeModel.cpp (limited to 'src/libs/client/NodeModel.cpp') diff --git a/src/libs/client/NodeModel.cpp b/src/libs/client/NodeModel.cpp deleted file mode 100644 index ac0c8e68..00000000 --- a/src/libs/client/NodeModel.cpp +++ /dev/null @@ -1,224 +0,0 @@ -/* 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 CONFIG_H_PATH - -#include -#include -#include "interface/Port.hpp" -#include "NodeModel.hpp" -#include "PatchModel.hpp" - -namespace Ingen { -namespace Client { - - -NodeModel::NodeModel(SharedPtr plugin, const Path& path) - : ObjectModel(path) - , _plugin_uri(plugin->uri()) - , _plugin(plugin) - , _num_values(0) - , _min_values(0) - , _max_values(0) -{ -} - -NodeModel::NodeModel(const string& plugin_uri, const Path& path) - : ObjectModel(path) - , _plugin_uri(plugin_uri) - , _num_values(0) - , _min_values(0) - , _max_values(0) -{ -} - - -NodeModel::NodeModel(const NodeModel& copy) - : ObjectModel(copy) - , _plugin_uri(copy._plugin_uri) - , _num_values(copy._num_values) - , _min_values((float*)malloc(sizeof(float) * _num_values)) - , _max_values((float*)malloc(sizeof(float) * _num_values)) -{ - memcpy(_min_values, copy._min_values, sizeof(float) * _num_values); - memcpy(_max_values, copy._max_values, sizeof(float) * _num_values); -} - - -NodeModel::~NodeModel() -{ - clear(); -} - - -void -NodeModel::remove_port(SharedPtr port) -{ - // FIXME: slow - for (Ports::iterator i = _ports.begin(); i != _ports.end(); ++i) { - if ((*i) == port) { - _ports.erase(i); - break; - } - } - signal_removed_port.emit(port); -} - - -void -NodeModel::remove_port(const Path& port_path) -{ - // FIXME: slow - for (Ports::iterator i = _ports.begin(); i != _ports.end(); ++i) { - if ((*i)->path() == port_path) { - _ports.erase(i); - break; - } - } -} - - -void -NodeModel::clear() -{ - _ports.clear(); - assert(_ports.empty()); - delete[] _min_values; - delete[] _max_values; - _min_values = 0; - _max_values = 0; -} - - -void -NodeModel::add_child(SharedPtr c) -{ - assert(c->parent().get() == this); - - //ObjectModel::add_child(c); - - SharedPtr pm = PtrCast(c); - assert(pm); - add_port(pm); -} - - -bool -NodeModel::remove_child(SharedPtr c) -{ - assert(c->path().is_child_of(_path)); - assert(c->parent().get() == this); - - //bool ret = ObjectModel::remove_child(c); - - SharedPtr pm = PtrCast(c); - assert(pm); - remove_port(pm); - - //return ret; - return true; -} - - -void -NodeModel::add_port(SharedPtr pm) -{ - assert(pm); - assert(pm->path().is_child_of(_path)); - assert(pm->parent().get() == this); - - Ports::iterator existing = find(_ports.begin(), _ports.end(), pm); - - // Store should have handled this by merging the two - assert(existing == _ports.end()); - - _ports.push_back(pm); - signal_new_port.emit(pm); -} - - -SharedPtr -NodeModel::get_port(const string& port_name) const -{ - assert(port_name.find("/") == string::npos); - for (Ports::const_iterator i = _ports.begin(); i != _ports.end(); ++i) - if ((*i)->path().name() == port_name) - return (*i); - return SharedPtr(); -} - - -Shared::Port* -NodeModel::port(uint32_t index) const -{ - assert(index < num_ports()); - return dynamic_cast(_ports[index].get()); -} - - -void -NodeModel::port_value_range(SharedPtr port, float& min, float& max) -{ - assert(port->parent().get() == this); - -#ifdef HAVE_SLV2 - // Plugin value first - if (_plugin && _plugin->type() == PluginModel::LV2) { - - if (!_min_values) { - - Glib::Mutex::Lock lock(PluginModel::rdf_world()->mutex()); - - _num_values = slv2_plugin_get_num_ports(_plugin->slv2_plugin()); - _min_values = new float[_num_values]; - _max_values = new float[_num_values]; - slv2_plugin_get_port_ranges_float(_plugin->slv2_plugin(), - _min_values, _max_values, 0); - } - - if (!std::isnan(_min_values[port->index()])) - min = _min_values[port->index()]; - if (!std::isnan(_max_values[port->index()])) - max = _max_values[port->index()]; - } -#endif - - // Possibly overriden - const Atom& min_atom = port->get_variable("ingen:minimum"); - const Atom& max_atom = port->get_variable("ingen:maximum"); - if (min_atom.type() == Atom::FLOAT) - min = min_atom.get_float(); - if (max_atom.type() == Atom::FLOAT) - max = max_atom.get_float(); -} - - -void -NodeModel::set(SharedPtr model) -{ - SharedPtr node = PtrCast(model); - if (node) { - _plugin_uri = node->_plugin_uri; - _plugin = node->_plugin; - } - - ObjectModel::set(model); -} - - -} // namespace Client -} // namespace Ingen -- cgit v1.2.1