summaryrefslogtreecommitdiffstats
path: root/ingen
diff options
context:
space:
mode:
Diffstat (limited to 'ingen')
-rw-r--r--ingen/SocketWriter.hpp26
-rw-r--r--ingen/TurtleWriter.hpp67
2 files changed, 71 insertions, 22 deletions
diff --git a/ingen/SocketWriter.hpp b/ingen/SocketWriter.hpp
index bb5c332b..871a63f5 100644
--- a/ingen/SocketWriter.hpp
+++ b/ingen/SocketWriter.hpp
@@ -19,20 +19,14 @@
#include <stdint.h>
-#include "ingen/AtomSink.hpp"
-#include "ingen/AtomWriter.hpp"
-#include "ingen/Interface.hpp"
-#include "ingen/types.hpp"
-#include "ingen/ingen.h"
+#include "ingen/TurtleWriter.hpp"
#include "raul/Socket.hpp"
-#include "raul/URI.hpp"
-#include "sratom/sratom.h"
namespace Ingen {
/** An Interface that writes Turtle messages to a socket.
*/
-class INGEN_API SocketWriter : public AtomWriter, public AtomSink
+class INGEN_API SocketWriter : public TurtleWriter
{
public:
SocketWriter(URIMap& map,
@@ -40,24 +34,12 @@ public:
const Raul::URI& uri,
SPtr<Raul::Socket> sock);
- ~SocketWriter();
-
- bool write(const LV2_Atom* msg);
+ size_t text_sink(const void* buf, size_t len) override;
+ /** Override of bundle_end to terminate bundles in the stream. */
void bundle_end();
- int fd() { return _socket->fd(); }
- Raul::URI uri() const { return _uri; }
- SerdWriter* writer() { return _writer; }
-
protected:
- URIMap& _map;
- Sratom* _sratom;
- SerdNode _base;
- SerdURI _base_uri;
- SerdEnv* _env;
- SerdWriter* _writer;
- Raul::URI _uri;
SPtr<Raul::Socket> _socket;
};
diff --git a/ingen/TurtleWriter.hpp b/ingen/TurtleWriter.hpp
new file mode 100644
index 00000000..4ce10f3c
--- /dev/null
+++ b/ingen/TurtleWriter.hpp
@@ -0,0 +1,67 @@
+/*
+ This file is part of Ingen.
+ Copyright 2012-2016 David Robillard <http://drobilla.net/>
+
+ Ingen is free software: you can redistribute it and/or modify it under the
+ terms of the GNU Affero General Public License as published by the Free
+ Software Foundation, either version 3 of the License, or 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 Affero General Public License for details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with Ingen. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef INGEN_TURTLE_WRITER_HPP
+#define INGEN_TURTLE_WRITER_HPP
+
+#include <stdint.h>
+
+#include "ingen/AtomSink.hpp"
+#include "ingen/AtomWriter.hpp"
+#include "ingen/Interface.hpp"
+#include "ingen/types.hpp"
+#include "ingen/ingen.h"
+#include "raul/URI.hpp"
+#include "sratom/sratom.h"
+
+namespace Ingen {
+
+/** An Interface that writes Turtle messages to a sink method.
+ *
+ * Derived classes must implement text_sink() to do something with the
+ * serialized messages.
+ */
+class INGEN_API TurtleWriter : public AtomWriter, public AtomSink
+{
+public:
+ TurtleWriter(URIMap& map,
+ URIs& uris,
+ const Raul::URI& uri);
+
+ virtual ~TurtleWriter();
+
+ /** AtomSink method which receives calls serialized to LV2 atoms. */
+ bool write(const LV2_Atom* msg);
+
+ /** Pure virtual text sink which receives calls serialized to Turtle. */
+ virtual size_t text_sink(const void* buf, size_t len) = 0;
+
+ Raul::URI uri() const { return _uri; }
+
+protected:
+ URIMap& _map;
+ Sratom* _sratom;
+ SerdNode _base;
+ SerdURI _base_uri;
+ SerdEnv* _env;
+ SerdWriter* _writer;
+ Raul::URI _uri;
+ bool _wrote_prefixes;
+};
+
+} // namespace Ingen
+
+#endif // INGEN_TURTLE_WRITER_HPP