summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2008-01-06 21:55:17 +0000
committerDavid Robillard <d@drobilla.net>2008-01-06 21:55:17 +0000
commit966dbecf3e8dd13bd8af6de129a0af5b8dc83b8f (patch)
treeb6f015589464b7dad703595ea0555ba1233504d6
parent2747087c382445ad7c1b891993679fb299a73151 (diff)
downloadraul-966dbecf3e8dd13bd8af6de129a0af5b8dc83b8f.tar.gz
raul-966dbecf3e8dd13bd8af6de129a0af5b8dc83b8f.tar.bz2
raul-966dbecf3e8dd13bd8af6de129a0af5b8dc83b8f.zip
Remove raul dependency on liblo and redlandmm.
git-svn-id: http://svn.drobilla.net/lad/raul@1025 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--configure.ac18
-rw-r--r--raul.pc.in4
-rw-r--r--raul/Atom.hpp80
-rw-r--r--raul/AtomLiblo.hpp91
-rw-r--r--raul/AtomRDF.hpp106
-rw-r--r--raul/Makefile.am6
6 files changed, 159 insertions, 146 deletions
diff --git a/configure.ac b/configure.ac
index c2c8448..ae83fe6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -144,23 +144,7 @@ AM_CONDITIONAL(BUILD_UNIT_TESTS, [test "$build_unit_tests" = "yes"])
################## RAUL
-# Check for Redlandmm
-build_redlandmm="no"
-PKG_CHECK_MODULES([REDLANDMM], [redlandmm], [build_redlandmm="yes"], [build_redlandmm="no"])
-AM_CONDITIONAL(WITH_REDLANDMM, [test "$build_redlandmm" = "yes"])
-AC_DEFINE(HAVE_REDLANDMM, 1, [Has redlandmm])
-
-# Check for liblo
-build_liblo="yes"
-AC_ARG_ENABLE(liblo,
- [AS_HELP_STRING(--enable-liblo, [Include liblo (OSC) support (yes)])],
- [ if test x$enable_liblo = xno ; then build_liblo=no ; fi ])
-if test "$build_liblo" = "yes"; then
- PKG_CHECK_MODULES(LIBLO, liblo >= 0.22, [],
- AC_MSG_ERROR([OSC support requires liblo (>= 0.22)]))
-fi
-AM_CONDITIONAL(WITH_LIBLO, [test "$build_liblo" = "yes"])
-
+# (No required dependencies)
#################### OUTPUT
diff --git a/raul.pc.in b/raul.pc.in
index 629362d..15dafcb 100644
--- a/raul.pc.in
+++ b/raul.pc.in
@@ -6,5 +6,5 @@ includedir=@includedir@
Name: raul
Version: @VERSION@
Description: A C++ convenience library for realtime audio applications
-Libs: -L${libdir} -lraul @GLIBMM_LIBS@ @GTHREAD_LIBS@ @REDLANDMM_LIBS@ @JACK_LIBS@ @LASH_LIBS@
-Cflags: -I${includedir} @GLIBMM_CFLAGS@ @GTHREAD_CFLAGS@ @REDLANDMM_CFLAGS@ @JACK_CFLAGS@ @LASH_CFLAGS@
+Libs: -L${libdir} -lraul @GLIBMM_LIBS@ @GTHREAD_LIBS@ @JACK_LIBS@ @LASH_LIBS@
+Cflags: -I${includedir} @GLIBMM_CFLAGS@ @GTHREAD_CFLAGS@ @JACK_CFLAGS@ @LASH_CFLAGS@
diff --git a/raul/Atom.hpp b/raul/Atom.hpp
index c1ca366..b9d81ec 100644
--- a/raul/Atom.hpp
+++ b/raul/Atom.hpp
@@ -26,10 +26,6 @@
#include <iostream>
#include CONFIG_H_PATH
-#ifdef HAVE_REDLANDMM
-#include <redlandmm/Node.hpp>
-#include <redlandmm/World.hpp>
-#endif
#define CUC(x) ((const unsigned char*)(x))
@@ -62,30 +58,7 @@ public:
Atom(void* val) : _type(BLOB), _blob_size(sizeof(val)), _blob_val(malloc(_blob_size))
{ memcpy(_blob_val, val, sizeof(_blob_size)); }
-#ifdef HAVE_REDLANDMM
- Atom(const Redland::Node& node)
- {
- if (node.type() == Redland::Node::RESOURCE) {
- _type = STRING;
- _string_val = strdup(node.to_c_string());
- } else if (node.is_float()) {
- _type = FLOAT;
- _float_val = node.to_float();
- } else if (node.is_int()) {
- _type = INT;
- _int_val = node.to_int();
- } else if (node.is_bool()) {
- _type = BOOL;
- _bool_val = node.to_bool();
- } else {
- _type = STRING;
- _string_val = strdup(node.to_c_string());
- }
- }
-#endif
-
- ~Atom()
- {
+ ~Atom() {
if (_type == STRING)
free(_string_val);
else if (_type == BLOB)
@@ -113,8 +86,7 @@ public:
}
}
- Atom& operator=(const Atom& other)
- {
+ Atom& operator=(const Atom& other) {
if (_type == BLOB)
free(_blob_val);
else if (_type == STRING)
@@ -152,54 +124,6 @@ public:
inline operator bool() const { return (_type != NIL); }
-
-#ifdef HAVE_REDLANDMM
- Redland::Node to_rdf_node(Redland::World& world) const
- {
- std::ostringstream os;
- std::string str;
- librdf_uri* type = NULL;
- librdf_node* node = NULL;
-
- switch (_type) {
- case Atom::INT:
- os << get_int32();
- str = os.str();
- // xsd:integer -> pretty integer literals in Turtle
- type = librdf_new_uri(world.world(), CUC("http://www.w3.org/2001/XMLSchema#integer"));
- break;
- case Atom::FLOAT:
- os.precision(20);
- os << get_float();
- str = os.str();
- // xsd:decimal -> pretty decimal (float) literals in Turtle
- type = librdf_new_uri(world.world(), CUC("http://www.w3.org/2001/XMLSchema#decimal"));
- break;
- case Atom::BOOL:
- // xsd:boolean -> pretty boolean literals in Turtle
- if (get_bool())
- str = "true";
- else
- str = "false";
- type = librdf_new_uri(world.world(), CUC("http://www.w3.org/2001/XMLSchema#boolean"));
- break;
- case Atom::STRING:
- str = get_string();
- break;
- case Atom::BLOB:
- case Atom::NIL:
- default:
- std::cerr << "WARNING: Unserializable Atom!" << std::endl;
- }
-
- if (str != "")
- node = librdf_new_node_from_typed_literal(world.world(), CUC(str.c_str()), NULL, type);
-
- return Redland::Node(world, node);
- }
-#endif
-
-
private:
Type _type;
diff --git a/raul/AtomLiblo.hpp b/raul/AtomLiblo.hpp
index e21e6c3..3491b3a 100644
--- a/raul/AtomLiblo.hpp
+++ b/raul/AtomLiblo.hpp
@@ -15,6 +15,11 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+/** @file Conversion from Raul Atom to Liblo OSC arguments and vice-versa.
+ * This header depends on liblo, only apps which directly depend on
+ * both raul and liblo should include it.
+ */
+
#ifndef RAUL_ATOM_LIBLO_HPP
#define RAUL_ATOM_LIBLO_HPP
@@ -22,57 +27,53 @@
#include <raul/Atom.hpp>
namespace Raul {
+namespace AtomLiblo {
-
-/** Support for serializing an Atom to/from liblo messages.
- *
- * (Here to prevent a unnecessary liblo dependency for Atom).
- *
- * \ingroup raul
- */
-class AtomLiblo {
-public:
- static void lo_message_add_atom(lo_message m, const Atom& atom) {
- switch (atom.type()) {
- case Atom::INT:
- lo_message_add_int32(m, atom.get_int32());
- break;
- case Atom::FLOAT:
- lo_message_add_float(m, atom.get_float());
- break;
- case Atom::STRING:
- lo_message_add_string(m, atom.get_string());
- break;
- case Atom::BLOB:
- // FIXME: is this okay? what does liblo do?
- lo_message_add_blob(m, const_cast<void*>(atom.get_blob()));
- break;
- case Atom::NIL:
- default:
- lo_message_add_nil(m);
- break;
- }
+inline void
+lo_message_add_atom(lo_message m, const Atom& atom)
+{
+ switch (atom.type()) {
+ case Atom::INT:
+ lo_message_add_int32(m, atom.get_int32());
+ break;
+ case Atom::FLOAT:
+ lo_message_add_float(m, atom.get_float());
+ break;
+ case Atom::STRING:
+ lo_message_add_string(m, atom.get_string());
+ break;
+ case Atom::BLOB:
+ // FIXME: is this okay? what does liblo do?
+ lo_message_add_blob(m, const_cast<void*>(atom.get_blob()));
+ break;
+ case Atom::NIL:
+ default:
+ lo_message_add_nil(m);
+ break;
}
+}
- static Atom lo_arg_to_atom(char type, lo_arg* arg) {
- switch (type) {
- case 'i':
- return Atom(arg->i);
- case 'f':
- return Atom(arg->f);
- case 's':
- return Atom(&arg->s);
- //case 'b'
- // FIXME: How to get a blob from a lo_arg?
- //return Atom(arg->b);
- default:
- return Atom();
- }
- }
-};
+inline Atom
+lo_arg_to_atom(char type, lo_arg* arg)
+{
+ switch (type) {
+ case 'i':
+ return Atom(arg->i);
+ case 'f':
+ return Atom(arg->f);
+ case 's':
+ return Atom(&arg->s);
+ //case 'b'
+ // FIXME: How to get a blob from a lo_arg?
+ //return Atom(arg->b);
+ default:
+ return Atom();
+ }
+}
+} // namespace AtomLiblo
} // namespace Raul
#endif // RAUL_ATOM_LIBLO_HPP
diff --git a/raul/AtomRDF.hpp b/raul/AtomRDF.hpp
new file mode 100644
index 0000000..2934a2a
--- /dev/null
+++ b/raul/AtomRDF.hpp
@@ -0,0 +1,106 @@
+/* This file is part of Raul.
+ * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
+ *
+ * Raul 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.
+ *
+ * Raul 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
+ */
+
+/** @file Conversion from Raul Atom to Redlandmm RDF Node and vice-versa.
+ * This header depends on redlandmm, only apps which directly depend on
+ * both raul and redlandmm should include it.
+ */
+
+#ifndef RAUL_ATOM_RDF_HPP
+#define RAUL_ATOM_RDF_HPP
+
+#include <cstring>
+#include <string>
+#include <sstream>
+
+#include CONFIG_H_PATH
+
+#include <redlandmm/Node.hpp>
+#include <redlandmm/World.hpp>
+
+#define CUC(x) ((const unsigned char*)(x))
+
+namespace Raul {
+namespace AtomRDF {
+
+inline Atom
+node_to_atom(const Redland::Node& node)
+{
+ if (node.type() == Redland::Node::RESOURCE)
+ return Atom(node.to_c_string());
+ else if (node.is_float())
+ return Atom(node.to_float());
+ else if (node.is_int())
+ return Atom(node.to_int());
+ else if (node.is_bool())
+ return Atom(node.to_bool());
+ else
+ return Atom(node.to_c_string());
+}
+
+
+inline Redland::Node
+atom_to_node(Redland::World& world, const Atom& atom)
+{
+ std::ostringstream os;
+ std::string str;
+ librdf_uri* type = NULL;
+ librdf_node* node = NULL;
+
+ switch (atom.type()) {
+ case Atom::INT:
+ os << atom.get_int32();
+ str = os.str();
+ // xsd:integer -> pretty integer literals in Turtle
+ type = librdf_new_uri(world.world(), CUC("http://www.w3.org/2001/XMLSchema#integer"));
+ break;
+ case Atom::FLOAT:
+ os.precision(20);
+ os << atom.get_float();
+ str = os.str();
+ // xsd:decimal -> pretty decimal (float) literals in Turtle
+ type = librdf_new_uri(world.world(), CUC("http://www.w3.org/2001/XMLSchema#decimal"));
+ break;
+ case Atom::BOOL:
+ // xsd:boolean -> pretty boolean literals in Turtle
+ if (atom.get_bool())
+ str = "true";
+ else
+ str = "false";
+ type = librdf_new_uri(world.world(), CUC("http://www.w3.org/2001/XMLSchema#boolean"));
+ break;
+ case Atom::STRING:
+ str = atom.get_string();
+ break;
+ case Atom::BLOB:
+ case Atom::NIL:
+ default:
+ std::cerr << "WARNING: Unserializable Atom!" << std::endl;
+ }
+
+ if (str != "")
+ node = librdf_new_node_from_typed_literal(world.world(), CUC(str.c_str()), NULL, type);
+
+ return Redland::Node(world, node);
+}
+
+
+} // namespace AtomRDF
+} // namespace Raul
+
+#endif // RAUL_ATOM_RDF_HPP
+
diff --git a/raul/Makefile.am b/raul/Makefile.am
index c8f25a2..eeeb792 100644
--- a/raul/Makefile.am
+++ b/raul/Makefile.am
@@ -3,6 +3,8 @@ raulincludedir = $(includedir)/raul
raulinclude_HEADERS = \
Array.hpp \
Atom.hpp \
+ AtomLiblo.hpp \
+ AtomRDF.hpp \
AtomicInt.hpp \
AtomicPtr.hpp \
Command.hpp \
@@ -35,10 +37,6 @@ raulinclude_HEADERS = \
midi_events.h \
types.hpp
-if WITH_LIBLO
-raulinclude_HEADERS += AtomLiblo.hpp
-endif
-
if WITH_LASH
raulinclude_HEADERS += LashClient.hpp LashServerInterface.hpp LashProject.hpp
endif