From aa454620bff8b6c5dcd4e0e379726307ad1918da Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 22 Jan 2007 05:00:29 +0000 Subject: Created Raul namespace. git-svn-id: http://svn.drobilla.net/lad/raul@265 a436a847-0d15-0410-975c-d299462d15a1 --- raul/Atom.h | 11 +++++-- raul/AtomLiblo.h | 10 ++++-- raul/AtomRaptor.h | 11 +++++-- raul/AtomicInt.h | 12 +++++-- raul/AtomicPtr.h | 12 +++++-- raul/Condition.h | 10 ++++-- raul/JackDriver.h | 34 +++++++++++--------- raul/Mutex.h | 10 ++++-- raul/Namespaces.h | 10 ++++-- raul/Path.h | 12 ++++--- raul/Process.h | 6 +++- raul/RDFQuery.h | 12 ++++--- raul/RDFWriter.h | 39 ++++++++++++----------- raul/SRMWQueue.h | 10 ++++-- raul/SRSWQueue.h | 10 ++++-- raul/Semaphore.h | 10 ++++-- raul/SharedPtr.h | 4 +-- raul/Slave.h | 6 +++- raul/Thread.h | 11 +++++-- raul/WeakPtr.h | 2 +- src/JackDriver.cpp | 88 +++++++++++++++++++++++++++------------------------ src/Namespaces.cpp | 11 +++++-- src/Path.cpp | 11 +++++-- src/RDFQuery.cpp | 11 +++++-- src/RDFWriter.cpp | 17 +++++++--- src/Thread.cpp | 11 +++++-- tests/atomic_test.cpp | 14 ++++++++ tests/path_test.cpp | 1 + tests/queue_test.cpp | 3 +- tests/thread_test.cpp | 5 ++- 30 files changed, 271 insertions(+), 143 deletions(-) create mode 100644 tests/atomic_test.cpp diff --git a/raul/Atom.h b/raul/Atom.h index 372cd78..3bfa68f 100644 --- a/raul/Atom.h +++ b/raul/Atom.h @@ -1,11 +1,11 @@ -/* This file is part of Ingen. Copyright (C) 2006 Dave Robillard. +/* This file is part of Raul. Copyright (C) 2007 Dave Robillard. * - * Ingen is free software; you can redistribute it and/or modify it under the + * 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. * - * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY + * 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. * @@ -24,6 +24,8 @@ using std::string; +namespace Raul { + /** An OSC atom (fundamental data types OSC messages are composed of). * @@ -126,4 +128,7 @@ private: }; }; + +} // namespace Raul + #endif // RAUL_ATOM_H diff --git a/raul/AtomLiblo.h b/raul/AtomLiblo.h index 6812dcf..c1c7d60 100644 --- a/raul/AtomLiblo.h +++ b/raul/AtomLiblo.h @@ -1,11 +1,11 @@ -/* This file is part of Ingen. Copyright (C) 2006 Dave Robillard. +/* This file is part of Raul. Copyright (C) 2007 Dave Robillard. * - * Ingen is free software; you can redistribute it and/or modify it under the + * 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. * - * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY + * 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. * @@ -20,6 +20,8 @@ #include #include "raul/Atom.h" +namespace Raul { + /** Support for serializing an Atom to/from liblo messages. * @@ -72,4 +74,6 @@ public: }; +} // namespace Raul + #endif // RAUL_ATOM_LIBLO_H diff --git a/raul/AtomRaptor.h b/raul/AtomRaptor.h index 9323918..87f871f 100644 --- a/raul/AtomRaptor.h +++ b/raul/AtomRaptor.h @@ -1,11 +1,11 @@ -/* This file is part of Ingen. Copyright (C) 2006 Dave Robillard. +/* This file is part of Raul. Copyright (C) 2007 Dave Robillard. * - * Ingen is free software; you can redistribute it and/or modify it under the + * 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. * - * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY + * 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. * @@ -26,6 +26,9 @@ using std::cerr; using std::endl; #define U(x) ((const unsigned char*)(x)) +namespace Raul { + + /** Support for serializing an Atom to/from RDF (via raptor, a part of librdf). * * (Here to prevent a unnecessary raptor dependency for Atom). @@ -96,4 +99,6 @@ public: }; +} // namespace Raul + #endif // RAUL_ATOM_RAPTOR_H diff --git a/raul/AtomicInt.h b/raul/AtomicInt.h index ba8e4b0..2678f31 100644 --- a/raul/AtomicInt.h +++ b/raul/AtomicInt.h @@ -1,11 +1,11 @@ -/* This file is part of Ingen. Copyright (C) 2007 Dave Robillard. +/* This file is part of Raul. Copyright (C) 2007 Dave Robillard. * - * Ingen is free software; you can redistribute it and/or modify it under the + * 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. * - * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY + * 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. * @@ -19,6 +19,9 @@ #include +namespace Raul { + + class AtomicInt { public: @@ -72,4 +75,7 @@ private: volatile int _val; }; + +} // namespace Raul + #endif // RAUL_ATOMIC_INT_H diff --git a/raul/AtomicPtr.h b/raul/AtomicPtr.h index 8209ca6..287fe2c 100644 --- a/raul/AtomicPtr.h +++ b/raul/AtomicPtr.h @@ -1,11 +1,11 @@ -/* This file is part of Ingen. Copyright (C) 2007 Dave Robillard. +/* This file is part of Raul. Copyright (C) 2007 Dave Robillard. * - * Ingen is free software; you can redistribute it and/or modify it under the + * 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. * - * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY + * 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. * @@ -19,6 +19,9 @@ #include +namespace Raul { + + template class AtomicPtr { public: @@ -40,4 +43,7 @@ private: volatile T* _val; }; + +} // namespace Raul + #endif // RAUL_ATOMIC_PTR_H diff --git a/raul/Condition.h b/raul/Condition.h index 5517225..18fb05f 100644 --- a/raul/Condition.h +++ b/raul/Condition.h @@ -1,11 +1,11 @@ -/* This file is part of Ingen. Copyright (C) 2006 Dave Robillard. +/* This file is part of Raul. Copyright (C) 2007 Dave Robillard. * - * Ingen is free software; you can redistribute it and/or modify it under the + * 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. * - * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY + * 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. * @@ -20,6 +20,8 @@ #include #include +namespace Raul { + /** Trivial (zero overhead) wrapper around POSIX Conditions. * @@ -41,5 +43,7 @@ private: }; +} // namespace Raul + #endif // RAUL_CONDITION_H diff --git a/raul/JackDriver.h b/raul/JackDriver.h index b16eeb3..22e2002 100644 --- a/raul/JackDriver.h +++ b/raul/JackDriver.h @@ -24,6 +24,8 @@ using std::string; +namespace Raul { + /** Handles all externally driven functionality, registering ports etc. * @@ -39,29 +41,29 @@ public: void attach(const string& client_name); void detach(); - bool is_attached() const { return (m_client != NULL); } - bool is_realtime() const { return m_client && jack_is_realtime(m_client); } + bool is_attached() const { return (_client != NULL); } + bool is_realtime() const { return _client && jack_is_realtime(_client); } - void start_transport() { jack_transport_start(m_client); } - void stop_transport() { jack_transport_stop(m_client); } + void start_transport() { jack_transport_start(_client); } + void stop_transport() { jack_transport_stop(_client); } void rewind_transport() { jack_position_t zero; zero.frame = 0; zero.valid = (jack_position_bits_t)0; - jack_transport_reposition(m_client, &zero); + jack_transport_reposition(_client, &zero); } jack_nframes_t buffer_size(); bool set_buffer_size(jack_nframes_t size); - inline float sample_rate() { return jack_get_sample_rate(m_client); } + inline float sample_rate() { return jack_get_sample_rate(_client); } - inline size_t xruns() { return m_xruns; } + inline size_t xruns() { return _xruns; } void reset_xruns(); - inline float max_delay() { return jack_get_max_delayed_usecs(m_client); } - inline void reset_delay() { jack_reset_max_delayed_usecs(m_client); } + inline float max_delay() { return jack_get_max_delayed_usecs(_client); } + inline void reset_delay() { jack_reset_max_delayed_usecs(_client); } protected: /** Process callback. Derived classes should do all audio processing here. */ @@ -94,14 +96,16 @@ private: static int jack_xrun_cb(void* me); static void jack_shutdown_cb(void* me); - jack_client_t* m_client; + jack_client_t* _client; - bool m_is_activated; - jack_position_t m_last_pos; - jack_nframes_t m_buffer_size; - size_t m_xruns; - float m_xrun_delay; + bool _is_activated; + jack_position_t _last_pos; + jack_nframes_t _buffer_size; + size_t _xruns; + float _xrun_delay; }; +} // namespace Raul + #endif // RAUL_JACKDRIVER_H diff --git a/raul/Mutex.h b/raul/Mutex.h index bf16d3c..8077ba9 100644 --- a/raul/Mutex.h +++ b/raul/Mutex.h @@ -1,11 +1,11 @@ -/* This file is part of Ingen. Copyright (C) 2006 Dave Robillard. +/* This file is part of Raul. Copyright (C) 2007 Dave Robillard. * - * Ingen is free software; you can redistribute it and/or modify it under the + * 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. * - * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY + * 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. * @@ -20,6 +20,8 @@ #include #include +namespace Raul { + /** Trivial (zero overhead) wrapper around POSIX Mutexes. * @@ -41,4 +43,6 @@ private: }; +} // namespace Raul + #endif // RAUL_MUTEX_H diff --git a/raul/Namespaces.h b/raul/Namespaces.h index d28089f..1de95f8 100644 --- a/raul/Namespaces.h +++ b/raul/Namespaces.h @@ -1,11 +1,11 @@ -/* This file is part of Ingen. Copyright (C) 2006 Dave Robillard. +/* This file is part of Raul. Copyright (C) 2007 Dave Robillard. * - * Ingen is free software; you can redistribute it and/or modify it under the + * 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. * - * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY + * 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. * @@ -20,6 +20,8 @@ #include #include +namespace Raul { + /** Collection of RDF namespaces with prefixes. */ @@ -29,4 +31,6 @@ public: }; +} // namespace Raul + #endif // RAUL_NAMESPACES_H diff --git a/raul/Path.h b/raul/Path.h index 200d05e..e68d507 100644 --- a/raul/Path.h +++ b/raul/Path.h @@ -1,11 +1,11 @@ -/* This file is part of Ingen. Copyright (C) 2006-2007 Dave Robillard. +/* This file is part of Raul. Copyright (C) 2007-2007 Dave Robillard. * - * Ingen is free software; you can redistribute it and/or modify it under the + * 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. * - * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY + * 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. * @@ -22,6 +22,8 @@ #include using std::string; +namespace Raul { + /** Simple wrapper around standard string with useful path-specific methods. * @@ -118,6 +120,8 @@ public: return (*this) + "/"; } }; - + + +} // namespace Raul #endif // RAUL_PATH_H diff --git a/raul/Process.h b/raul/Process.h index a8cf043..5504440 100644 --- a/raul/Process.h +++ b/raul/Process.h @@ -1,4 +1,4 @@ -/* This file is part of Raul. Copyright (C) 2006 Dave Robillard. +/* This file is part of Raul. Copyright (C) 2007 Dave Robillard. * * 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 @@ -22,6 +22,8 @@ #include #include +namespace Raul { + /** A child process. * @@ -82,4 +84,6 @@ private: }; +} // namespace Raul + #endif // RAUL_PROCESS_H diff --git a/raul/RDFQuery.h b/raul/RDFQuery.h index 8b0f362..b0709b2 100644 --- a/raul/RDFQuery.h +++ b/raul/RDFQuery.h @@ -1,11 +1,11 @@ -/* This file is part of Ingen. Copyright (C) 2006 Dave Robillard. +/* This file is part of Raul. Copyright (C) 2007 Dave Robillard. * - * Ingen is free software; you can redistribute it and/or modify it under the + * 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. * - * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY + * 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. * @@ -22,10 +22,12 @@ #include #include "raul/Namespaces.h" +namespace Raul { + /** Pretty wrapper for a SPARQL query. * - * Automatically handles things like prepending prefixes, etc. Ingen specific. + * Automatically handles things like prepending prefixes, etc. Raul specific. */ class RDFQuery { public: @@ -67,5 +69,7 @@ private: }; +} // namespace Raul + #endif // RAUL_RDFQUERY_H diff --git a/raul/RDFWriter.h b/raul/RDFWriter.h index c67645e..f2dfadd 100644 --- a/raul/RDFWriter.h +++ b/raul/RDFWriter.h @@ -1,11 +1,11 @@ -/* This file is part of Ingen. Copyright (C) 2006 Dave Robillard. +/* This file is part of Raul. Copyright (C) 2007 Dave Robillard. * - * Ingen is free software; you can redistribute it and/or modify it under the + * 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. * - * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY + * 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. * @@ -19,24 +19,25 @@ #include #include -#include #include +#include "raul/Namespaces.h" #include "raul/Atom.h" -using std::string; using std::map; + +namespace Raul { class RdfId { public: enum Type { ANONYMOUS, RESOURCE }; - RdfId(Type t, const string& s) : _type(t), _string(s) {} + RdfId(Type t, const std::string& s) : _type(t), _string(s) {} - Type type() const { return _type; } - const string& to_string() const { return _string; } + Type type() const { return _type; } + const std::string& to_string() const { return _string; } private: - Type _type; - string _string; ///< URI or blank node ID, depending on _type + Type _type; + std::string _string; ///< URI or blank node ID, depending on _type }; @@ -44,12 +45,12 @@ class RDFWriter { public: RDFWriter(); - void add_prefix(const string& prefix, const string& uri); - string expand_uri(const string& uri); + void add_prefix(const std::string& prefix, const std::string& uri); + std::string expand_uri(const std::string& uri); - void start_to_filename(const string& filename) throw (std::logic_error); - void start_to_string() throw (std::logic_error); - string finish() throw (std::logic_error); + void start_to_filename(const std::string& filename) throw (std::logic_error); + void start_to_string() throw (std::logic_error); + std::string finish() throw (std::logic_error); bool serialization_in_progress() { return (_serializer != NULL); } @@ -64,10 +65,12 @@ public: private: void setup_prefixes(); - raptor_serializer* _serializer; - unsigned char* _string_output; - map _prefixes; + raptor_serializer* _serializer; + unsigned char* _string_output; + Namespaces _prefixes; }; +} // namespace Raul + #endif // RDFWRITER_H diff --git a/raul/SRMWQueue.h b/raul/SRMWQueue.h index 2a4955c..5b7273a 100644 --- a/raul/SRMWQueue.h +++ b/raul/SRMWQueue.h @@ -1,11 +1,11 @@ -/* This file is part of Ingen. Copyright (C) 2006 Dave Robillard. +/* This file is part of Raul. Copyright (C) 2007 Dave Robillard. * - * Ingen is free software; you can redistribute it and/or modify it under the + * 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. * - * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY + * 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. * @@ -25,6 +25,8 @@ #include using namespace std; +namespace Raul { + /** Realtime-safe single-reader multi-writer queue (aka lock-free ringbuffer) * @@ -198,4 +200,6 @@ SRMWQueue::pop() } +} // namespace Raul + #endif // RAUL_SRMW_QUEUE_H diff --git a/raul/SRSWQueue.h b/raul/SRSWQueue.h index e7dd60d..b23f2f7 100644 --- a/raul/SRSWQueue.h +++ b/raul/SRSWQueue.h @@ -1,11 +1,11 @@ -/* This file is part of Ingen. Copyright (C) 2006 Dave Robillard. +/* This file is part of Raul. Copyright (C) 2007 Dave Robillard. * - * Ingen is free software; you can redistribute it and/or modify it under the + * 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. * - * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY + * 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. * @@ -22,6 +22,8 @@ #include #include "raul/AtomicInt.h" +namespace Raul { + /** Realtime-safe single-reader single-writer queue (aka lock-free ringbuffer) * @@ -149,4 +151,6 @@ SRSWQueue::pop() } +} // namespace Raul + #endif // RAUL_SRSW_QUEUE_H diff --git a/raul/Semaphore.h b/raul/Semaphore.h index bd06b65..d5195ba 100644 --- a/raul/Semaphore.h +++ b/raul/Semaphore.h @@ -1,11 +1,11 @@ -/* This file is part of Ingen. Copyright (C) 2006 Dave Robillard. +/* This file is part of Raul. Copyright (C) 2007 Dave Robillard. * - * Ingen is free software; you can redistribute it and/or modify it under the + * 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. * - * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY + * 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. * @@ -20,6 +20,8 @@ #include #include +namespace Raul { + /** Trivial wrapper around POSIX semaphores (zero memory overhead). * @@ -63,4 +65,6 @@ private: }; +} // namespace Raul + #endif // RAUL_SEMAPHORE_H diff --git a/raul/SharedPtr.h b/raul/SharedPtr.h index 89600a9..e5381b6 100644 --- a/raul/SharedPtr.h +++ b/raul/SharedPtr.h @@ -1,5 +1,5 @@ /* A Reference Counting Smart Pointer. - * Copyright (C) 2006 Dave Robillard. + * Copyright (C) 2007 Dave Robillard. * * This 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 @@ -53,7 +53,7 @@ namespace boost { #ifdef BOOST_AC_USE_PTHREADS #error "Boost is using mutex locking for pointer reference counting." -#error "This is VERY slow. Please report your platform." +#error "This is VERY slow. Please report your platform to dave@codeson.net" #endif #define SharedPtr boost::shared_ptr diff --git a/raul/Slave.h b/raul/Slave.h index 8f20140..e80fbeb 100644 --- a/raul/Slave.h +++ b/raul/Slave.h @@ -1,4 +1,4 @@ -/* This file is part of Raul. Copyright (C) 2006 Dave Robillard. +/* This file is part of Raul. Copyright (C) 2007 Dave Robillard. * * 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 @@ -21,6 +21,8 @@ #include "raul/Semaphore.h" #include "raul/Thread.h" +namespace Raul { + /** Thread driven by (realtime safe) signals. * @@ -59,4 +61,6 @@ private: }; +} // namespace Raul + #endif // RAUL_SLAVE_H diff --git a/raul/Thread.h b/raul/Thread.h index 2a7a321..694d463 100644 --- a/raul/Thread.h +++ b/raul/Thread.h @@ -1,11 +1,11 @@ -/* This file is part of Ingen. Copyright (C) 2006 Dave Robillard. +/* This file is part of Raul. Copyright (C) 2007 Dave Robillard. * - * Ingen is free software; you can redistribute it and/or modify it under the + * 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. * - * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY + * 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. * @@ -22,6 +22,8 @@ #include #include +namespace Raul { + /** Abstract base class for a thread. * @@ -106,6 +108,7 @@ protected: Thread(const std::string& name="") : _context(0), _name(name), _pthread_exists(false) { pthread_once(&_thread_key_once, thread_key_alloc); + pthread_setspecific(_thread_key, this); } /** Must be called from thread */ @@ -151,4 +154,6 @@ private: }; +} // namespace Raul + #endif // RAUL_THREAD_H diff --git a/raul/WeakPtr.h b/raul/WeakPtr.h index 3523d25..1793608 100644 --- a/raul/WeakPtr.h +++ b/raul/WeakPtr.h @@ -1,5 +1,5 @@ /* A "weak" pointer to a resource owned by a shared pointer. - * Copyright (C) 2006 Dave Robillard. + * Copyright (C) 2007 Dave Robillard. * * This 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 diff --git a/src/JackDriver.cpp b/src/JackDriver.cpp index cd96ab7..a8ece4a 100644 --- a/src/JackDriver.cpp +++ b/src/JackDriver.cpp @@ -26,16 +26,17 @@ using std::cerr; using std::endl; using std::string; +namespace Raul { + JackDriver::JackDriver() -//: m_app(app) -: m_client(NULL) -, m_is_activated(false) -, m_xruns(0) -, m_xrun_delay(0) +: _client(NULL) +, _is_activated(false) +, _xruns(0) +, _xrun_delay(0) { - m_last_pos.frame = 0; - m_last_pos.valid = (jack_position_bits_t)0; + _last_pos.frame = 0; + _last_pos.valid = (jack_position_bits_t)0; } @@ -51,33 +52,33 @@ void JackDriver::attach(const string& client_name) { // Already connected - if (m_client) + if (_client) return; jack_set_error_function(error_cb); - m_client = jack_client_open(client_name.c_str(), JackNullOption, NULL); - if (m_client == NULL) { - //m_app->status_message("[JACK] Unable to create client"); - m_is_activated = false; + _client = jack_client_open(client_name.c_str(), JackNullOption, NULL); + if (_client == NULL) { + //_app->status_message("[JACK] Unable to create client"); + _is_activated = false; } else { jack_set_error_function(error_cb); - jack_on_shutdown(m_client, jack_shutdown_cb, this); - jack_set_port_registration_callback(m_client, jack_port_registration_cb, this); - jack_set_graph_order_callback(m_client, jack_graph_order_cb, this); - jack_set_buffer_size_callback(m_client, jack_buffer_size_cb, this); - jack_set_xrun_callback(m_client, jack_xrun_cb, this); + jack_on_shutdown(_client, jack_shutdown_cb, this); + jack_set_port_registration_callback(_client, jack_port_registration_cb, this); + jack_set_graph_order_callback(_client, jack_graph_order_cb, this); + jack_set_buffer_size_callback(_client, jack_buffer_size_cb, this); + jack_set_xrun_callback(_client, jack_xrun_cb, this); - //m_is_dirty = true; - m_buffer_size = jack_get_buffer_size(m_client); + //_is_dirty = true; + _buffer_size = jack_get_buffer_size(_client); - if (!jack_activate(m_client)) { - m_is_activated = true; + if (!jack_activate(_client)) { + _is_activated = true; //signal_attached.emit(); - //m_app->status_message("[JACK] Attached"); + //_app->status_message("[JACK] Attached"); } else { - //m_app->status_message("[JACK] ERROR: Failed to attach"); - m_is_activated = false; + //_app->status_message("[JACK] ERROR: Failed to attach"); + _is_activated = false; } } } @@ -86,11 +87,11 @@ JackDriver::attach(const string& client_name) void JackDriver::detach() { - if (m_client) { - jack_deactivate(m_client); - jack_client_close(m_client); - m_client = NULL; - m_is_activated = false; + if (_client) { + jack_deactivate(_client); + jack_client_close(_client); + _client = NULL; + _is_activated = false; //signal_detached.emit(); } } @@ -124,7 +125,7 @@ JackDriver::jack_buffer_size_cb(jack_nframes_t buffer_size, void* jack_driver) me->reset_xruns(); me->reset_delay(); me->on_buffer_size_changed(buffer_size); - me->m_buffer_size = buffer_size; + me->_buffer_size = buffer_size; return 0; } @@ -137,8 +138,8 @@ JackDriver::jack_xrun_cb(void* jack_driver) assert(me); - me->m_xruns++; - me->m_xrun_delay = jack_get_xrun_delayed_usecs(me->m_client); + me->_xruns++; + me->_xrun_delay = jack_get_xrun_delayed_usecs(me->_client); me->reset_delay(); me->on_xrun(); @@ -158,7 +159,7 @@ JackDriver::jack_shutdown_cb(void* jack_driver) me->on_shutdown(); - me->m_client = NULL; + me->_client = NULL; } @@ -172,18 +173,18 @@ JackDriver::error_cb(const char* msg) jack_nframes_t JackDriver::buffer_size() { - if (m_is_activated) - return m_buffer_size; + if (_is_activated) + return _buffer_size; else - return jack_get_buffer_size(m_client); + return jack_get_buffer_size(_client); } void JackDriver::reset_xruns() { - m_xruns = 0; - m_xrun_delay = 0; + _xruns = 0; + _xrun_delay = 0; } @@ -194,16 +195,19 @@ JackDriver::set_buffer_size(jack_nframes_t size) return true; } - if (!m_client) { - m_buffer_size = size; + if (!_client) { + _buffer_size = size; return true; } - if (jack_set_buffer_size(m_client, size)) { - //m_app->status_message("[JACK] ERROR: Unable to set buffer size"); + if (jack_set_buffer_size(_client, size)) { + //_app->status_message("[JACK] ERROR: Unable to set buffer size"); return false; } else { return true; } } + +} // namespace Raul + diff --git a/src/Namespaces.cpp b/src/Namespaces.cpp index d45d259..379644d 100644 --- a/src/Namespaces.cpp +++ b/src/Namespaces.cpp @@ -1,11 +1,11 @@ -/* This file is part of Ingen. Copyright (C) 2006 Dave Robillard. +/* This file is part of Raul. Copyright (C) 2007 Dave Robillard. * - * Ingen is free software; you can redistribute it and/or modify it under the + * 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. * - * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY + * 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. * @@ -16,6 +16,8 @@ #include "raul/Namespaces.h" +namespace Raul { + /** Create a prefixed qname from @a uri, if possible. * @@ -35,3 +37,6 @@ Namespaces::qualify(std::string uri) return uri; } + +} // namespace Raul + diff --git a/src/Path.cpp b/src/Path.cpp index 59e18dd..07c5279 100644 --- a/src/Path.cpp +++ b/src/Path.cpp @@ -1,11 +1,11 @@ -/* This file is part of Ingen. Copyright (C) 2006-2007 Dave Robillard. +/* This file is part of Raul. Copyright (C) 2007-2007 Dave Robillard. * - * Ingen is free software; you can redistribute it and/or modify it under the + * 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. * - * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY + * 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. * @@ -16,6 +16,8 @@ #include "raul/Path.h" +namespace Raul { + bool Path::is_valid(const std::basic_string& path) @@ -169,3 +171,6 @@ Path::is_parent_of(const Path& child) const return child.is_child_of(*this); } + +} // namespace Raul + diff --git a/src/RDFQuery.cpp b/src/RDFQuery.cpp index f92ca89..471723f 100644 --- a/src/RDFQuery.cpp +++ b/src/RDFQuery.cpp @@ -1,11 +1,11 @@ -/* This file is part of Ingen. Copyright (C) 2006 Dave Robillard. +/* This file is part of Raul. Copyright (C) 2007 Dave Robillard. * - * Ingen is free software; you can redistribute it and/or modify it under the + * 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. * - * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY + * 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. * @@ -19,6 +19,8 @@ #include #include "raul/RDFQuery.h" +namespace Raul { + RDFQuery::Results RDFQuery::run(const Glib::ustring base_uri_str) const @@ -69,3 +71,6 @@ RDFQuery::run(const Glib::ustring base_uri_str) const return result; } + +} // namespace Raul + diff --git a/src/RDFWriter.cpp b/src/RDFWriter.cpp index 972286d..66b166a 100644 --- a/src/RDFWriter.cpp +++ b/src/RDFWriter.cpp @@ -1,11 +1,11 @@ -/* This file is part of Ingen. Copyright (C) 2006 Dave Robillard. +/* This file is part of Raul. Copyright (C) 2007 Dave Robillard. * - * Ingen is free software; you can redistribute it and/or modify it under the + * 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. * - * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY + * 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. * @@ -19,6 +19,9 @@ #define U(x) ((const unsigned char*)(x)) +namespace Raul { + + //static const char* const RDF_LANG = "rdfxml-abbrev"; static const char* const RDF_LANG = "turtle"; @@ -44,7 +47,7 @@ RDFWriter::setup_prefixes() { assert(_serializer); - for (map::const_iterator i = _prefixes.begin(); i != _prefixes.end(); ++i) { + for (Namespaces::const_iterator i = _prefixes.begin(); i != _prefixes.end(); ++i) { raptor_serialize_set_namespace(_serializer, raptor_new_uri(U(i->second.c_str())), U(i->first.c_str())); } @@ -56,7 +59,7 @@ RDFWriter::setup_prefixes() string RDFWriter::expand_uri(const string& uri) { - for (map::const_iterator i = _prefixes.begin(); i != _prefixes.end(); ++i) + for (Namespaces::const_iterator i = _prefixes.begin(); i != _prefixes.end(); ++i) if (uri.substr(0, i->first.length()+1) == i->first + ":") return i->second + uri.substr(i->first.length()+1); @@ -216,3 +219,7 @@ RDFWriter::write(const RdfId& subject, raptor_free_uri((raptor_uri*)triple.predicate); } + + +} // namespace Raul + diff --git a/src/Thread.cpp b/src/Thread.cpp index 34ba0f9..cc024b0 100644 --- a/src/Thread.cpp +++ b/src/Thread.cpp @@ -1,11 +1,11 @@ -/* This file is part of Ingen. Copyright (C) 2007 Dave Robillard. +/* This file is part of Raul. Copyright (C) 2007 Dave Robillard. * - * Ingen is free software; you can redistribute it and/or modify it under the + * 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. * - * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY + * 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. * @@ -16,6 +16,11 @@ #include "raul/Thread.h" +namespace Raul { + /* Thread-specific data key (once-only initialized) */ pthread_once_t Thread::_thread_key_once = PTHREAD_ONCE_INIT; pthread_key_t Thread::_thread_key; + +} // namespace Raul + diff --git a/tests/atomic_test.cpp b/tests/atomic_test.cpp new file mode 100644 index 0000000..c10677a --- /dev/null +++ b/tests/atomic_test.cpp @@ -0,0 +1,14 @@ +#include +#include +#include + +using namespace std; +using namespace Raul; + +int +main() +{ + cout << "Well, at least I compiled; that's gotta count for something eh?" << endl; + + return 0; +} diff --git a/tests/path_test.cpp b/tests/path_test.cpp index 911b760..280f968 100644 --- a/tests/path_test.cpp +++ b/tests/path_test.cpp @@ -2,6 +2,7 @@ #include using namespace std; +using namespace Raul; int main() diff --git a/tests/queue_test.cpp b/tests/queue_test.cpp index d299995..dc9928d 100644 --- a/tests/queue_test.cpp +++ b/tests/queue_test.cpp @@ -3,7 +3,8 @@ #include "raul/SRSWQueue.h" #include "raul/SRMWQueue.h" -using std::string; using std::cerr; using std::cout; using std::endl; +using namespace std; +using namespace Raul; int main() diff --git a/tests/thread_test.cpp b/tests/thread_test.cpp index 7a4d875..ef3ad53 100644 --- a/tests/thread_test.cpp +++ b/tests/thread_test.cpp @@ -2,6 +2,7 @@ #include using namespace std; +using namespace Raul; int main() @@ -9,7 +10,9 @@ main() Thread& this_thread = Thread::get(); this_thread.set_name("Main"); - cerr << "Thread name: " << Thread::get().name() << endl; + cout << "Thread name should be Main" << endl; + + cout << "Thread name: " << Thread::get().name() << endl; return 0; } -- cgit v1.2.1