From 7126f005be3e49818dafe0d2666b6745e09f8aff Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 16 Mar 2012 16:55:33 +0000 Subject: Remove ping() from interface, just use a get instead. Add preliminary AtomWriter Interface. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4068 a436a847-0d15-0410-975c-d299462d15a1 --- ingen/Interface.hpp | 1 - ingen/client/ClientStore.hpp | 1 - ingen/client/SigClientInterface.hpp | 1 - ingen/shared/ClashAvoider.hpp | 1 - ingen/shared/LV2URIMap.hpp | 23 ++---- ingen/shared/URIs.hpp | 14 +++- src/gui/ConnectWindow.cpp | 5 +- src/server/ClientBroadcaster.hpp | 1 - src/server/ServerInterfaceImpl.cpp | 6 -- src/shared/AtomSink.hpp | 34 +++++++++ src/shared/AtomWriter.cpp | 147 ++++++++++++++++++++++++++++++++++++ src/shared/AtomWriter.hpp | 89 ++++++++++++++++++++++ src/shared/LV2URIMap.cpp | 34 ++++----- src/shared/URIs.cpp | 14 +++- src/shared/wscript | 1 + wscript | 2 + 16 files changed, 324 insertions(+), 50 deletions(-) create mode 100644 src/shared/AtomSink.hpp create mode 100644 src/shared/AtomWriter.cpp create mode 100644 src/shared/AtomWriter.hpp diff --git a/ingen/Interface.hpp b/ingen/Interface.hpp index cdc37949..3f79e2de 100644 --- a/ingen/Interface.hpp +++ b/ingen/Interface.hpp @@ -75,7 +75,6 @@ public: virtual void set_response_id(int32_t id) = 0; // Requests - virtual void ping() = 0; virtual void get(const Raul::URI& uri) = 0; // Response diff --git a/ingen/client/ClientStore.hpp b/ingen/client/ClientStore.hpp index dbba8e90..d26573ea 100644 --- a/ingen/client/ClientStore.hpp +++ b/ingen/client/ClientStore.hpp @@ -104,7 +104,6 @@ public: void del(const Raul::URI& uri); void set_response_id(int32_t id) {} - void ping() {} void get(const Raul::URI& uri) {} void response(int32_t id, Status status) {} void error(const std::string& msg) {} diff --git a/ingen/client/SigClientInterface.hpp b/ingen/client/SigClientInterface.hpp index afc4d66b..7a53a7f7 100644 --- a/ingen/client/SigClientInterface.hpp +++ b/ingen/client/SigClientInterface.hpp @@ -111,7 +111,6 @@ protected: { EMIT(property_change, subject, key, value); } void set_response_id(int32_t id) {} - void ping() {} void get(const Raul::URI& uri) {} }; diff --git a/ingen/shared/ClashAvoider.hpp b/ingen/shared/ClashAvoider.hpp index 5c33d412..41c6c86c 100644 --- a/ingen/shared/ClashAvoider.hpp +++ b/ingen/shared/ClashAvoider.hpp @@ -77,7 +77,6 @@ public: virtual void del(const Raul::URI& uri); virtual void set_response_id(int32_t id) {} - virtual void ping() {} virtual void get(const Raul::URI& uri) {} virtual void response(int32_t id, Status status) {} virtual void error(const std::string& msg) {} diff --git a/ingen/shared/LV2URIMap.hpp b/ingen/shared/LV2URIMap.hpp index 70c47a12..01bbfb7d 100644 --- a/ingen/shared/LV2URIMap.hpp +++ b/ingen/shared/LV2URIMap.hpp @@ -55,30 +55,23 @@ public: LV2_Feature _feature; }; - class URIMapFeature : public Feature { - public: + struct URIMapFeature : public Feature { URIMapFeature(LV2URIMap* map); - - private: - LV2_URI_Map_Feature _feature_data; + LV2_URI_Map_Feature uri_map; }; - class URIDMapFeature : public Feature { - public: + struct URIDMapFeature : public Feature { URIDMapFeature(LV2URIMap* map, LV2_URID_Map* urid_map); - LV2_URID map(const char* uri); - private: + LV2_URID map(const char* uri); static LV2_URID default_map(LV2_URID_Map_Handle h, const char* uri); - LV2_URID_Map _feature_data; + LV2_URID_Map urid_map; }; - class URIDUnmapFeature : public Feature { - public: + struct URIDUnmapFeature : public Feature { URIDUnmapFeature(LV2URIMap* map, LV2_URID_Unmap* urid_unmap); - const char* unmap(const LV2_URID urid); - private: + const char* unmap(const LV2_URID urid); static const char* default_unmap(LV2_URID_Map_Handle h, LV2_URID uri); - LV2_URID_Unmap _feature_data; + LV2_URID_Unmap urid_unmap; }; SharedPtr uri_map_feature() { return _uri_map_feature; } diff --git a/ingen/shared/URIs.hpp b/ingen/shared/URIs.hpp index a99e45d0..22c46f15 100644 --- a/ingen/shared/URIs.hpp +++ b/ingen/shared/URIs.hpp @@ -36,6 +36,7 @@ public: struct Quark : public Raul::URI { Quark(LV2URIMap* map, const char* str); + operator LV2_URID() const { return id; } uint32_t id; }; @@ -56,13 +57,17 @@ public: const Quark cv_CVPort; const Quark doap_name; const Quark ev_EventPort; + const Quark ingen_Connection; const Quark ingen_Internal; const Quark ingen_Node; const Quark ingen_Patch; const Quark ingen_Port; const Quark ingen_activity; const Quark ingen_broadcast; + const Quark ingen_canvasX; + const Quark ingen_canvasY; const Quark ingen_controlBinding; + const Quark ingen_destination; const Quark ingen_document; const Quark ingen_enabled; const Quark ingen_engine; @@ -72,9 +77,8 @@ public: const Quark ingen_polyphony; const Quark ingen_sampleRate; const Quark ingen_selected; + const Quark ingen_source; const Quark ingen_value; - const Quark ingen_canvasX; - const Quark ingen_canvasY; const Quark lv2_AudioPort; const Quark lv2_ControlPort; const Quark lv2_InputPort; @@ -98,6 +102,12 @@ public: const Quark midi_NoteOn; const Quark midi_controllerNumber; const Quark midi_noteNumber; + const Quark patch_Get; + const Quark patch_Put; + const Quark patch_Response; + const Quark patch_body; + const Quark patch_request; + const Quark patch_subject; const Quark rdf_instanceOf; const Quark rdf_type; const Quark rdfs_seeAlso; diff --git a/src/gui/ConnectWindow.cpp b/src/gui/ConnectWindow.cpp index 12f2173a..dfb285a4 100644 --- a/src/gui/ConnectWindow.cpp +++ b/src/gui/ConnectWindow.cpp @@ -380,7 +380,7 @@ ConnectWindow::gtk_callback() _ping_id = abs(rand()) / 2 * 2; // avoid -1 _app->engine()->set_response_id(_ping_id); - _app->engine()->ping(); + _app->engine()->get("ingen:engine"); if (_widgets_loaded) { _progress_label->set_text("Connecting to engine..."); @@ -397,12 +397,11 @@ ConnectWindow::gtk_callback() (now.tv_usec - last.tv_usec) * 0.001f; if (ms_since_last > 1000) { _app->engine()->set_response_id(_ping_id); - _app->engine()->ping(); + _app->engine()->get("ingen:engine"); last = now; } } } else if (_connect_stage == 2) { - _app->engine()->get("ingen:engine"); _app->engine()->get(Path("/")); if (_widgets_loaded) _progress_label->set_text(string("Requesting root patch...")); diff --git a/src/server/ClientBroadcaster.hpp b/src/server/ClientBroadcaster.hpp index ee356702..7cccfb1f 100644 --- a/src/server/ClientBroadcaster.hpp +++ b/src/server/ClientBroadcaster.hpp @@ -115,7 +115,6 @@ public: Raul::URI uri() const { return "http://drobilla.net/ns/ingen#broadcaster"; } ///< N/A void set_response_id(int32_t id) {} ///< N/A - void ping() {} ///< N/A void get(const Raul::URI& uri) {} ///< N/A void response(int32_t id, Status status) {} ///< N/A diff --git a/src/server/ServerInterfaceImpl.cpp b/src/server/ServerInterfaceImpl.cpp index b5c6f3fc..f03294b2 100644 --- a/src/server/ServerInterfaceImpl.cpp +++ b/src/server/ServerInterfaceImpl.cpp @@ -181,12 +181,6 @@ ServerInterfaceImpl::set_property(const URI& uri, // Requests // -void -ServerInterfaceImpl::ping() -{ - push_queued(new Events::Ping(_engine, _request_client, _request_id, now())); -} - void ServerInterfaceImpl::get(const URI& uri) { diff --git a/src/shared/AtomSink.hpp b/src/shared/AtomSink.hpp new file mode 100644 index 00000000..5bc5aef6 --- /dev/null +++ b/src/shared/AtomSink.hpp @@ -0,0 +1,34 @@ +/* This file is part of Ingen. + * Copyright 2012 David Robillard + * + * Ingen is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef INGEN_ATOMSINK_HPP +#define INGEN_ATOMSINK_HPP + +namespace Ingen { +namespace Shared { + +class AtomSink +{ +public: + virtual void write(const LV2_Atom* msg) = 0; +}; + +} // namespace Shared +} // namespace Ingen + +#endif // INGEN_ATOMSINK_HPP + diff --git a/src/shared/AtomWriter.cpp b/src/shared/AtomWriter.cpp new file mode 100644 index 00000000..a5317bfb --- /dev/null +++ b/src/shared/AtomWriter.cpp @@ -0,0 +1,147 @@ +/* This file is part of Ingen. + * Copyright 2012 David Robillard + * + * Ingen is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "raul/Path.hpp" + +#include "AtomWriter.hpp" + +namespace Ingen { +namespace Shared { + +AtomWriter::AtomWriter(LV2URIMap& map, URIs& uris) + : _map(map) + , _uris(uris) + , _id(-1) +{ + lv2_atom_forge_init(&_forge, &map.urid_map_feature()->urid_map); +} + +int32_t +AtomWriter::next_id() +{ + if (_id == -1) { + return 0; + } else { + return ++_id; + } +} + +void +AtomWriter::bundle_begin() +{ +} + +void +AtomWriter::bundle_end() +{ +} + +void +AtomWriter::put(const Raul::URI& uri, + const Resource::Properties& properties, + Resource::Graph ctx) +{ +} + +void +AtomWriter::delta(const Raul::URI& uri, + const Resource::Properties& remove, + const Resource::Properties& add) +{ +} + +void +AtomWriter::move(const Raul::Path& old_path, + const Raul::Path& new_path) +{ +} + +void +AtomWriter::del(const Raul::URI& uri) +{ +} + +void +AtomWriter::connect(const Raul::Path& src, + const Raul::Path& dst) +{ + LV2_Atom_Forge_Frame msg; + lv2_atom_forge_blank(&_forge, &msg, next_id(), _uris.patch_Put); + lv2_atom_forge_property_head(&_forge, _uris.patch_body, 0); + + LV2_Atom_Forge_Frame body; + lv2_atom_forge_blank(&_forge, &body, 0, _uris.ingen_Connection); + lv2_atom_forge_property_head(&_forge, _uris.ingen_source, 0); + lv2_atom_forge_string(&_forge, src.c_str(), src.length()); + lv2_atom_forge_property_head(&_forge, _uris.ingen_destination, 0); + lv2_atom_forge_string(&_forge, dst.c_str(), dst.length()); + lv2_atom_forge_pop(&_forge, &body); + + lv2_atom_forge_pop(&_forge, &msg); +} + +void +AtomWriter::disconnect(const Raul::URI& src, + const Raul::URI& dst) +{ +} + +void +AtomWriter::disconnect_all(const Raul::Path& parent_patch_path, + const Raul::Path& path) +{ +} + +void +AtomWriter::set_property(const Raul::URI& subject, + const Raul::URI& predicate, + const Raul::Atom& value) +{ +} + +void +AtomWriter::set_response_id(int32_t id) +{ +} + +void +AtomWriter::get(const Raul::URI& uri) +{ + LV2_Atom_Forge_Frame msg; + lv2_atom_forge_blank(&_forge, &msg, next_id(), _uris.patch_Get); + lv2_atom_forge_property_head(&_forge, _uris.patch_subject, 0); + lv2_atom_forge_uri(&_forge, uri.c_str(), uri.length()); + lv2_atom_forge_pop(&_forge, &msg); +} + +void +AtomWriter::response(int32_t id, Status status) +{ + LV2_Atom_Forge_Frame msg; + lv2_atom_forge_blank(&_forge, &msg, next_id(), _uris.patch_Response); + lv2_atom_forge_property_head(&_forge, _uris.patch_request, 0); + lv2_atom_forge_int32(&_forge, id); + lv2_atom_forge_pop(&_forge, &msg); +} + +void +AtomWriter::error(const std::string& msg) +{ +} + +} // namespace Shared +} // namespace Ingen diff --git a/src/shared/AtomWriter.hpp b/src/shared/AtomWriter.hpp new file mode 100644 index 00000000..2983848c --- /dev/null +++ b/src/shared/AtomWriter.hpp @@ -0,0 +1,89 @@ +/* This file is part of Ingen. + * Copyright 2012 David Robillard + * + * Ingen is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef INGEN_SHARED_ATOM_WRITER_HPP +#define INGEN_SHARED_ATOM_WRITER_HPP + +#include "ingen/Interface.hpp" +#include "ingen/shared/LV2URIMap.hpp" +#include "ingen/shared/URIs.hpp" +#include "lv2/lv2plug.in/ns/ext/atom/forge.h" + +namespace Ingen { +namespace Shared { + +/** An Interface that writes LV2 atoms. */ +class AtomWriter : public Interface +{ +public: + AtomWriter(LV2URIMap& map, URIs& uris); + ~AtomWriter() {} + + Raul::URI uri() const { return "http://drobilla.net/ns/ingen#AtomWriter"; } + + void bundle_begin(); + + void bundle_end(); + + 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 del(const Raul::URI& uri); + + 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 set_property(const Raul::URI& subject, + const Raul::URI& predicate, + const Raul::Atom& value); + + void set_response_id(int32_t id); + + void get(const Raul::URI& uri); + + void response(int32_t id, Status status); + + void error(const std::string& msg); + +private: + int32_t next_id(); + + LV2URIMap& _map; + URIs& _uris; + LV2_Atom_Forge _forge; + int32_t _id; +}; + +} // namespace Shared +} // namespace Ingen + +#endif // INGEN_SHARED_ATOM_WRITER_HPP + diff --git a/src/shared/LV2URIMap.cpp b/src/shared/LV2URIMap.cpp index c66a8984..14b6ca0a 100644 --- a/src/shared/LV2URIMap.cpp +++ b/src/shared/LV2URIMap.cpp @@ -43,21 +43,21 @@ LV2URIMap::LV2URIMap(LV2_URID_Map* map, LV2_URID_Unmap* unmap) } LV2URIMap::URIMapFeature::URIMapFeature(LV2URIMap* map) - : Feature(LV2_URI_MAP_URI, &_feature_data) + : Feature(LV2_URI_MAP_URI, &uri_map) { - _feature_data.uri_to_id = &LV2URIMap::uri_map_uri_to_id; - _feature_data.callback_data = map; + uri_map.uri_to_id = &LV2URIMap::uri_map_uri_to_id; + uri_map.callback_data = map; } LV2URIMap::URIDMapFeature::URIDMapFeature(LV2URIMap* map, - LV2_URID_Map* urid_map) - : Feature(LV2_URID__map, &_feature_data) + LV2_URID_Map* impl) + : Feature(LV2_URID__map, &urid_map) { - if (urid_map) { - _feature_data = *urid_map; + if (impl) { + urid_map = *impl; } else { - _feature_data.map = default_map; - _feature_data.handle = NULL; + urid_map.map = default_map; + urid_map.handle = NULL; } } @@ -71,19 +71,19 @@ LV2URIMap::URIDMapFeature::default_map(LV2_URID_Map_Handle handle, LV2_URID LV2URIMap::URIDMapFeature::map(const char* uri) { - return _feature_data.map(_feature_data.handle, uri); + return urid_map.map(urid_map.handle, uri); } LV2URIMap::URIDUnmapFeature::URIDUnmapFeature(LV2URIMap* map, - LV2_URID_Unmap* urid_unmap) - : Feature(LV2_URID__unmap, &_feature_data) + LV2_URID_Unmap* impl) + : Feature(LV2_URID__unmap, &urid_unmap) { - if (urid_unmap) { - _feature_data = *urid_unmap; + if (impl) { + urid_unmap = *impl; } else { - _feature_data.unmap = default_unmap; - _feature_data.handle = NULL; + urid_unmap.unmap = default_unmap; + urid_unmap.handle = NULL; } } @@ -97,7 +97,7 @@ LV2URIMap::URIDUnmapFeature::default_unmap(LV2_URID_Unmap_Handle handle, const char* LV2URIMap::URIDUnmapFeature::unmap(LV2_URID urid) { - return _feature_data.unmap(_feature_data.handle, urid); + return urid_unmap.unmap(urid_unmap.handle, urid); } uint32_t diff --git a/src/shared/URIs.cpp b/src/shared/URIs.cpp index 1cefbca3..3ca8a69d 100644 --- a/src/shared/URIs.cpp +++ b/src/shared/URIs.cpp @@ -28,6 +28,7 @@ #include "lv2/lv2plug.in/ns/lv2core/lv2.h" #include "lv2/lv2plug.in/ns/ext/atom/atom.h" #include "lv2/lv2plug.in/ns/ext/midi/midi.h" +#include "lv2/lv2plug.in/ns/ext/patch/patch.h" #include "raul/log.hpp" using namespace std; @@ -64,13 +65,17 @@ URIs::URIs(Raul::Forge& f, LV2URIMap* map) , cv_CVPort (map, "http://lv2plug.in/ns/ext/cv-port#CVPort") , doap_name (map, "http://usefulinc.com/ns/doap#name") , ev_EventPort (map, "http://lv2plug.in/ns/ext/event#EventPort") + , ingen_Connection (map, NS_INGEN "Connection") , ingen_Internal (map, NS_INGEN "Internal") , ingen_Node (map, NS_INGEN "Node") , ingen_Patch (map, NS_INGEN "Patch") , ingen_Port (map, NS_INGEN "Port") , ingen_activity (map, NS_INGEN "activity") , ingen_broadcast (map, NS_INGEN "broadcast") + , ingen_canvasX (map, NS_INGEN "canvasX") + , ingen_canvasY (map, NS_INGEN "canvasY") , ingen_controlBinding (map, NS_INGEN "controlBinding") + , ingen_destination (map, NS_INGEN "destination") , ingen_document (map, NS_INGEN "document") , ingen_enabled (map, NS_INGEN "enabled") , ingen_engine (map, NS_INGEN "engine") @@ -80,9 +85,8 @@ URIs::URIs(Raul::Forge& f, LV2URIMap* map) , ingen_polyphony (map, NS_INGEN "polyphony") , ingen_sampleRate (map, NS_INGEN "sampleRate") , ingen_selected (map, NS_INGEN "selected") + , ingen_source (map, NS_INGEN "source") , ingen_value (map, NS_INGEN "value") - , ingen_canvasX (map, NS_INGEN "canvasX") - , ingen_canvasY (map, NS_INGEN "canvasY") , lv2_AudioPort (map, LV2_CORE__AudioPort) , lv2_ControlPort (map, LV2_CORE__ControlPort) , lv2_InputPort (map, LV2_CORE__InputPort) @@ -106,6 +110,12 @@ URIs::URIs(Raul::Forge& f, LV2URIMap* map) , midi_NoteOn (map, LV2_MIDI__NoteOn) , midi_controllerNumber (map, LV2_MIDI__controllerNumber) , midi_noteNumber (map, LV2_MIDI__noteNumber) + , patch_Get (map, LV2_PATCH__Get) + , patch_Put (map, LV2_PATCH__Put) + , patch_Response (map, LV2_PATCH__Response) + , patch_body (map, LV2_PATCH__body) + , patch_request (map, LV2_PATCH__request) + , patch_subject (map, LV2_PATCH__subject) , rdf_instanceOf (map, NS_RDF "instanceOf") , rdf_type (map, NS_RDF "type") , rdfs_seeAlso (map, NS_RDFS "seeAlso") diff --git a/src/shared/wscript b/src/shared/wscript index 72f56012..11b61f17 100644 --- a/src/shared/wscript +++ b/src/shared/wscript @@ -13,6 +13,7 @@ def build(bld): autowaf.use_lib(bld, obj, 'GLIBMM LV2CORE LILV RAUL SORD LV2_MIDI') obj.source = ''' + AtomWriter.cpp Builder.cpp ClashAvoider.cpp Configuration.cpp diff --git a/wscript b/wscript index 9e2083fb..5030e0b7 100644 --- a/wscript +++ b/wscript @@ -92,6 +92,8 @@ def configure(conf): uselib_store='LV2_ATOM') autowaf.check_pkg(conf, 'lv2-lv2plug.in-ns-ext-midi', uselib_store='LV2_MIDI') + autowaf.check_pkg(conf, 'lv2-lv2plug.in-ns-ext-patch', + uselib_store='LV2_PATCH') autowaf.check_pkg(conf, 'lv2-lv2plug.in-ns-ext-state', uselib_store='LV2_STATE') autowaf.check_pkg(conf, 'lv2-lv2plug.in-ns-ext-contexts', -- cgit v1.2.1