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/shared/Builder.cpp | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 src/shared/Builder.cpp (limited to 'src/shared/Builder.cpp') diff --git a/src/shared/Builder.cpp b/src/shared/Builder.cpp new file mode 100644 index 00000000..1eb127a5 --- /dev/null +++ b/src/shared/Builder.cpp @@ -0,0 +1,98 @@ +/* This file is part of Ingen. + * Copyright (C) 2008 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 "Builder.hpp" +#include "common/interface/CommonInterface.hpp" +#include "common/interface/Patch.hpp" +#include "common/interface/Node.hpp" +#include "common/interface/Port.hpp" +#include "common/interface/Connection.hpp" +#include "common/interface/Plugin.hpp" +#include +using namespace std; + +namespace Ingen { +namespace Shared { + + +Builder::Builder(CommonInterface& interface) + : _interface(interface) +{ +} + + +void +Builder::build(const Raul::Path& prefix, SharedPtr object) +{ + SharedPtr patch = PtrCast(object); + if (patch) { + if (object->path() != "/") { + const std::string path_str = prefix.base() + object->path().substr(1); + //cout << "BUILDING PATCH " << path_str << endl; + _interface.new_patch(path_str, patch->internal_polyphony()); + } + + build_object(prefix, object); + for (Patch::Connections::const_iterator i = patch->connections().begin(); + i != patch->connections().end(); ++i) { + string base = prefix.base() + object->path().substr(1); + cout << "*********** BASE: " << base << endl; + _interface.connect(base + (*i)->src_port_path().substr(1), + base + (*i)->dst_port_path().substr(1)); + } + return; + } + + SharedPtr node = PtrCast(object); + if (node) { + Raul::Path path = prefix.base() + node->path().substr(1); + //cout << "BUILDING NODE " << path << endl; + _interface.new_node(path, node->plugin()->uri()); + build_object(prefix, object); + return; + } + + SharedPtr port = PtrCast(object); + if (port) { + Raul::Path path = prefix.base() + port->path().substr(1); + //cout << "BUILDING PORT " << path << endl; + _interface.new_port(path, port->index(), port->type().uri(), !port->is_input()); + build_object(prefix, object); + return; + } +} + + +void +Builder::build_object(const Raul::Path& prefix, SharedPtr object) +{ + for (GraphObject::Variables::const_iterator i = object->variables().begin(); + i != object->variables().end(); ++i) + _interface.set_variable(prefix.base() + object->path().substr(1), i->first, i->second); + + for (GraphObject::Properties::const_iterator i = object->properties().begin(); + i != object->properties().end(); ++i) { + if (object->path() == "/") + continue; + string path_str = prefix.base() + object->path().substr(1); + _interface.set_property(prefix.base() + object->path().substr(1), i->first, i->second); + } +} + + +} // namespace Shared +} // namespace Ingen -- cgit v1.2.1