From 22bf43352ddfc48452d776f10ad4d12161255049 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 10 Sep 2006 20:37:52 +0000 Subject: Added missing files. git-svn-id: http://svn.drobilla.net/lad/ingen@127 a436a847-0d15-0410-975c-d299462d15a1 --- src/libs/client/ModelEngineInterface.cpp | 85 ++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 src/libs/client/ModelEngineInterface.cpp (limited to 'src/libs/client') diff --git a/src/libs/client/ModelEngineInterface.cpp b/src/libs/client/ModelEngineInterface.cpp new file mode 100644 index 00000000..ca92b1ac --- /dev/null +++ b/src/libs/client/ModelEngineInterface.cpp @@ -0,0 +1,85 @@ +/* This file is part of Ingen. Copyright (C) 2006 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 "ModelEngineInterface.h" +#include "PatchModel.h" +#include "PresetModel.h" + +namespace Ingen { +namespace Client { + + +/** Load a node. + */ +void +ModelEngineInterface::create_node_from_model(const NodeModel* nm) +{ + // Load by URI + if (nm->plugin()->uri().length() > 0) { + create_node(nm->path().c_str(), + nm->plugin()->type_string(), + nm->plugin()->uri().c_str(), + nm->polyphonic()); + + // Load by libname, label + } else { + //assert(nm->plugin()->lib_name().length() > 0); + assert(nm->plugin()->plug_label().length() > 0); + + create_node(nm->path(), + nm->plugin()->type_string(), + nm->plugin()->lib_name().c_str(), + nm->plugin()->plug_label().c_str(), + nm->polyphonic()); + } + + set_all_metadata(nm); +} + + +/** Create a patch. + */ +void +ModelEngineInterface::create_patch_from_model(const PatchModel* pm) +{ + create_patch(pm->path().c_str(), pm->poly()); + set_all_metadata(pm); +} + + +/** Set all pieces of metadata in a model. + */ +void +ModelEngineInterface::set_all_metadata(const ObjectModel* m) +{ + for (map::const_iterator i = m->metadata().begin(); i != m->metadata().end(); ++i) + set_metadata(m->path(), (*i).first, (*i).second.c_str()); +} + + +/** Set a preset by setting all relevant controls for a patch. + */ +void +ModelEngineInterface::set_preset(const Path& patch_path, const PresetModel* const pm) +{ + for (list::const_iterator i = pm->controls().begin(); i != pm->controls().end(); ++i) { + set_port_value_queued((*i).port_path(), (*i).value()); + } +} + + +} // namespace Client +} // namespace Ingen -- cgit v1.2.1