diff options
author | David Robillard <d@drobilla.net> | 2012-03-15 23:52:45 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2012-03-15 23:52:45 +0000 |
commit | b617f75ff95d48ab3089976eb767e4f09abaa110 (patch) | |
tree | 971640580f926580dad54bb0a20e7838e135f5c6 /ingen | |
parent | 89e263ff78b51352f226c8b02ee65ecd8cbfefb8 (diff) | |
download | ingen-b617f75ff95d48ab3089976eb767e4f09abaa110.tar.gz ingen-b617f75ff95d48ab3089976eb767e4f09abaa110.tar.bz2 ingen-b617f75ff95d48ab3089976eb767e4f09abaa110.zip |
Remove weird "include" directory and use standard style ("ingen" directory in top level).
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4063 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'ingen')
37 files changed, 2943 insertions, 0 deletions
diff --git a/ingen/ClientInterface.hpp b/ingen/ClientInterface.hpp new file mode 100644 index 00000000..0bed231c --- /dev/null +++ b/ingen/ClientInterface.hpp @@ -0,0 +1,54 @@ +/* This file is part of Ingen. + * Copyright 2007-2011 David Robillard <http://drobilla.net> + * + * 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 + */ + +#ifndef INGEN_INTERFACE_CLIENTINTERFACE_HPP +#define INGEN_INTERFACE_CLIENTINTERFACE_HPP + +#include <stdint.h> + +#include <string> + +#include "raul/URI.hpp" + +#include "ingen/CommonInterface.hpp" +#include "ingen/Status.hpp" + +namespace Raul { class Path; } + +namespace Ingen { + +/** The (only) interface the engine uses to communicate with clients. + * Purely virtual (except for the destructor). + * + * \ingroup interface + */ +class ClientInterface : public CommonInterface +{ +public: + virtual ~ClientInterface() {} + + virtual void response(int32_t id, Status status) = 0; + + virtual void error(const std::string& msg) = 0; + + virtual void activity(const Raul::Path& path, + const Raul::Atom& value) = 0; +}; + +} // namespace Ingen + +#endif diff --git a/ingen/CommonInterface.hpp b/ingen/CommonInterface.hpp new file mode 100644 index 00000000..398fbd3b --- /dev/null +++ b/ingen/CommonInterface.hpp @@ -0,0 +1,75 @@ +/* This file is part of Ingen. + * Copyright 2008-2011 David Robillard <http://drobilla.net> + * + * 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 + */ + +#ifndef INGEN_INTERFACE_COMMONINTERFACE_HPP +#define INGEN_INTERFACE_COMMONINTERFACE_HPP + +#include "ingen/Resource.hpp" + +namespace Raul { class Atom; class Path; class URI; } + +namespace Ingen { + +/** Abstract interface common to both engine and clients. + * Purely virtual (except for the destructor). + * + * \ingroup interface + */ +class CommonInterface +{ +public: + virtual ~CommonInterface() {} + + virtual Raul::URI uri() const = 0; + + /** Begin an atomic bundle */ + virtual void bundle_begin() = 0; + + /** End (and send) an atomic bundle */ + virtual void bundle_end() = 0; + + virtual void put(const Raul::URI& uri, + const Resource::Properties& properties, + Resource::Graph ctx=Resource::DEFAULT) = 0; + + virtual void delta(const Raul::URI& uri, + const Resource::Properties& remove, + const Resource::Properties& add) = 0; + + virtual void move(const Raul::Path& old_path, + const Raul::Path& new_path) = 0; + + virtual void del(const Raul::URI& uri) = 0; + + virtual void connect(const Raul::Path& src_port_path, + const Raul::Path& dst_port_path) = 0; + + virtual void disconnect(const Raul::URI& src, + const Raul::URI& dst) = 0; + + virtual void disconnect_all(const Raul::Path& parent_patch_path, + const Raul::Path& path) = 0; + + virtual void set_property(const Raul::URI& subject, + const Raul::URI& predicate, + const Raul::Atom& value) = 0; +}; + +} // namespace Ingen + +#endif // INGEN_INTERFACE_COMMONINTERFACE_HPP + diff --git a/ingen/Connection.hpp b/ingen/Connection.hpp new file mode 100644 index 00000000..f300adb8 --- /dev/null +++ b/ingen/Connection.hpp @@ -0,0 +1,40 @@ +/* This file is part of Ingen. + * Copyright 2007-2011 David Robillard <http://drobilla.net> + * + * 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 + */ + +#ifndef INGEN_INTERFACE_CONNECTION_HPP +#define INGEN_INTERFACE_CONNECTION_HPP + +namespace Raul { class Path; } + +namespace Ingen { + +/** A connection between two ports. + * + * \ingroup interface + */ +class Connection +{ +public: + virtual ~Connection() {} + + virtual const Raul::Path& src_port_path() const = 0; + virtual const Raul::Path& dst_port_path() const = 0; +}; + +} // namespace Ingen + +#endif // INGEN_INTERFACE_CONNECTION_HPP diff --git a/ingen/EngineBase.hpp b/ingen/EngineBase.hpp new file mode 100644 index 00000000..80d1c789 --- /dev/null +++ b/ingen/EngineBase.hpp @@ -0,0 +1,67 @@ +/* This file is part of Ingen. + * Copyright 2007-2011 David Robillard <http://drobilla.net> + * + * 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 + */ + +#ifndef INGEN_ENGINE_BASE_HPP +#define INGEN_ENGINE_BASE_HPP + +namespace Ingen { + +/** + The engine which executes the process graph. + + @ingroup interface +*/ +class EngineBase +{ +public: + virtual ~EngineBase() {} + + /** + Activate the engine. + */ + virtual bool activate() = 0; + + /** + Deactivate the engine. + */ + virtual void deactivate() = 0; + + /** + Indicate that a quit is desired. + + This function simply sets a flag which affects the return value of + main_iteration, it does not actually force the engine to stop running or + block. The code driving the engine is responsible for stopping and + cleaning up when main_iteration returns false. + */ + virtual void quit() = 0; + + /** + Run a single iteration of the main context. + + The main context post-processes events and performs housekeeping duties + like collecting garbage. This should be called regularly, e.g. a few + times per second. The return value indicates whether execution should + continue; i.e. if false is returned, a quit has been requested and the + caller should cease calling main_iteration() and stop the engine. + */ + virtual bool main_iteration() = 0; +}; + +} // namespace Ingen + +#endif // INGEN_ENGINE_BASE_HPP diff --git a/ingen/GraphObject.hpp b/ingen/GraphObject.hpp new file mode 100644 index 00000000..393569e0 --- /dev/null +++ b/ingen/GraphObject.hpp @@ -0,0 +1,48 @@ +/* This file is part of Ingen. + * Copyright 2007-2011 David Robillard <http://drobilla.net> + * + * 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 + */ + +#ifndef INGEN_INTERFACE_GRAPHOBJECT_HPP +#define INGEN_INTERFACE_GRAPHOBJECT_HPP + +#include "raul/Deletable.hpp" + +#include "ingen/Resource.hpp" + +namespace Raul { class Atom; class Path; class Symbol; } + +namespace Ingen { + +/** An object on the audio graph - Patch, Node, Port, etc. + * + * Purely virtual (except for the destructor). + * + * \ingroup interface + */ +class GraphObject : public Raul::Deletable + , public virtual Resource +{ +public: + virtual void set_path(const Raul::Path& path) = 0; + + virtual const Raul::Path& path() const = 0; + virtual const Raul::Symbol& symbol() const = 0; + virtual GraphObject* graph_parent() const = 0; +}; + +} // namespace Ingen + +#endif // INGEN_INTERFACE_GRAPHOBJECT_HPP diff --git a/ingen/Node.hpp b/ingen/Node.hpp new file mode 100644 index 00000000..70864766 --- /dev/null +++ b/ingen/Node.hpp @@ -0,0 +1,49 @@ +/* This file is part of Ingen. + * Copyright 2007-2011 David Robillard <http://drobilla.net> + * + * 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 + */ + +#ifndef INGEN_INTERFACE_NODE_HPP +#define INGEN_INTERFACE_NODE_HPP + +#include <stdint.h> + +#include "ingen/GraphObject.hpp" + +namespace Ingen { + +class Port; +class Plugin; + +/** A Node (or "module") in a Patch (which is also a Node). + * + * A Node is a unit with input/output ports, a process() method, and some other + * things. + * + * Purely virtual (except for the destructor). + * + * \ingroup interface + */ +class Node : public virtual GraphObject +{ +public: + virtual uint32_t num_ports() const = 0; + virtual Port* port(uint32_t index) const = 0; + virtual const Plugin* plugin() const = 0; +}; + +} // namespace Ingen + +#endif // INGEN_INTERFACE_NODE_HPP diff --git a/ingen/Patch.hpp b/ingen/Patch.hpp new file mode 100644 index 00000000..83c80db4 --- /dev/null +++ b/ingen/Patch.hpp @@ -0,0 +1,50 @@ +/* This file is part of Ingen. + * Copyright 2007-2011 David Robillard <http://drobilla.net> + * + * 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 + */ + +#ifndef INGEN_INTERFACE_PATCH_HPP +#define INGEN_INTERFACE_PATCH_HPP + +#include <map> +#include <utility> + +#include "raul/SharedPtr.hpp" + +#include "ingen/Node.hpp" + +namespace Ingen { + +class Connection; + +/** A Path (graph of Nodes/Connections) + * + * \ingroup interface + */ +class Patch : virtual public Node +{ +public: + typedef std::pair<const Port*, const Port*> ConnectionsKey; + typedef std::map< ConnectionsKey, SharedPtr<Connection> > Connections; + + virtual const Connections& connections() const = 0; + + virtual bool enabled() const = 0; + virtual uint32_t internal_poly() const = 0; +}; + +} // namespace Ingen + +#endif // INGEN_INTERFACE_PATCH_HPP diff --git a/ingen/Plugin.hpp b/ingen/Plugin.hpp new file mode 100644 index 00000000..9b6d87b5 --- /dev/null +++ b/ingen/Plugin.hpp @@ -0,0 +1,61 @@ +/* This file is part of Ingen. + * Copyright 2007-2011 David Robillard <http://drobilla.net> + * + * 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 + */ + +#ifndef INGEN_INTERFACE_PLUGIN_HPP +#define INGEN_INTERFACE_PLUGIN_HPP + +#include "raul/URI.hpp" + +#include "ingen/Resource.hpp" + +namespace Ingen { + +class Plugin : virtual public Resource +{ +public: + enum Type { NIL, LV2, Internal, Patch }; + + virtual Type type() const = 0; + + static inline const Raul::URI& type_uri(Type type) { + static const Raul::URI uris[] = { + "http://drobilla.net/ns/ingen#nil", + "http://lv2plug.in/ns/lv2core#Plugin", + "http://drobilla.net/ns/ingen#Internal", + "http://drobilla.net/ns/ingen#Patch" + }; + + return uris[type]; + } + + inline const Raul::URI& type_uri() const { return type_uri(type()); } + + static inline Type type_from_uri(const Raul::URI& uri) { + if (uri == type_uri(LV2)) + return LV2; + else if (uri == type_uri(Internal)) + return Internal; + else if (uri == type_uri(Patch)) + return Patch; + else + return NIL; + } +}; + +} // namespace Ingen + +#endif // INGEN_INTERFACE_PLUGIN_HPP diff --git a/ingen/Port.hpp b/ingen/Port.hpp new file mode 100644 index 00000000..c703c6d8 --- /dev/null +++ b/ingen/Port.hpp @@ -0,0 +1,47 @@ +/* This file is part of Ingen. + * Copyright 2007-2011 David Robillard <http://drobilla.net> + * + * 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 + */ + +#ifndef INGEN_INTERFACE_PORT_HPP +#define INGEN_INTERFACE_PORT_HPP + +#include <stdint.h> + +#include "ingen/GraphObject.hpp" + +namespace Raul { class Atom; } + +namespace Ingen { + +/** A Port on a Node. + * + * Purely virtual (except for the destructor). + * + * \ingroup interface + */ +class Port : public virtual GraphObject +{ +public: + virtual bool supports(const Raul::URI& value_type) const = 0; + + virtual uint32_t index() const = 0; + virtual bool is_input() const = 0; + virtual const Raul::Atom& value() const = 0; +}; + +} // namespace Ingen + +#endif // INGEN_INTERFACE_PORT_HPP diff --git a/ingen/Resource.hpp b/ingen/Resource.hpp new file mode 100644 index 00000000..56b5157a --- /dev/null +++ b/ingen/Resource.hpp @@ -0,0 +1,115 @@ +/* This file is part of Ingen. + * Copyright 2008-2011 David Robillard <http://drobilla.net> + * + * 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 + */ + +#ifndef INGEN_INTERFACE_RESOURCE_HPP +#define INGEN_INTERFACE_RESOURCE_HPP + +#include <map> +#include <string> + +#include "raul/Atom.hpp" +#include "raul/URI.hpp" +#include "raul/log.hpp" + +#define NS_INGEN "http://drobilla.net/ns/ingen#" + +namespace Ingen { + +class Resource +{ +public: + enum Graph { + DEFAULT, + EXTERNAL, + INTERNAL + }; + + static Raul::URI graph_to_uri(Graph g) { + switch (g) { + default: + case DEFAULT: + return NS_INGEN "defaultContext"; + case EXTERNAL: + return NS_INGEN "externalContext"; + case INTERNAL: + return NS_INGEN "internalContext"; + } + } + + static Graph uri_to_graph(const char* uri) { + if (strncmp(uri, NS_INGEN, sizeof(NS_INGEN) - 1)) { + return DEFAULT; + } + + const char* suffix = uri + sizeof(NS_INGEN) - 1; + if (!strcmp(suffix, "defaultContext")) { + return DEFAULT; + } else if (!strcmp(suffix, "externalContext")) { + return EXTERNAL; + } else if (!strcmp(suffix, "internalContext")) { + return INTERNAL; + } + + Raul::error << "Unknown context URI " << uri << std::endl; + return DEFAULT; + } + + class Property : public Raul::Atom { + public: + Property(const Raul::Atom& atom, Graph ctx=DEFAULT) + : Raul::Atom(atom) + , _ctx(ctx) + {} + + Graph context() const { return _ctx; } + void set_context(Graph ctx) { _ctx = ctx; } + + private: + Graph _ctx; + }; + + virtual ~Resource() {} + + virtual const Raul::URI& uri() const = 0; + + typedef std::multimap<Raul::URI, Property> Properties; + + static void set_context(Properties& props, Graph ctx) { + for (Properties::iterator i = props.begin(); i != props.end(); ++i) { + i->second.set_context(ctx); + } + } + + virtual Properties properties(Resource::Graph ctx) const = 0; + + virtual const Properties& properties() const = 0; + virtual Properties& properties() = 0; + virtual const Raul::Atom& get_property(const Raul::URI& uri) const = 0; + virtual const Raul::Atom& set_property(const Raul::URI& uri, + const Raul::Atom& value, + Graph ctx=DEFAULT) = 0; + virtual void add_property(const Raul::URI& uri, + const Raul::Atom& value, + Graph ctx=DEFAULT) = 0; + virtual bool has_property(const Raul::URI& uri, + const Raul::Atom& value) const = 0; +}; + +} // namespace Ingen + +#endif // INGEN_INTERFACE_RESOURCE_HPP + diff --git a/ingen/ServerInterface.hpp b/ingen/ServerInterface.hpp new file mode 100644 index 00000000..25016416 --- /dev/null +++ b/ingen/ServerInterface.hpp @@ -0,0 +1,55 @@ +/* This file is part of Ingen. + * Copyright 2007-2011 David Robillard <http://drobilla.net> + * + * 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 + */ + +#ifndef INGEN_INTERFACE_SERVERINTERFACE_HPP +#define INGEN_INTERFACE_SERVERINTERFACE_HPP + +#include <stdint.h> + +#include "ingen/CommonInterface.hpp" + +namespace Ingen { + +class ClientInterface; + +/** The (only) interface clients use to communicate with the engine. + * Purely virtual (except for the destructor). + * + * \ingroup interface + */ +class ServerInterface : public CommonInterface +{ +public: + virtual ~ServerInterface() {} + + // Responses + virtual void respond_to(ClientInterface* client, int32_t id) = 0; + virtual void disable_responses() = 0; + + // Client registration + virtual void register_client(ClientInterface* client) = 0; + virtual void unregister_client(const Raul::URI& uri) = 0; + + // Requests + virtual void ping() = 0; + virtual void get(const Raul::URI& uri) = 0; +}; + +} // namespace Ingen + +#endif // INGEN_INTERFACE_SERVERINTERFACE_HPP + diff --git a/ingen/Status.hpp b/ingen/Status.hpp new file mode 100644 index 00000000..0e19435a --- /dev/null +++ b/ingen/Status.hpp @@ -0,0 +1,81 @@ +/* This file is part of Ingen. + * Copyright 2012 David Robillard <http://drobilla.net> + * + * 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 + */ + +#ifndef INGEN_STATUS_HPP +#define INGEN_STATUS_HPP + +namespace Ingen { + +enum Status { + SUCCESS, + FAILURE, + + BAD_INDEX, + BAD_OBJECT_TYPE, + BAD_VALUE_TYPE, + CLIENT_NOT_FOUND, + CREATION_FAILED, + DIRECTION_MISMATCH, + EXISTS, + INTERNAL_ERROR, + INVALID_PARENT_PATH, + INVALID_POLY, + NOT_FOUND, + NOT_MOVABLE, + NO_SPACE, + PARENT_DIFFERS, + PARENT_NOT_FOUND, + PLUGIN_NOT_FOUND, + PORT_NOT_FOUND, + TYPE_MISMATCH, + UNKNOWN_TYPE +}; + +static inline const char* +ingen_status_string(Status st) +{ + switch (st) { + case SUCCESS: return "Success"; + case FAILURE: return "Failure"; + + case BAD_INDEX: return "Invalid index"; + case BAD_OBJECT_TYPE: return "Invalid object type"; + case BAD_VALUE_TYPE: return "Invalid value type"; + case CLIENT_NOT_FOUND: return "Client not found"; + case CREATION_FAILED: return "Creation failed"; + case DIRECTION_MISMATCH: return "Direction mismatch"; + case EXISTS: return "Object exists"; + case INTERNAL_ERROR: return "Internal error" ; + case INVALID_PARENT_PATH: return "Invalid parent path"; + case INVALID_POLY: return "Invalid polyphony"; + case NOT_FOUND: return "Object not found"; + case NOT_MOVABLE: return "Object not movable"; + case NO_SPACE: return "Insufficient space"; + case PARENT_DIFFERS: return "Parent differs"; + case PARENT_NOT_FOUND: return "Parent not found"; + case PORT_NOT_FOUND: return "Port not found"; + case PLUGIN_NOT_FOUND: return "Plugin not found"; + case TYPE_MISMATCH: return "Type mismatch"; + case UNKNOWN_TYPE: return "Unknown type"; + } + + return "Unknown error"; +} + +} // namespace Ingen + +#endif // INGEN_STATUS_HPP diff --git a/ingen/client/ClientStore.hpp b/ingen/client/ClientStore.hpp new file mode 100644 index 00000000..b6042086 --- /dev/null +++ b/ingen/client/ClientStore.hpp @@ -0,0 +1,143 @@ +/* This file is part of Ingen. + * Copyright 2007-2011 David Robillard <http://drobilla.net> + * + * 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 + */ + +#ifndef INGEN_CLIENT_CLIENTSTORE_HPP +#define INGEN_CLIENT_CLIENTSTORE_HPP + +#include <cassert> +#include <list> +#include <string> + +#include "raul/Path.hpp" +#include "raul/PathTable.hpp" +#include "raul/SharedPtr.hpp" +#include "raul/TableImpl.hpp" + +#include "ingen/ServerInterface.hpp" +#include "ingen/client/signal.hpp" +#include "ingen/shared/LV2URIMap.hpp" +#include "ingen/shared/Store.hpp" + +namespace Raul { class Atom; } + +namespace Ingen { + +namespace Shared { class URIs; } + +class GraphObject; + +namespace Client { + +class NodeModel; +class ObjectModel; +class PatchModel; +class PluginModel; +class PortModel; +class SigClientInterface; + +/** Automatically manages models of objects in the engine. + * + * \ingroup IngenClient + */ +class ClientStore : public Shared::Store + , public CommonInterface + , public INGEN_TRACKABLE { +public: + ClientStore( + SharedPtr<Shared::URIs> uris, + SharedPtr<ServerInterface> engine=SharedPtr<ServerInterface>(), + SharedPtr<SigClientInterface> emitter=SharedPtr<SigClientInterface>()); + + Raul::URI uri() const { return "ingen:ClientStore"; } + + SharedPtr<const ObjectModel> object(const Raul::Path& path) const; + SharedPtr<const PluginModel> plugin(const Raul::URI& uri) const; + SharedPtr<const Resource> resource(const Raul::URI& uri) const; + + void clear(); + + typedef Raul::Table<Raul::URI, SharedPtr<PluginModel> > Plugins; + SharedPtr<const Plugins> plugins() const { return _plugins; } + SharedPtr<Plugins> plugins() { return _plugins; } + void set_plugins(SharedPtr<Plugins> p) { _plugins = p; } + + Shared::URIs& uris() { return *_uris.get(); } + + void put(const Raul::URI& uri, + const Resource::Properties& properties, + Resource::Graph ctx=Resource::DEFAULT); + + void delta(const Raul::URI& uri, + const Resource::Properties& remove, + const Resource::Properties& add); + + void move(const Raul::Path& old_path, + const Raul::Path& new_path); + + void set_property(const Raul::URI& subject_path, + const Raul::URI& predicate, + const Raul::Atom& value); + + void connect(const Raul::Path& src_port_path, + const Raul::Path& dst_port_path); + + void disconnect(const Raul::URI& src, + const Raul::URI& dst); + + void disconnect_all(const Raul::Path& parent_patch_path, + const Raul::Path& path); + + void del(const Raul::URI& uri); + + INGEN_SIGNAL(new_object, void, SharedPtr<ObjectModel>); + INGEN_SIGNAL(new_plugin, void, SharedPtr<PluginModel>); + +private: + void add(GraphObject* o) { throw; } + + SharedPtr<ObjectModel> _object(const Raul::Path& path); + SharedPtr<PluginModel> _plugin(const Raul::URI& uri); + SharedPtr<Resource> _resource(const Raul::URI& uri); + + void add_object(SharedPtr<ObjectModel> object); + SharedPtr<ObjectModel> remove_object(const Raul::Path& path); + + void add_plugin(SharedPtr<PluginModel> plugin); + + SharedPtr<PatchModel> connection_patch(const Raul::Path& src_port_path, + const Raul::Path& dst_port_path); + + void bundle_begin() {} + void bundle_end() {} + + // Slots for SigClientInterface signals + void activity(const Raul::Path& path, const Raul::Atom& value); + + bool attempt_connection(const Raul::Path& src_port_path, + const Raul::Path& dst_port_path); + + SharedPtr<Shared::URIs> _uris; + SharedPtr<ServerInterface> _engine; + SharedPtr<SigClientInterface> _emitter; + + SharedPtr<Plugins> _plugins; ///< Map, keyed by plugin URI +}; + +} // namespace Client +} // namespace Ingen + +#endif // INGEN_CLIENT_CLIENTSTORE_HPP diff --git a/ingen/client/ConnectionModel.hpp b/ingen/client/ConnectionModel.hpp new file mode 100644 index 00000000..1c719914 --- /dev/null +++ b/ingen/client/ConnectionModel.hpp @@ -0,0 +1,68 @@ +/* This file is part of Ingen. + * Copyright 2007-2011 David Robillard <http://drobilla.net> + * + * 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 + */ + +#ifndef INGEN_CLIENT_CONNECTIONMODEL_HPP +#define INGEN_CLIENT_CONNECTIONMODEL_HPP + +#include <cassert> + +#include "raul/Path.hpp" +#include "raul/SharedPtr.hpp" + +#include "ingen/Connection.hpp" +#include "ingen/client/PortModel.hpp" + +namespace Ingen { +namespace Client { + +class ClientStore; + +/** Class to represent a port->port connections in the engine. + * + * \ingroup IngenClient + */ +class ConnectionModel : public Connection +{ +public: + SharedPtr<PortModel> src_port() const { return _src_port; } + SharedPtr<PortModel> dst_port() const { return _dst_port; } + + const Raul::Path& src_port_path() const { return _src_port->path(); } + const Raul::Path& dst_port_path() const { return _dst_port->path(); } + +private: + friend class ClientStore; + + ConnectionModel(SharedPtr<PortModel> src, SharedPtr<PortModel> dst) + : _src_port(src) + , _dst_port(dst) + { + assert(_src_port); + assert(_dst_port); + assert(_src_port->parent()); + assert(_dst_port->parent()); + assert(_src_port->path() != _dst_port->path()); + } + + const SharedPtr<PortModel> _src_port; + const SharedPtr<PortModel> _dst_port; +}; + +} // namespace Client +} // namespace Ingen + +#endif // INGEN_CLIENT_CONNECTIONMODEL_HPP diff --git a/ingen/client/NodeModel.hpp b/ingen/client/NodeModel.hpp new file mode 100644 index 00000000..ef04be90 --- /dev/null +++ b/ingen/client/NodeModel.hpp @@ -0,0 +1,115 @@ +/* This file is part of Ingen. + * Copyright 2007-2011 David Robillard <http://drobilla.net> + * + * 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 + */ + +#ifndef INGEN_CLIENT_NODEMODEL_HPP +#define INGEN_CLIENT_NODEMODEL_HPP + +#include <cstdlib> +#include <string> +#include <vector> + +#include "raul/SharedPtr.hpp" + +#include "ingen/Node.hpp" +#include "ingen/Port.hpp" +#include "ingen/client/ObjectModel.hpp" +#include "ingen/client/PortModel.hpp" +#include "ingen/client/PluginModel.hpp" + +namespace Raul { class Path; } + +namespace Ingen { + +namespace Shared { class URIs; } + +namespace Client { + +class PluginModel; +class ClientStore; + +/** Node model class, used by the client to store engine's state. + * + * \ingroup IngenClient + */ +class NodeModel : public ObjectModel, + virtual public Ingen::Node +{ +public: + NodeModel(const NodeModel& copy); + virtual ~NodeModel(); + + typedef std::vector< SharedPtr<const PortModel> > Ports; + + SharedPtr<const PortModel> get_port(const Raul::Symbol& symbol) const; + + Port* port(uint32_t index) const; + + const Raul::URI& plugin_uri() const { return _plugin_uri; } + const Plugin* plugin() const { return _plugin.get(); } + Plugin* plugin() { return _plugin.get(); } + SharedPtr<PluginModel> plugin_model() const { return _plugin; } + uint32_t num_ports() const { return _ports.size(); } + const Ports& ports() const { return _ports; } + + void default_port_value_range(SharedPtr<const PortModel> port, + float& min, float& max, uint32_t srate=1) const; + + void port_value_range(SharedPtr<const PortModel> port, + float& min, float& max, uint32_t srate=1) const; + + std::string port_label(SharedPtr<const PortModel> port) const; + + // Signals + INGEN_SIGNAL(new_port, void, SharedPtr<const PortModel>); + INGEN_SIGNAL(removed_port, void, SharedPtr<const PortModel>); + +protected: + friend class ClientStore; + + NodeModel(Shared::URIs& uris, + const Raul::URI& plugin_uri, + const Raul::Path& path); + NodeModel(Shared::URIs& uris, + SharedPtr<PluginModel> plugin, + const Raul::Path& path); + NodeModel(const Raul::Path& path); + + void add_child(SharedPtr<ObjectModel> c); + bool remove_child(SharedPtr<ObjectModel> c); + void add_port(SharedPtr<PortModel> pm); + void remove_port(SharedPtr<PortModel> pm); + void remove_port(const Raul::Path& port_path); + void add_program(int bank, int program, const std::string& name); + void remove_program(int bank, int program); + void set(SharedPtr<ObjectModel> model); + + virtual void clear(); + + Ports _ports; ///< Vector of ports (not a Table to preserve order) + Raul::URI _plugin_uri; ///< Plugin URI (if PluginModel is unknown) + SharedPtr<PluginModel> _plugin; ///< The plugin this node is an instance of + +private: + mutable uint32_t _num_values; ///< Size of _min_values and _max_values + mutable float* _min_values; ///< Port min values (cached for LV2) + mutable float* _max_values; ///< Port max values (cached for LV2) +}; + +} // namespace Client +} // namespace Ingen + +#endif // INGEN_CLIENT_NODEMODEL_HPP diff --git a/ingen/client/ObjectModel.hpp b/ingen/client/ObjectModel.hpp new file mode 100644 index 00000000..b426ebdc --- /dev/null +++ b/ingen/client/ObjectModel.hpp @@ -0,0 +1,102 @@ +/* This file is part of Ingen. + * Copyright 2007-2011 David Robillard <http://drobilla.net> + * + * 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 + */ + +#ifndef INGEN_CLIENT_OBJECTMODEL_HPP +#define INGEN_CLIENT_OBJECTMODEL_HPP + +#include <algorithm> +#include <cassert> +#include <cstdlib> + +#include "raul/Path.hpp" +#include "raul/SharedPtr.hpp" +#include "raul/URI.hpp" + +#include "ingen/GraphObject.hpp" +#include "ingen/client/signal.hpp" +#include "ingen/shared/ResourceImpl.hpp" + +namespace Ingen { + +namespace Shared { class URIs; } + +namespace Client { + +class ClientStore; + +/** Base class for all GraphObject models (NodeModel, PatchModel, PortModel). + * + * There are no non-const public methods intentionally, models are not allowed + * to be manipulated directly by anything (but the Store) because of the + * asynchronous nature of engine control. To change something, use the + * controller (which the model probably shouldn't have a reference to but oh + * well, it reduces Collection Hell) and wait for the result (as a signal + * from this Model). + * + * \ingroup IngenClient + */ +class ObjectModel : virtual public GraphObject + , public Ingen::Shared::ResourceImpl +{ +public: + virtual ~ObjectModel(); + + bool is_a(const Raul::URI& type) const; + + const Raul::Atom& get_property(const Raul::URI& key) const; + + void on_property(const Raul::URI& uri, const Raul::Atom& value); + + const Raul::Path& path() const { return _path; } + const Raul::Symbol& symbol() const { return _symbol; } + SharedPtr<ObjectModel> parent() const { return _parent; } + bool polyphonic() const; + + GraphObject* graph_parent() const { return _parent.get(); } + + // Signals + INGEN_SIGNAL(new_child, void, SharedPtr<ObjectModel>); + INGEN_SIGNAL(removed_child, void, SharedPtr<ObjectModel>); + INGEN_SIGNAL(property, void, const Raul::URI&, const Raul::Atom&); + INGEN_SIGNAL(destroyed, void); + INGEN_SIGNAL(moved, void); + +protected: + friend class ClientStore; + + ObjectModel(Shared::URIs& uris, const Raul::Path& path); + ObjectModel(const ObjectModel& copy); + + virtual void set_path(const Raul::Path& p); + virtual void set_parent(SharedPtr<ObjectModel> p); + virtual void add_child(SharedPtr<ObjectModel> c) {} + virtual bool remove_child(SharedPtr<ObjectModel> c) { return true; } + + virtual void set(SharedPtr<ObjectModel> model); + + ResourceImpl _meta; + SharedPtr<ObjectModel> _parent; + +private: + Raul::Path _path; + Raul::Symbol _symbol; +}; + +} // namespace Client +} // namespace Ingen + +#endif // INGEN_CLIENT_OBJECTMODEL_HPP diff --git a/ingen/client/PatchModel.hpp b/ingen/client/PatchModel.hpp new file mode 100644 index 00000000..023a1dc2 --- /dev/null +++ b/ingen/client/PatchModel.hpp @@ -0,0 +1,96 @@ +/* This file is part of Ingen. + * Copyright 2007-2011 David Robillard <http://drobilla.net> + * + * 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 + */ + +#ifndef INGEN_CLIENT_PATCHMODEL_HPP +#define INGEN_CLIENT_PATCHMODEL_HPP + +#include "raul/SharedPtr.hpp" + +#include "ingen/Patch.hpp" +#include "ingen/client/NodeModel.hpp" + +namespace Ingen { + +class Port; + +namespace Client { + +class ClientStore; +class ConnectionModel; + +/** Client's model of a patch. + * + * \ingroup IngenClient + */ +class PatchModel : public NodeModel, public Ingen::Patch +{ +public: + /* WARNING: Copy constructor creates a shallow copy WRT connections */ + + const Connections& connections() const { return *_connections.get(); } + + SharedPtr<ConnectionModel> get_connection(const Ingen::Port* src_port, + const Ingen::Port* dst_port); + + bool enabled() const; + bool polyphonic() const; + uint32_t internal_poly() const; + + /** "editable" = arranging,connecting,adding,deleting,etc + * not editable (control mode) you can just change controllers (performing) + */ + bool get_editable() const { return _editable; } + void set_editable(bool e) const { + if (_editable != e) { + _editable = e; + const_cast<PatchModel*>(this)->signal_editable().emit(e); + } + } + + // Signals + INGEN_SIGNAL(new_node, void, SharedPtr<NodeModel>); + INGEN_SIGNAL(removed_node, void, SharedPtr<NodeModel>); + INGEN_SIGNAL(new_connection, void, SharedPtr<ConnectionModel>); + INGEN_SIGNAL(removed_connection, void, SharedPtr<ConnectionModel>); + INGEN_SIGNAL(editable, void, bool); + +private: + friend class ClientStore; + + PatchModel(Shared::URIs& uris, const Raul::Path& patch_path) + : NodeModel(uris, "http://drobilla.net/ns/ingen#Patch", patch_path) + , _connections(new Connections()) + , _editable(true) + { + } + + void clear(); + void add_child(SharedPtr<ObjectModel> c); + bool remove_child(SharedPtr<ObjectModel> c); + + void add_connection(SharedPtr<ConnectionModel> cm); + void remove_connection(const Ingen::Port* src_port, + const Ingen::Port* dst_port); + + SharedPtr<Connections> _connections; + mutable bool _editable; +}; + +} // namespace Client +} // namespace Ingen + +#endif // INGEN_CLIENT_PATCHMODEL_HPP diff --git a/ingen/client/PluginModel.hpp b/ingen/client/PluginModel.hpp new file mode 100644 index 00000000..a0887454 --- /dev/null +++ b/ingen/client/PluginModel.hpp @@ -0,0 +1,111 @@ +/* This file is part of Ingen. + * Copyright 2007-2011 David Robillard <http://drobilla.net> + * + * 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 + */ + +#ifndef INGEN_CLIENT_PLUGINMODEL_HPP +#define INGEN_CLIENT_PLUGINMODEL_HPP + +#include "lilv/lilv.h" +#include "raul/SharedPtr.hpp" +#include "raul/Symbol.hpp" +#include "sord/sordmm.hpp" + +#include "ingen/Plugin.hpp" +#include "ingen/ServerInterface.hpp" +#include "ingen/client/signal.hpp" +#include "ingen/shared/ResourceImpl.hpp" +#include "ingen/shared/World.hpp" + +namespace Ingen { + +namespace Shared { class URIs; } + +namespace Client { + +class PatchModel; +class NodeModel; +class PluginUI; + +/** Model for a plugin available for loading. + * + * \ingroup IngenClient + */ +class PluginModel : public Ingen::Plugin + , public Ingen::Shared::ResourceImpl +{ +public: + PluginModel(Shared::URIs& uris, + const Raul::URI& uri, + const Raul::URI& type_uri, + const Ingen::Resource::Properties& properties); + + Type type() const { return _type; } + + virtual const Raul::Atom& get_property(const Raul::URI& key) const; + + Raul::Symbol default_node_symbol() const; + std::string human_name() const; + std::string port_human_name(uint32_t index) const; + + static LilvWorld* lilv_world() { return _lilv_world; } + const LilvPlugin* lilv_plugin() const { return _lilv_plugin; } + + const LilvPort* lilv_port(uint32_t index) const; + + static void set_lilv_world(LilvWorld* world); + + bool has_ui() const; + + SharedPtr<PluginUI> ui(Ingen::Shared::World* world, + SharedPtr<const NodeModel> node) const; + + const std::string& icon_path() const; + static std::string get_lv2_icon_path(const LilvPlugin* plugin); + + std::string documentation(bool* html) const; + std::string port_documentation(uint32_t index) const; + + static void set_rdf_world(Sord::World& world) { + _rdf_world = &world; + } + + static Sord::World* rdf_world() { return _rdf_world; } + + // Signals + INGEN_SIGNAL(changed, void); + INGEN_SIGNAL(property, void, const Raul::URI&, const Raul::Atom&); + +protected: + friend class ClientStore; + void set(SharedPtr<PluginModel> p); + +private: + Type _type; + + static LilvWorld* _lilv_world; + static const LilvPlugins* _lilv_plugins; + + const LilvPlugin* _lilv_plugin; + mutable std::string _icon_path; + + static Sord::World* _rdf_world; +}; + +} // namespace Client +} // namespace Ingen + +#endif // INGEN_CLIENT_PLUGINMODEL_HPP + diff --git a/ingen/client/PluginUI.hpp b/ingen/client/PluginUI.hpp new file mode 100644 index 00000000..501db260 --- /dev/null +++ b/ingen/client/PluginUI.hpp @@ -0,0 +1,78 @@ +/* This file is part of Ingen. + * Copyright 2007-2011 David Robillard <http://drobilla.net> + * + * 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 + */ + +#ifndef INGEN_CLIENT_PLUGINUI_HPP +#define INGEN_CLIENT_PLUGINUI_HPP + +#include "raul/SharedPtr.hpp" + +#include "lilv/lilv.h" + +#include "suil/suil.h" + +#include "ingen/shared/LV2Features.hpp" + +namespace Ingen { + +class ServerInterface; + +namespace Shared { class World; } + +namespace Client { + +class NodeModel; + +/** Model for a plugin available for loading. + * + * \ingroup IngenClient + */ +class PluginUI { +public: + ~PluginUI(); + + static SharedPtr<PluginUI> create(Ingen::Shared::World* world, + SharedPtr<const NodeModel> node, + const LilvPlugin* plugin); + + SuilWidget get_widget(); + + void port_event(uint32_t port_index, + uint32_t buffer_size, + uint32_t format, + const void* buffer); + + Ingen::Shared::World* world() const { return _world; } + SharedPtr<const NodeModel> node() const { return _node; } + +private: + PluginUI(Ingen::Shared::World* world, + SharedPtr<const NodeModel> node); + + Ingen::Shared::World* _world; + SharedPtr<const NodeModel> _node; + SuilInstance* _instance; + + static SuilHost* ui_host; + + SharedPtr<Shared::LV2Features::FeatureArray> _features; +}; + +} // namespace Client +} // namespace Ingen + +#endif // INGEN_CLIENT_PLUGINUI_HPP + diff --git a/ingen/client/PortModel.hpp b/ingen/client/PortModel.hpp new file mode 100644 index 00000000..35e3c4ea --- /dev/null +++ b/ingen/client/PortModel.hpp @@ -0,0 +1,117 @@ +/* This file is part of Ingen. + * Copyright 2007-2011 David Robillard <http://drobilla.net> + * + * 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 + */ + +#ifndef INGEN_CLIENT_PORTMODEL_HPP +#define INGEN_CLIENT_PORTMODEL_HPP + +#include <cstdlib> +#include <string> + +#include "raul/SharedPtr.hpp" +#include "raul/log.hpp" + +#include "ingen/Port.hpp" +#include "ingen/client/ObjectModel.hpp" + +namespace Raul { class Path; } + +namespace Ingen { +namespace Client { + +/** Model of a port. + * + * \ingroup IngenClient + */ +class PortModel : public ObjectModel, public Ingen::Port +{ +public: + enum Direction { INPUT, OUTPUT }; + + bool supports(const Raul::URI& value_type) const; + + inline uint32_t index() const { return _index; } + inline const Raul::Atom& value() const { return _current_val; } + inline bool connected() const { return (_connections > 0); } + inline bool is_input() const { return (_direction == INPUT); } + inline bool is_output() const { return (_direction == OUTPUT); } + + bool port_property(const Raul::URI& uri) const; + + bool is_logarithmic() const { return port_property("http://drobilla.net/ns/ingen#logarithmic"); } + bool is_integer() const { return port_property("http://lv2plug.in/ns/lv2core#integer"); } + bool is_toggle() const { return port_property("http://lv2plug.in/ns/lv2core#toggled"); } + bool is_numeric() const { + return ObjectModel::is_a("http://lv2plug.in/ns/lv2core#ControlPort") + || ObjectModel::is_a("http://lv2plug.in/ns/ext/cv-port#CVPort"); + } + + bool has_context(const Raul::URI& context) const; + + inline bool operator==(const PortModel& pm) const { return (path() == pm.path()); } + + void on_property(const Raul::URI& uri, const Raul::Atom& value); + + inline void value(const Raul::Atom& val) { + if (val != _current_val) { + _current_val = val; + _signal_value_changed.emit(val); + } + } + + inline void value(uint32_t voice, const Raul::Atom& val) { + // FIXME: implement properly + _signal_voice_changed.emit(voice, val); + } + + // Signals + INGEN_SIGNAL(value_changed, void, const Raul::Atom&); + INGEN_SIGNAL(voice_changed, void, uint32_t, const Raul::Atom&); + INGEN_SIGNAL(activity, void, const Raul::Atom&); + INGEN_SIGNAL(connection, void, SharedPtr<PortModel>); + INGEN_SIGNAL(disconnection, void, SharedPtr<PortModel>); + +private: + friend class ClientStore; + + PortModel(Shared::URIs& uris, + const Raul::Path& path, + uint32_t index, + Direction dir) + : ObjectModel(uris, path) + , _index(index) + , _direction(dir) + , _connections(0) + {} + + void add_child(SharedPtr<ObjectModel> c) { throw; } + bool remove_child(SharedPtr<ObjectModel> c) { throw; } + + void connected_to(SharedPtr<PortModel> p) { ++_connections; _signal_connection.emit(p); } + void disconnected_from(SharedPtr<PortModel> p) { --_connections; _signal_disconnection.emit(p); } + + void set(SharedPtr<ObjectModel> model); + + uint32_t _index; + Direction _direction; + Raul::Atom _current_val; + size_t _connections; +}; + +} // namespace Client +} // namespace Ingen + +#endif // INGEN_CLIENT_PORTMODEL_HPP diff --git a/ingen/client/SigClientInterface.hpp b/ingen/client/SigClientInterface.hpp new file mode 100644 index 00000000..559d1b15 --- /dev/null +++ b/ingen/client/SigClientInterface.hpp @@ -0,0 +1,121 @@ +/* This file is part of Ingen. + * Copyright 2007-2011 David Robillard <http://drobilla.net> + * + * 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 + */ + +#ifndef INGEN_CLIENT_SIGCLIENTINTERFACE_HPP +#define INGEN_CLIENT_SIGCLIENTINTERFACE_HPP + +#include <stdint.h> + +#include "raul/Path.hpp" + +#include "ingen/ClientInterface.hpp" +#include "ingen/client/signal.hpp" + +namespace Ingen { +namespace Client { + +/** A LibSigC++ signal emitting interface for clients to use. + * + * This simply emits a signal for every event that comes from the engine. + * For a higher level model based view of the engine, use ClientStore. + * + * The signals here match the calls to ClientInterface exactly. See the + * documentation for ClientInterface for meanings of signal parameters. + */ +class SigClientInterface : public Ingen::ClientInterface, + public INGEN_TRACKABLE +{ +public: + SigClientInterface() {} + + Raul::URI uri() const { return "http://drobilla.net/ns/ingen#internal"; } + + INGEN_SIGNAL(response, void, int32_t, Status) + INGEN_SIGNAL(bundle_begin, void) + INGEN_SIGNAL(bundle_end, void) + INGEN_SIGNAL(error, void, std::string) + INGEN_SIGNAL(new_patch, void, Raul::Path, uint32_t) + INGEN_SIGNAL(new_port, void, Raul::Path, Raul::URI, uint32_t, bool) + INGEN_SIGNAL(put, void, Raul::URI, Resource::Properties, Resource::Graph) + INGEN_SIGNAL(delta, void, Raul::URI, Resource::Properties, Resource::Properties) + INGEN_SIGNAL(object_moved, void, Raul::Path, Raul::Path) + INGEN_SIGNAL(object_deleted, void, Raul::URI) + INGEN_SIGNAL(connection, void, Raul::Path, Raul::Path) + INGEN_SIGNAL(disconnection, void, Raul::URI, Raul::URI) + INGEN_SIGNAL(disconnect_all, void, Raul::Path, Raul::Path) + INGEN_SIGNAL(variable_change, void, Raul::URI, Raul::URI, Raul::Atom) + INGEN_SIGNAL(property_change, void, Raul::URI, Raul::URI, Raul::Atom) + INGEN_SIGNAL(port_value, void, Raul::Path, Raul::Atom) + INGEN_SIGNAL(activity, void, Raul::Path, Raul::Atom) + + /** Fire pending signals. Only does anything on derived classes (that may queue) */ + virtual bool emit_signals() { return false; } + +protected: + + // ClientInterface hooks that fire the above signals + +#define EMIT(name, ...) { _signal_ ## name (__VA_ARGS__); } + + void bundle_begin() + { EMIT(bundle_begin); } + + void bundle_end() + { EMIT(bundle_end); } + + void response(int32_t id, Status status) + { EMIT(response, id, status); } + + void error(const std::string& msg) + { EMIT(error, msg); } + + void put(const Raul::URI& uri, + const Resource::Properties& properties, + Resource::Graph ctx=Resource::DEFAULT) + { EMIT(put, uri, properties, ctx); } + + void delta(const Raul::URI& uri, + const Resource::Properties& remove, + const Resource::Properties& add) + { EMIT(delta, uri, remove, add); } + + void connect(const Raul::Path& src_port_path, const Raul::Path& dst_port_path) + { EMIT(connection, src_port_path, dst_port_path); } + + void del(const Raul::URI& uri) + { EMIT(object_deleted, uri); } + + void move(const Raul::Path& old_path, const Raul::Path& new_path) + { EMIT(object_moved, old_path, new_path); } + + void disconnect(const Raul::URI& src, const Raul::URI& dst) + { EMIT(disconnection, src, dst); } + + void disconnect_all(const Raul::Path& parent_patch_path, const Raul::Path& path) + { EMIT(disconnect_all, parent_patch_path, path); } + + void set_property(const Raul::URI& subject, const Raul::URI& key, const Raul::Atom& value) + { EMIT(property_change, subject, key, value); } + + void activity(const Raul::Path& port_path, const Raul::Atom& value) + { EMIT(activity, port_path, value); } +}; + +} // namespace Client +} // namespace Ingen + +#endif diff --git a/ingen/client/ThreadedSigClientInterface.hpp b/ingen/client/ThreadedSigClientInterface.hpp new file mode 100644 index 00000000..6ded560e --- /dev/null +++ b/ingen/client/ThreadedSigClientInterface.hpp @@ -0,0 +1,151 @@ +/* This file is part of Ingen. + * Copyright 2007-2011 David Robillard <http://drobilla.net> + * + * 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 + */ + +#ifndef INGEN_CLIENT_THREADEDSIGCLIENTINTERFACE_HPP +#define INGEN_CLIENT_THREADEDSIGCLIENTINTERFACE_HPP + +#include <stdint.h> + +#include <string> + +#undef nil +#include <sigc++/sigc++.h> +#include <glibmm/thread.h> + +#include "raul/Atom.hpp" +#include "raul/SRSWQueue.hpp" + +#include "ingen/ClientInterface.hpp" +#include "ingen/client/SigClientInterface.hpp" + +/** Returns nothing and takes no parameters (because they have all been bound) */ +typedef sigc::slot<void> Closure; + +namespace Ingen { + +class ServerInterface; + +namespace Client { + +/** A LibSigC++ signal emitting interface for clients to use. + * + * This emits signals (possibly) in a different thread than the ClientInterface + * functions are called. It must be explicitly driven with the emit_signals() + * function, which fires all enqueued signals up until the present. You can + * use this in a GTK idle callback for receiving thread safe engine signals. + */ +class ThreadedSigClientInterface : public SigClientInterface +{ +public: + ThreadedSigClientInterface(uint32_t queue_size) + : _sigs(queue_size) + , response_slot(_signal_response.make_slot()) + , error_slot(_signal_error.make_slot()) + , new_port_slot(_signal_new_port.make_slot()) + , put_slot(_signal_put.make_slot()) + , connection_slot(_signal_connection.make_slot()) + , object_deleted_slot(_signal_object_deleted.make_slot()) + , object_moved_slot(_signal_object_moved.make_slot()) + , disconnection_slot(_signal_disconnection.make_slot()) + , disconnect_all_slot(_signal_disconnect_all.make_slot()) + , variable_change_slot(_signal_variable_change.make_slot()) + , property_change_slot(_signal_property_change.make_slot()) + , port_value_slot(_signal_port_value.make_slot()) + , activity_slot(_signal_activity.make_slot()) + {} + + virtual Raul::URI uri() const { return "http://drobilla.net/ns/ingen#internal"; } + + void bundle_begin() + { push_sig(bundle_begin_slot); } + + void bundle_end() + { push_sig(bundle_end_slot); } + + void response(int32_t id, Status status) + { push_sig(sigc::bind(response_slot, id, status)); } + + void error(const std::string& msg) + { push_sig(sigc::bind(error_slot, msg)); } + + void put(const Raul::URI& path, + const Resource::Properties& properties, + Resource::Graph ctx=Resource::DEFAULT) + { push_sig(sigc::bind(put_slot, path, properties, ctx)); } + + void delta(const Raul::URI& path, + const Resource::Properties& remove, + const Resource::Properties& add) + { push_sig(sigc::bind(delta_slot, path, remove, add)); } + + void connect(const Raul::Path& src_port_path, const Raul::Path& dst_port_path) + { push_sig(sigc::bind(connection_slot, src_port_path, dst_port_path)); } + + void del(const Raul::URI& uri) + { push_sig(sigc::bind(object_deleted_slot, uri)); } + + void move(const Raul::Path& old_path, const Raul::Path& new_path) + { push_sig(sigc::bind(object_moved_slot, old_path, new_path)); } + + void disconnect(const Raul::URI& src, const Raul::URI& dst) + { push_sig(sigc::bind(disconnection_slot, src, dst)); } + + void disconnect_all(const Raul::Path& parent_patch_path, const Raul::Path& path) + { push_sig(sigc::bind(disconnect_all_slot, parent_patch_path, path)); } + + void set_property(const Raul::URI& subject, const Raul::URI& key, const Raul::Atom& value) + { push_sig(sigc::bind(property_change_slot, subject, key, value)); } + + void activity(const Raul::Path& port_path, const Raul::Atom& value) + { push_sig(sigc::bind(activity_slot, port_path, value)); } + + /** Process all queued events - Called from GTK thread to emit signals. */ + bool emit_signals(); + +private: + void push_sig(Closure ev); + + Glib::Mutex _mutex; + Glib::Cond _cond; + + Raul::SRSWQueue<Closure> _sigs; + + sigc::slot<void> bundle_begin_slot; + sigc::slot<void> bundle_end_slot; + sigc::slot<void, int32_t, Status> response_slot; + sigc::slot<void, std::string> error_slot; + sigc::slot<void, Raul::URI, Raul::URI, Raul::Symbol> new_plugin_slot; + sigc::slot<void, Raul::Path, Raul::URI, uint32_t, bool> new_port_slot; + sigc::slot<void, Raul::URI, Resource::Properties, + Resource::Graph> put_slot; + sigc::slot<void, Raul::URI, Resource::Properties, + Resource::Properties> delta_slot; + sigc::slot<void, Raul::Path, Raul::Path> connection_slot; + sigc::slot<void, Raul::URI> object_deleted_slot; + sigc::slot<void, Raul::Path, Raul::Path> object_moved_slot; + sigc::slot<void, Raul::URI, Raul::URI> disconnection_slot; + sigc::slot<void, Raul::Path, Raul::Path> disconnect_all_slot; + sigc::slot<void, Raul::URI, Raul::URI, Raul::Atom> variable_change_slot; + sigc::slot<void, Raul::URI, Raul::URI, Raul::Atom> property_change_slot; + sigc::slot<void, Raul::Path, Raul::Atom> port_value_slot; + sigc::slot<void, Raul::Path, Raul::Atom> activity_slot; +}; + +} // namespace Client +} // namespace Ingen + +#endif diff --git a/ingen/client/signal.hpp b/ingen/client/signal.hpp new file mode 100644 index 00000000..f40c6a57 --- /dev/null +++ b/ingen/client/signal.hpp @@ -0,0 +1,32 @@ +/* This file is part of Ingen. + * Copyright 2007-2011 David Robillard <http://drobilla.net> + * + * 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 + */ + +#ifndef INGEN_CLIENT_SIGNAL_HPP +#define INGEN_CLIENT_SIGNAL_HPP + +#include <sigc++/sigc++.h> + +#define INGEN_SIGNAL(name, ...) \ +protected: \ +sigc::signal<__VA_ARGS__> _signal_##name; \ +public: \ +sigc::signal<__VA_ARGS__> signal_##name() const { return _signal_##name; } \ +sigc::signal<__VA_ARGS__>& signal_##name() { return _signal_##name; } + +#define INGEN_TRACKABLE sigc::trackable + +#endif // INGEN_CLIENT_SIGNAL_HPP diff --git a/ingen/serialisation/Parser.hpp b/ingen/serialisation/Parser.hpp new file mode 100644 index 00000000..492af2ad --- /dev/null +++ b/ingen/serialisation/Parser.hpp @@ -0,0 +1,75 @@ +/* This file is part of Ingen. + * Copyright 2007-2011 David Robillard <http://drobilla.net> + * + * 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 + */ + +#ifndef INGEN_SERIALISATION_PARSER_HPP +#define INGEN_SERIALISATION_PARSER_HPP + +#include <string> +#include <list> + +#include <boost/optional.hpp> +#include <glibmm/ustring.h> + +#include "raul/Path.hpp" + +#include "ingen/GraphObject.hpp" + +namespace Ingen { + +class CommonInterface; + +namespace Shared { class World; } + +namespace Serialisation { + +/** Parse Ingen objects from RDF. + * + * \ingroup IngenSerialisation + */ +class Parser { +public: + Parser(Shared::World& world); + + virtual ~Parser() {} + + typedef GraphObject::Properties Properties; + + virtual bool parse_file( + Shared::World* world, + CommonInterface* target, + Glib::ustring path, + boost::optional<Raul::Path> parent = boost::optional<Raul::Path>(), + boost::optional<Raul::Symbol> symbol = boost::optional<Raul::Symbol>(), + boost::optional<Properties> data = boost::optional<Properties>()); + + virtual bool parse_string( + Shared::World* world, + CommonInterface* target, + const Glib::ustring& str, + const Glib::ustring& base_uri, + boost::optional<Raul::Path> parent = boost::optional<Raul::Path>(), + boost::optional<Raul::Symbol> symbol = boost::optional<Raul::Symbol>(), + boost::optional<Properties> data = boost::optional<Properties>()); + +private: + Shared::World& _world; +}; + +} // namespace Serialisation +} // namespace Ingen + +#endif // INGEN_SERIALISATION_PARSER_HPP diff --git a/ingen/serialisation/Serialiser.hpp b/ingen/serialisation/Serialiser.hpp new file mode 100644 index 00000000..8d5805e1 --- /dev/null +++ b/ingen/serialisation/Serialiser.hpp @@ -0,0 +1,84 @@ +/* This file is part of Ingen. + * Copyright 2007-2011 David Robillard <http://drobilla.net> + * + * 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 + */ + +#ifndef INGEN_SERIALISATION_SERIALISER_HPP +#define INGEN_SERIALISATION_SERIALISER_HPP + +#include <stdexcept> +#include <string> + +#include "raul/Path.hpp" +#include "raul/SharedPtr.hpp" + +#include "sord/sordmm.hpp" + +#include "ingen/GraphObject.hpp" + +namespace Ingen { + +class Plugin; +class GraphObject; +class Patch; +class Node; +class Port; +class Connection; + +namespace Shared { class World; class Store; } + +namespace Serialisation { + +/** Serialises Ingen objects (patches, nodes, etc) to RDF. + * + * \ingroup IngenSerialisation + */ +class Serialiser +{ +public: + Serialiser(Shared::World& world); + virtual ~Serialiser(); + + typedef GraphObject::Properties Properties; + + virtual void to_file(SharedPtr<const GraphObject> object, + const std::string& filename); + + virtual void write_bundle(SharedPtr<const Patch> patch, + const std::string& path); + + virtual std::string to_string(SharedPtr<const GraphObject> object, + const std::string& base_uri, + const Properties& extra_rdf); + + virtual void start_to_string(const Raul::Path& root, + const std::string& base_uri); + + virtual void serialise(SharedPtr<const GraphObject> object) throw (std::logic_error); + + virtual void serialise_connection(const Sord::Node& parent, + SharedPtr<const Connection> c) throw (std::logic_error); + + virtual std::string finish(); + +private: + struct Impl; + Impl* me; +}; + +} // namespace Serialisation +} // namespace Ingen + +#endif // INGEN_SERIALISATION_SERIALISER_HPP diff --git a/ingen/shared/Builder.hpp b/ingen/shared/Builder.hpp new file mode 100644 index 00000000..245b3013 --- /dev/null +++ b/ingen/shared/Builder.hpp @@ -0,0 +1,57 @@ +/* This file is part of Ingen. + * Copyright 2008-2011 David Robillard <http://drobilla.net> + * + * 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 + */ + +#ifndef INGEN_SHARED_BUILDER_HPP +#define INGEN_SHARED_BUILDER_HPP + +#include "raul/SharedPtr.hpp" + +namespace Ingen { + +class CommonInterface; +class GraphObject; + +namespace Shared { + +class URIs; + +/** Wrapper for CommonInterface to create existing objects/models. + * + * \ingroup interface + */ +class Builder +{ +public: + Builder(SharedPtr<Shared::URIs> uris, CommonInterface& interface); + virtual ~Builder() {} + + void build(SharedPtr<const GraphObject> object); + void connect(SharedPtr<const GraphObject> object); + +private: + void build_object(SharedPtr<const GraphObject> object); + + SharedPtr<Shared::URIs> _uris; + CommonInterface& _interface; +}; + +} // namespace Shared +} // namespace Ingen + +#endif // INGEN_SHARED_BUILDER_HPP + + diff --git a/ingen/shared/ClashAvoider.hpp b/ingen/shared/ClashAvoider.hpp new file mode 100644 index 00000000..4f5d8ec1 --- /dev/null +++ b/ingen/shared/ClashAvoider.hpp @@ -0,0 +1,100 @@ +/* This file is part of Ingen. + * Copyright 2008-2011 David Robillard <http://drobilla.net> + * + * 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 + */ + +#ifndef INGEN_SHARED_CLASHAVOIDER_HPP +#define INGEN_SHARED_CLASHAVOIDER_HPP + +#include <inttypes.h> + +#include <map> + +#include "ingen/CommonInterface.hpp" + +namespace Raul { class Atom; class Path; } + +namespace Ingen { +namespace Shared { + +class Store; + +/** A wrapper for a CommonInterface that creates objects but possibly maps + * symbol names to avoid clashes with the existing objects in a store. + */ +class ClashAvoider : public CommonInterface +{ +public: + ClashAvoider(Store& store, CommonInterface& target, Store* also_avoid=NULL) + : _store(store), _target(target), _also_avoid(also_avoid) {} + + Raul::URI uri() const { return "ingen:ClientStore"; } + + void set_target(CommonInterface& target) { _target = target; } + + // Bundles + void bundle_begin() { _target.bundle_begin(); } + void bundle_end() { _target.bundle_end(); } + + // Object commands + + virtual void put(const Raul::URI& path, + const Resource::Properties& properties, + Resource::Graph ctx=Resource::DEFAULT); + + virtual void delta(const Raul::URI& path, + const Resource::Properties& remove, + const Resource::Properties& add); + + virtual void move(const Raul::Path& old_path, + const Raul::Path& new_path); + + virtual void connect(const Raul::Path& src_port_path, + const Raul::Path& dst_port_path); + + virtual void disconnect(const Raul::URI& src, + const Raul::URI& dst); + + virtual void disconnect_all(const Raul::Path& parent_patch_path, + const Raul::Path& path); + + virtual void set_property(const Raul::URI& subject_path, + const Raul::URI& predicate, + const Raul::Atom& value); + + virtual void del(const Raul::URI& uri); + +private: + const Raul::URI map_uri(const Raul::URI& in); + const Raul::Path map_path(const Raul::Path& in); + + Store& _store; + CommonInterface& _target; + + Store* _also_avoid; + bool exists(const Raul::Path& path) const; + + typedef std::map<Raul::Path, unsigned> Offsets; + Offsets _offsets; + + typedef std::map<Raul::Path, Raul::Path> SymbolMap; + SymbolMap _symbol_map; +}; + +} // namespace Shared +} // namespace Ingen + +#endif // INGEN_SHARED_CLASHAVOIDER_HPP + diff --git a/ingen/shared/Configuration.hpp b/ingen/shared/Configuration.hpp new file mode 100644 index 00000000..21bc5737 --- /dev/null +++ b/ingen/shared/Configuration.hpp @@ -0,0 +1,35 @@ +/* This file is part of Ingen. + * Copyright 2010-2011 David Robillard <http://drobilla.net> + * + * 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 + */ + +#ifndef INGEN_SHARED_CONFIGURATION_HPP +#define INGEN_SHARED_CONFIGURATION_HPP + +#include "raul/Configuration.hpp" + +namespace Ingen { +namespace Shared { + +class Configuration : public Raul::Configuration { +public: + Configuration(Raul::Forge* forge); +}; + +} // namespace Shared +} // namespace Ingen + +#endif // INGEN_SHARED_CONFIGURATION_HPP + diff --git a/ingen/shared/LV2Atom.hpp b/ingen/shared/LV2Atom.hpp new file mode 100644 index 00000000..0aa35889 --- /dev/null +++ b/ingen/shared/LV2Atom.hpp @@ -0,0 +1,45 @@ +/* This file is part of Ingen. + * Copyright 2009-2011 David Robillard <http://drobilla.net> + * + * 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 + */ + +#ifndef INGEN_SHARED_LV2ATOM_HPP +#define INGEN_SHARED_LV2ATOM_HPP + +#include "lv2/lv2plug.in/ns/ext/atom/atom.h" + +namespace Raul { class Atom; } + +namespace Ingen { +namespace Shared { + +class URIs; + +namespace LV2Atom { + +bool to_atom(const URIs& uris, + const LV2_Atom* object, + Raul::Atom& atom); + +bool from_atom(const URIs& uris, + const Raul::Atom& atom, + LV2_Atom* object); + +} // namespace LV2Atom + +} // namespace Shared +} // namespace Ingen + +#endif // INGEN_SHARED_LV2ATOM_HPP diff --git a/ingen/shared/LV2Features.hpp b/ingen/shared/LV2Features.hpp new file mode 100644 index 00000000..f33cc605 --- /dev/null +++ b/ingen/shared/LV2Features.hpp @@ -0,0 +1,77 @@ +/* This file is part of Ingen. + * Copyright 2008-2011 David Robillard <http://drobilla.net> + * + * 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 + */ + +#ifndef INGEN_SHARED_LV2FEATURES_HPP +#define INGEN_SHARED_LV2FEATURES_HPP + +#include <vector> + +#include "lv2/lv2plug.in/ns/lv2core/lv2.h" + +#include "raul/SharedPtr.hpp" + +namespace Ingen { + +class Node; + +namespace Shared { + +class World; + +/** Stuff that may need to be passed to an LV2 plugin (i.e. LV2 features). + */ +class LV2Features { +public: + LV2Features(); + + class Feature { + public: + virtual ~Feature() {} + + virtual SharedPtr<LV2_Feature> feature(Shared::World* world, + Node* node) = 0; + }; + + class FeatureArray { + public: + typedef std::vector< SharedPtr<LV2_Feature> > FeatureVector; + + explicit FeatureArray(FeatureVector& features); + + ~FeatureArray(); + + LV2_Feature** array() { return _array; } + + private: + FeatureVector _features; + LV2_Feature** _array; + }; + + void add_feature(SharedPtr<Feature> feature); + + SharedPtr<FeatureArray> lv2_features(Shared::World* world, + Node* node) const; + +private: + typedef std::vector< SharedPtr<Feature> > Features; + Features _features; +}; + +} // namespace Shared +} // namespace Ingen + +#endif // INGEN_SHARED_LV2FEATURES_HPP diff --git a/ingen/shared/LV2URIMap.hpp b/ingen/shared/LV2URIMap.hpp new file mode 100644 index 00000000..70c47a12 --- /dev/null +++ b/ingen/shared/LV2URIMap.hpp @@ -0,0 +1,115 @@ +/* This file is part of Ingen. + * Copyright 2008-2011 David Robillard <http://drobilla.net> + * + * 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 + */ + +#ifndef INGEN_SHARED_LV2URIMAP_HPP +#define INGEN_SHARED_LV2URIMAP_HPP + +#include <map> +#include <utility> + +#include <boost/utility.hpp> + +#include "ingen/shared/LV2Features.hpp" +#include "lv2/lv2plug.in/ns/ext/uri-map/uri-map.h" +#include "lv2/lv2plug.in/ns/ext/urid/urid.h" +#include "raul/URI.hpp" + +namespace Ingen { +namespace Shared { + +/** URI to Integer Map */ +class LV2URIMap : public boost::noncopyable { +public: + LV2URIMap(LV2_URID_Map* map, LV2_URID_Unmap* unmap); + virtual ~LV2URIMap() {} + + uint32_t map_uri(const char* uri); + const char* unmap_uri(uint32_t urid); + + class Feature : public LV2Features::Feature { + public: + Feature(const char* URI, void* data) { + _feature.URI = URI; + _feature.data = data; + } + + SharedPtr<LV2_Feature> feature(Shared::World*, Node*) { + return SharedPtr<LV2_Feature>(&_feature, NullDeleter<LV2_Feature>); + } + + private: + LV2_Feature _feature; + }; + + class URIMapFeature : public Feature { + public: + URIMapFeature(LV2URIMap* map); + + private: + LV2_URI_Map_Feature _feature_data; + }; + + class URIDMapFeature : public Feature { + public: + URIDMapFeature(LV2URIMap* map, LV2_URID_Map* urid_map); + LV2_URID map(const char* uri); + private: + static LV2_URID default_map(LV2_URID_Map_Handle h, const char* uri); + LV2_URID_Map _feature_data; + }; + + class URIDUnmapFeature : public Feature { + public: + URIDUnmapFeature(LV2URIMap* map, LV2_URID_Unmap* urid_unmap); + const char* unmap(const LV2_URID urid); + private: + static const char* default_unmap(LV2_URID_Map_Handle h, LV2_URID uri); + LV2_URID_Unmap _feature_data; + }; + + SharedPtr<URIMapFeature> uri_map_feature() { return _uri_map_feature; } + SharedPtr<URIDMapFeature> urid_map_feature() { return _urid_map_feature; } + SharedPtr<URIDUnmapFeature> urid_unmap_feature() { return _urid_unmap_feature; } + + virtual uint32_t uri_to_id(const char* map, const char* uri); + virtual const char* id_to_uri(const char* map, uint32_t id); + + std::pair<bool, uint32_t> event_to_global(uint16_t event_id) const; + std::pair<bool, uint16_t> global_to_event(uint32_t global_id) const; + +private: + static uint32_t uri_map_uri_to_id(LV2_URI_Map_Callback_Data callback_data, + const char* map, + const char* uri); + + static LV2_URID urid_map(LV2_URID_Map_Handle handle, const char* uri); + static const char* urid_unmap(LV2_URID_Unmap_Handle handle, LV2_URID urid); + + typedef std::map<uint16_t, uint32_t> EventToGlobal; + typedef std::map<uint32_t, uint16_t> GlobalToEvent; + + SharedPtr<URIMapFeature> _uri_map_feature; + SharedPtr<URIDMapFeature> _urid_map_feature; + SharedPtr<URIDUnmapFeature> _urid_unmap_feature; + EventToGlobal _event_to_global; + GlobalToEvent _global_to_event; +}; + +} // namespace Shared +} // namespace Ingen + +#endif // INGEN_SHARED_LV2URIMAP_HPP diff --git a/ingen/shared/Module.hpp b/ingen/shared/Module.hpp new file mode 100644 index 00000000..f972a999 --- /dev/null +++ b/ingen/shared/Module.hpp @@ -0,0 +1,46 @@ +/* This file is part of Ingen. + * Copyright 2007-2011 David Robillard <http://drobilla.net> + * + * 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 + */ + +#ifndef INGEN_SHARED_MODULE_HPP +#define INGEN_SHARED_MODULE_HPP + +#include <glibmm/module.h> + +#include "raul/SharedPtr.hpp" + +namespace Ingen { +namespace Shared { + +class World; + +/** A dynamically loaded Ingen module. + * + * All components of Ingen reside in one of these. + */ +struct Module { + virtual ~Module(); + + virtual void load(Ingen::Shared::World* world) = 0; + virtual void run(Ingen::Shared::World* world) {} + + SharedPtr<Glib::Module> library; +}; + +} // namespace Shared +} // namespace Ingen + +#endif // INGEN_SHARED_MODULE_HPP diff --git a/ingen/shared/ResourceImpl.hpp b/ingen/shared/ResourceImpl.hpp new file mode 100644 index 00000000..8069c480 --- /dev/null +++ b/ingen/shared/ResourceImpl.hpp @@ -0,0 +1,97 @@ +/* This file is part of Ingen. + * Copyright 2008-2011 David Robillard <http://drobilla.net> + * + * 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 + */ + +#ifndef INGEN_SHARED_RESOURCEIMPL_HPP +#define INGEN_SHARED_RESOURCEIMPL_HPP + +#include "ingen/Resource.hpp" +#include "ingen/shared/URIs.hpp" +#include "raul/SharedPtr.hpp" +#include "raul/URI.hpp" + +namespace Ingen { +namespace Shared { + +class URIs; + +class ResourceImpl : virtual public Resource +{ +public: + ResourceImpl(URIs& uris, const Raul::URI& uri) + : _uris(uris) + , _uri(uri) + {} + + URIs& uris() const { return _uris; } + + virtual void set_uri(const Raul::URI& uri) { _uri = uri; } + virtual const Raul::URI& uri() const { return _uri; } + + const Properties& properties() const { return _properties; } + Properties& properties() { return _properties; } + + Properties properties(Resource::Graph ctx) const; + + const Raul::Atom& get_property(const Raul::URI& uri) const; + + const Raul::Atom& set_property(const Raul::URI& uri, + const Raul::Atom& value, + Resource::Graph ctx=Resource::DEFAULT); + + /** Hook called whenever a property is added. + * This can be used by derived classes to implement special behaviour for + * particular properties (e.g. ingen:value for ports). + */ + virtual void on_property(const Raul::URI& uri, const Raul::Atom& value) {} + + void remove_property(const Raul::URI& uri, const Raul::Atom& value); + bool has_property(const Raul::URI& uri, const Raul::Atom& value) const; + void add_property(const Raul::URI& uri, + const Raul::Atom& value, + Graph ctx = DEFAULT); + void set_properties(const Properties& p); + void add_properties(const Properties& p); + void remove_properties(const Properties& p); + + void dump(std::ostream& os) const; + + /** Get the ingen type from a set of Properties. + * If some coherent ingen type is found, true is returned and the appropriate + * output parameter set to true. Otherwise false is returned. + */ + static bool type(const URIs& uris, + const Properties& properties, + bool& patch, + bool& node, + bool& port, + bool& is_output); + +protected: + const Raul::Atom& set_property(const Raul::URI& uri, const Raul::Atom& value) const; + + URIs& _uris; + +private: + Raul::URI _uri; + mutable Properties _properties; +}; + +} // namespace Shared +} // namespace Ingen + +#endif // INGEN_SHARED_RESOURCEIMPL_HPP + diff --git a/ingen/shared/Store.hpp b/ingen/shared/Store.hpp new file mode 100644 index 00000000..3347cdde --- /dev/null +++ b/ingen/shared/Store.hpp @@ -0,0 +1,60 @@ +/* This file is part of Ingen. + * Copyright 2008-2011 David Robillard <http://drobilla.net> + * + * 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 + */ + +#ifndef INGEN_SHARED_STORE_HPP +#define INGEN_SHARED_STORE_HPP + +#include <string> + +#undef nil +#include <glibmm/thread.h> + +#include "raul/PathTable.hpp" + +#include "ingen/GraphObject.hpp" + +namespace Ingen { +namespace Shared { + +class Store : public Raul::PathTable< SharedPtr<GraphObject> > { +public: + virtual ~Store() {} + + virtual void add(GraphObject* o); + + typedef Raul::Table< Raul::Path, SharedPtr<GraphObject> > Objects; + + const_iterator children_begin(SharedPtr<const GraphObject> o) const; + const_iterator children_end(SharedPtr<const GraphObject> o) const; + + SharedPtr<GraphObject> find_child(SharedPtr<const GraphObject> parent, + const std::string& child_name) const; + + unsigned child_name_offset(const Raul::Path& parent, + const Raul::Symbol& symbol, + bool allow_zero=true); + + Glib::RWLock& lock() { return _lock; } + +private: + Glib::RWLock _lock; +}; + +} // namespace Shared +} // namespace Ingen + +#endif // INGEN_SHARED_STORE_HPP diff --git a/ingen/shared/URIs.hpp b/ingen/shared/URIs.hpp new file mode 100644 index 00000000..b3d8d301 --- /dev/null +++ b/ingen/shared/URIs.hpp @@ -0,0 +1,110 @@ +/* This file is part of Ingen. + * Copyright 2008-2011 David Robillard <http://drobilla.net> + * + * 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 + */ + +#ifndef INGEN_SHARED_URIS_HPP +#define INGEN_SHARED_URIS_HPP + +#include <boost/utility.hpp> + +#include "ingen/shared/LV2URIMap.hpp" +#include "raul/URI.hpp" + +namespace Raul { + class Forge; +} + +namespace Ingen { +namespace Shared { + +class URIs : public boost::noncopyable { +public: + URIs(Raul::Forge& forge, LV2URIMap* map); + + struct Quark : public Raul::URI { + Quark(LV2URIMap* map, const char* str); + uint32_t id; + }; + + Raul::Forge& forge; + + const Quark atom_Bool; + const Quark atom_Float; + const Quark atom_Int32; + const Quark atom_MessagePort; + const Quark atom_String; + const Quark atom_ValuePort; + const Quark atom_Vector; + const Quark atom_eventTransfer; + const Quark atom_supports; + const Quark ctx_audioContext; + const Quark ctx_context; + const Quark ctx_messageContext; + const Quark cv_CVPort; + const Quark doap_name; + const Quark ev_EventPort; + const Quark ingen_Internal; + const Quark ingen_Node; + const Quark ingen_Patch; + const Quark ingen_Port; + const Quark ingen_broadcast; + const Quark ingen_controlBinding; + const Quark ingen_document; + const Quark ingen_enabled; + const Quark ingen_engine; + const Quark ingen_nil; + const Quark ingen_node; + const Quark ingen_polyphonic; + const Quark ingen_polyphony; + const Quark ingen_sampleRate; + const Quark ingen_selected; + const Quark ingen_value; + const Quark ingen_canvasX; + const Quark ingen_canvasY; + const Quark lv2_AudioPort; + const Quark lv2_ControlPort; + const Quark lv2_InputPort; + const Quark lv2_OutputPort; + const Quark lv2_Plugin; + const Quark lv2_connectionOptional; + const Quark lv2_default; + const Quark lv2_index; + const Quark lv2_integer; + const Quark lv2_maximum; + const Quark lv2_minimum; + const Quark lv2_name; + const Quark lv2_portProperty; + const Quark lv2_sampleRate; + const Quark lv2_symbol; + const Quark lv2_toggled; + const Quark midi_Bender; + const Quark midi_ChannelPressure; + const Quark midi_Controller; + const Quark midi_MidiEvent; + const Quark midi_NoteOn; + const Quark midi_controllerNumber; + const Quark midi_noteNumber; + const Quark rdf_instanceOf; + const Quark rdf_type; + const Quark rdfs_seeAlso; + const Quark ui_Events; + const Quark wildcard; +}; + +} // namespace Shared +} // namespace Ingen + +#endif // INGEN_SHARED_LV2URIMAP_HPP diff --git a/ingen/shared/World.hpp b/ingen/shared/World.hpp new file mode 100644 index 00000000..e062dea6 --- /dev/null +++ b/ingen/shared/World.hpp @@ -0,0 +1,130 @@ +/* This file is part of Ingen. + * Copyright 2007-2011 David Robillard <http://drobilla.net> + * + * 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 + */ + +#ifndef INGEN_MODULE_WORLD_HPP +#define INGEN_MODULE_WORLD_HPP + +#include <string> + +#include <boost/shared_ptr.hpp> +#include <boost/utility.hpp> + +#include "lv2/lv2plug.in/ns/ext/urid/urid.h" + +#include "raul/Configuration.hpp" +#include "raul/SharedPtr.hpp" + +typedef struct LilvWorldImpl LilvWorld; + +namespace Sord { class World; } + +namespace Ingen { + +class EngineBase; +class ClientInterface; +class ServerInterface; + +namespace Serialisation { class Serialiser; class Parser; } + +namespace Shared { + +class LV2Features; +class URIs; +class LV2URIMap; +class Store; + +/** The "world" all Ingen modules may share. + * + * All loaded components of Ingen, as well as things requiring shared access + * and/or locking (e.g. Sord, Lilv). + * + * Ingen modules are shared libraries which modify the World when loaded + * using World::load, e.g. loading the "ingen_serialisation" module will + * set World::serialiser and World::parser to valid objects. + */ +class World : public boost::noncopyable { +public: + World(Raul::Configuration* conf, + int& argc, + char**& argv, + LV2_URID_Map* map, + LV2_URID_Unmap* unmap); + + virtual ~World(); + + virtual bool load_module(const char* name); + virtual bool run_module(const char* name); + + virtual void unload_modules(); + + typedef SharedPtr<ServerInterface> (*InterfaceFactory)( + World* world, + const std::string& engine_url, + SharedPtr<ClientInterface> respond_to); + + virtual void add_interface_factory(const std::string& scheme, + InterfaceFactory factory); + + virtual SharedPtr<ServerInterface> interface( + const std::string& engine_url, + SharedPtr<ClientInterface> respond_to); + + virtual bool run(const std::string& mime_type, + const std::string& filename); + + virtual void set_local_engine(SharedPtr<EngineBase> e); + virtual void set_engine(SharedPtr<ServerInterface> e); + virtual void set_serialiser(SharedPtr<Serialisation::Serialiser> s); + virtual void set_parser(SharedPtr<Serialisation::Parser> p); + virtual void set_store(SharedPtr<Store> s); + + virtual SharedPtr<EngineBase> local_engine(); + virtual SharedPtr<ServerInterface> engine(); + virtual SharedPtr<Serialisation::Serialiser> serialiser(); + virtual SharedPtr<Serialisation::Parser> parser(); + virtual SharedPtr<Store> store(); + + virtual Sord::World* rdf_world(); + + virtual SharedPtr<URIs> uris(); + virtual SharedPtr<LV2URIMap> lv2_uri_map(); + + virtual int& argc(); + virtual char**& argv(); + + virtual Raul::Configuration* conf(); + virtual void set_conf(Raul::Configuration* c); + + virtual Raul::Forge& forge(); + + virtual LV2Features* lv2_features(); + + virtual LilvWorld* lilv_world(); + + virtual void set_jack_uuid(const std::string& uuid); + virtual std::string jack_uuid(); + +private: + class Pimpl; + + Pimpl* _impl; +}; + +} // namespace Shared +} // namespace Ingen + +#endif // INGEN_MODULE_WORLD_HPP diff --git a/ingen/shared/runtime_paths.hpp b/ingen/shared/runtime_paths.hpp new file mode 100644 index 00000000..3ed48f00 --- /dev/null +++ b/ingen/shared/runtime_paths.hpp @@ -0,0 +1,36 @@ +/* This file is part of Ingen. + * Copyright 2008-2011 David Robillard <http://drobilla.net> + * + * 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 + */ + +#ifndef INGEN_SHARED_RUNTIME_PATHS_HPP +#define INGEN_SHARED_RUNTIME_PATHS_HPP + +#include <string> + +namespace Ingen { +namespace Shared { + +void set_bundle_path(const char* path); +void set_bundle_path_from_code(void* function); + +std::string bundle_file_path(const std::string& name); +std::string data_file_path(const std::string& name); +std::string module_path(const std::string& name, std::string dir=""); + +} // namespace Ingen +} // namespace Shared + +#endif // INGEN_SHARED_RUNTIME_PATHS_HPP |