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 --- 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 + 6 files changed, 300 insertions(+), 19 deletions(-) create mode 100644 src/shared/AtomSink.hpp create mode 100644 src/shared/AtomWriter.cpp create mode 100644 src/shared/AtomWriter.hpp (limited to 'src/shared') 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 -- cgit v1.2.1