From ca32b189529ffc7c1d42af85f005dea54189218f Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 20 Jan 2007 02:35:34 +0000 Subject: Added Machina. Moved some Jack and RDF functionality down to RAUL from Ingen, for use by Machina. git-svn-id: http://svn.drobilla.net/lad/raul@263 a436a847-0d15-0410-975c-d299462d15a1 --- Namespaces.cpp | 43 ----------------------------- RDFQuery.cpp | 80 ------------------------------------------------------ configure.ac | 29 ++++++++++++++++++-- raul/JackDriver.h | 12 ++++---- raul/Namespaces.h | 6 ---- raul/RDFQuery.h | 6 ---- src/JackDriver.cpp | 4 +-- src/Makefile.am | 18 ++++++++---- src/Namespaces.cpp | 37 +++++++++++++++++++++++++ src/RDFQuery.cpp | 71 ++++++++++++++++++++++++++++++++++++++++++++++++ tests/Makefile.am | 10 ++++--- 11 files changed, 159 insertions(+), 157 deletions(-) delete mode 100644 Namespaces.cpp delete mode 100644 RDFQuery.cpp create mode 100644 src/Namespaces.cpp create mode 100644 src/RDFQuery.cpp diff --git a/Namespaces.cpp b/Namespaces.cpp deleted file mode 100644 index 545e1db..0000000 --- a/Namespaces.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* This file is part of Ingen. Copyright (C) 2006 Dave 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 "Namespaces.h" - -namespace Ingen { -namespace Client { - - -/** Create a prefixed qname from @a uri, if possible. - * - * If @a uri can not be qualified with the namespaces currently in this - * Namespaces, @a uri will be returned unmodified. - */ -std::string -Namespaces::qualify(std::string uri) -{ - for (iterator i = begin(); i != end(); ++i) { - size_t ns_len = i->second.length(); - - if (uri.substr(0, ns_len) == i->second) - return i->first + ":" + uri.substr(ns_len); - } - - return uri; -} - - -} // namespace Client -} // namespace Ingen diff --git a/RDFQuery.cpp b/RDFQuery.cpp deleted file mode 100644 index 196868b..0000000 --- a/RDFQuery.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/* This file is part of Ingen. Copyright (C) 2006 Dave 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 -#include -#include -#include "RDFQuery.h" - -#include -using std::cerr; using std::endl; - -namespace Ingen { -namespace Client { - - -RDFQuery::Results -RDFQuery::run(const Glib::ustring base_uri_str) const -{ - Results result; - - rasqal_init(); - - rasqal_query *rq = rasqal_new_query("sparql", NULL); - - raptor_uri* base_uri = NULL; - if (base_uri_str != "") - base_uri = raptor_new_uri((const unsigned char*)base_uri_str.c_str()); - rasqal_query_prepare(rq, (unsigned char*)_query.c_str(), base_uri); - - rasqal_query_results* results = rasqal_query_execute(rq); - assert(results); - - while (!rasqal_query_results_finished(results)) { - - Bindings bindings; - - for (int i=0; i < rasqal_query_results_get_bindings_count(results); i++) { - const unsigned char* rname = rasqal_query_results_get_binding_name(results, i); - rasqal_literal* rvalue = rasqal_query_results_get_binding_value(results, i); - Glib::ustring name((const char*)rname); - - const unsigned char* str = rasqal_literal_as_string(rvalue); - - if (str) { - Glib::ustring value((const char*)str); - bindings.insert(std::make_pair(name, value)); - } - } - - result.push_back(bindings); - rasqal_query_results_next(results); - } - - rasqal_free_query_results(results); - rasqal_free_query(rq); - - if (base_uri) - raptor_free_uri(base_uri); - - rasqal_finish(); - - return result; -} - - -} // namespace Client -} // namespace Ingen diff --git a/configure.ac b/configure.ac index c0eaf8c..06d3560 100644 --- a/configure.ac +++ b/configure.ac @@ -50,6 +50,9 @@ AC_ARG_ENABLE(unit-tests, [build_unit_tests="$enableval"]) AM_CONDITIONAL(BUILD_TESTS, [test "$build_unit_tests" = "yes"]) +# Check for glibmm +PKG_CHECK_MODULES(GLIBMM, glibmm-2.4) + build_smart_pointers="yes" AC_ARG_ENABLE(smart_pointers, [AS_HELP_STRING(--enable-smart_pointers, [Include smart pointers - requires boost (yes)])], @@ -69,6 +72,15 @@ if test "$build_smart_pointers" = "yes"; then fi AM_CONDITIONAL(WITH_BOOST, [test "$build_smart_pointers" = "yes"]) +build_jack="yes" +AC_ARG_ENABLE(jack, + [AS_HELP_STRING(--enable-jack, [Include JACK audio/midi support (yes)])], + [ if test x$enable_jack = xno ; then build_jack=no ; fi ]) +if test "$build_jack" = "yes"; then + PKG_CHECK_MODULES(JACK, jack >= 0.102.20, [], + AC_MSG_ERROR([JACK support requires jack (>= 0.102.20)])) +fi +AM_CONDITIONAL(WITH_JACK, [test "$build_jack" = "yes"]) build_raptor="yes" AC_ARG_ENABLE(raptor, @@ -80,6 +92,15 @@ if test "$build_raptor" = "yes"; then fi AM_CONDITIONAL(WITH_RAPTOR, [test "$build_raptor" = "yes"]) +build_rasqal="yes" +AC_ARG_ENABLE(rasqal, + [AS_HELP_STRING(--enable-rasqal, [Include Rasqal (RDF Querying) support (yes)])], + [ if test x$enable_rasqal = xno ; then build_rasqal=no ; fi ]) +if test "$build_rasqal" = "yes"; then + PKG_CHECK_MODULES(RASQAL, rasqal >= 0.9.11, [], + AC_MSG_ERROR([RDF query support requires rasqal (>= 0.9.11)])) +fi +AM_CONDITIONAL(WITH_RASQAL, [test "$build_rasqal" = "yes"]) build_liblo="yes" AC_ARG_ENABLE(liblo, @@ -107,9 +128,11 @@ AC_MSG_RESULT([Raul build configuration:]) AC_MSG_RESULT([]) AC_MSG_RESULT([Building unit tests: $build_unit_tests]) AC_MSG_RESULT([]) -AC_MSG_RESULT([OSC supprt: $build_liblo]) -AC_MSG_RESULT([RDF supprt: $build_raptor]) -AC_MSG_RESULT([Smart Pointers: $build_smart_pointers]) +AC_MSG_RESULT([OSC (Liblo) support: $build_liblo]) +AC_MSG_RESULT([RDF Serialization (Raptor) support: $build_raptor]) +AC_MSG_RESULT([RDF Querying (Rasqal) support: $build_rasqal]) +AC_MSG_RESULT([Jack support: $build_jack]) +AC_MSG_RESULT([Smart Pointers (Boost): $build_smart_pointers]) AC_MSG_RESULT([**********************************************************************]) AC_MSG_RESULT([]) diff --git a/raul/JackDriver.h b/raul/JackDriver.h index 52e22cd..b16eeb3 100644 --- a/raul/JackDriver.h +++ b/raul/JackDriver.h @@ -65,7 +65,7 @@ public: protected: /** Process callback. Derived classes should do all audio processing here. */ - virtual void on_process(jack_nframes_t nframes) {} + virtual void on_process(jack_nframes_t /*nframes*/) {} /** Graph order change callback. */ virtual void on_graph_order_changed() {} @@ -74,11 +74,11 @@ protected: * At the time this is called, buffer_size() will still return the old * size. Immediately afterwards, it will be set to the new value. */ - virtual void on_buffer_size_changed(jack_nframes_t size) {} + virtual void on_buffer_size_changed(jack_nframes_t /*size*/) {} - virtual void on_xrun() {} - virtual void on_shutdown() {} - virtual void on_error() {} + virtual void on_xrun() {} + virtual void on_shutdown() {} + virtual void on_error() {} private: @@ -88,8 +88,6 @@ private: void update_time(); - - static void jack_port_registration_cb(jack_port_id_t port_id, int registered, void* me); static int jack_graph_order_cb(void* me); static int jack_buffer_size_cb(jack_nframes_t buffer_size, void* me); diff --git a/raul/Namespaces.h b/raul/Namespaces.h index ab2c45a..d28089f 100644 --- a/raul/Namespaces.h +++ b/raul/Namespaces.h @@ -20,9 +20,6 @@ #include #include -namespace Ingen { -namespace Client { - /** Collection of RDF namespaces with prefixes. */ @@ -32,7 +29,4 @@ public: }; -} // namespace Client -} // namespace Ingen - #endif // RAUL_NAMESPACES_H diff --git a/raul/RDFQuery.h b/raul/RDFQuery.h index 5e972ca..8b0f362 100644 --- a/raul/RDFQuery.h +++ b/raul/RDFQuery.h @@ -22,9 +22,6 @@ #include #include "raul/Namespaces.h" -namespace Ingen { -namespace Client { - /** Pretty wrapper for a SPARQL query. * @@ -70,8 +67,5 @@ private: }; -} // namespace Client -} // namespace Ingen - #endif // RAUL_RDFQUERY_H diff --git a/src/JackDriver.cpp b/src/JackDriver.cpp index 0bbc24b..cd96ab7 100644 --- a/src/JackDriver.cpp +++ b/src/JackDriver.cpp @@ -97,9 +97,9 @@ JackDriver::detach() void -JackDriver::jack_port_registration_cb(jack_port_id_t port_id, int registered, void* jack_driver) +JackDriver::jack_port_registration_cb(jack_port_id_t /*port_id*/, int /*registered*/, void* /*jack_driver*/) { - /* shrug. */ + /* whatever. */ } diff --git a/src/Makefile.am b/src/Makefile.am index d0cef87..1e9f60d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,16 +1,22 @@ -AM_CXXFLAGS = -I$(top_srcdir) +AM_CXXFLAGS = -I$(top_srcdir) @RAPTOR_CFLAGS@ @RASQAL_CFLAGS@ @GLIBMM_CFLAGS@ @JACK_CFLAGS@ -libraul_la_CFLAGS = @RAPTOR_CFLAGS@ -libraul_la_LIBADD = @RAPTOR_LIBS@ +libraul_la_LIBADD = @RAPTOR_LIBS@ @RASQAL_LIBS@ @GLIBMM_LIBS@ @JACK_LIBS@ lib_LTLIBRARIES = libraul.la libraul_la_SOURCES = \ Thread.cpp \ Path.cpp \ - RDFWriter.cpp \ - JackDriver.cpp \ - RDFQuery.cpp \ Namespaces.cpp +if WITH_RAPTOR +libraul_la_SOURCES += RDFWriter.cpp +endif +if WITH_RASQAL +libraul_la_SOURCES += RDFQuery.cpp +endif + +if WITH_JACK +libraul_la_SOURCES += JackDriver.cpp +endif diff --git a/src/Namespaces.cpp b/src/Namespaces.cpp new file mode 100644 index 0000000..d45d259 --- /dev/null +++ b/src/Namespaces.cpp @@ -0,0 +1,37 @@ +/* This file is part of Ingen. Copyright (C) 2006 Dave 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/Namespaces.h" + + +/** Create a prefixed qname from @a uri, if possible. + * + * If @a uri can not be qualified with the namespaces currently in this + * Namespaces, @a uri will be returned unmodified. + */ +std::string +Namespaces::qualify(std::string uri) +{ + for (iterator i = begin(); i != end(); ++i) { + size_t ns_len = i->second.length(); + + if (uri.substr(0, ns_len) == i->second) + return i->first + ":" + uri.substr(ns_len); + } + + return uri; +} + diff --git a/src/RDFQuery.cpp b/src/RDFQuery.cpp new file mode 100644 index 0000000..f92ca89 --- /dev/null +++ b/src/RDFQuery.cpp @@ -0,0 +1,71 @@ +/* This file is part of Ingen. Copyright (C) 2006 Dave 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 +#include +#include +#include "raul/RDFQuery.h" + + +RDFQuery::Results +RDFQuery::run(const Glib::ustring base_uri_str) const +{ + Results result; + + rasqal_init(); + + rasqal_query *rq = rasqal_new_query("sparql", NULL); + + raptor_uri* base_uri = NULL; + if (base_uri_str != "") + base_uri = raptor_new_uri((const unsigned char*)base_uri_str.c_str()); + rasqal_query_prepare(rq, (unsigned char*)_query.c_str(), base_uri); + + rasqal_query_results* results = rasqal_query_execute(rq); + assert(results); + + while (!rasqal_query_results_finished(results)) { + + Bindings bindings; + + for (int i=0; i < rasqal_query_results_get_bindings_count(results); i++) { + const unsigned char* rname = rasqal_query_results_get_binding_name(results, i); + rasqal_literal* rvalue = rasqal_query_results_get_binding_value(results, i); + Glib::ustring name((const char*)rname); + + const unsigned char* str = rasqal_literal_as_string(rvalue); + + if (str) { + Glib::ustring value((const char*)str); + bindings.insert(std::make_pair(name, value)); + } + } + + result.push_back(bindings); + rasqal_query_results_next(results); + } + + rasqal_free_query_results(results); + rasqal_free_query(rq); + + if (base_uri) + raptor_free_uri(base_uri); + + rasqal_finish(); + + return result; +} + diff --git a/tests/Makefile.am b/tests/Makefile.am index 6cb5a59..20209d3 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,11 +1,13 @@ if BUILD_TESTS -AM_CXXFLAGS = -I.. -lpthread +AM_CXXFLAGS = -I.. -lpthread @RASQAL_CFLAGS@ +ALL_LIBS = @RASQAL_LIBS@ ../src/libraul.la + bin_PROGRAMS = path_test thread_test queue_test -thread_test_LDADD = ../src/libraul.la -path_test_LDADD = ../src/libraul.la -queue_test_LDADD = ../src/libraul.la +thread_test_LDADD = $(ALL_LIBS) +path_test_LDADD = $(ALL_LIBS) +queue_test_LDADD = $(ALL_LIBS) path_test_SOURCES = path_test.cpp thread_test_SOURCES = thread_test.cpp -- cgit v1.2.1