summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-05-20 00:33:22 +0000
committerDavid Robillard <d@drobilla.net>2011-05-20 00:33:22 +0000
commitbed446e569b815ebb81e8866579a8abcda77358a (patch)
tree325e59b693f8d7b10a7036bf7172701d91c8e4cd
parent3be36824924e886802b495c2131b412277aa5421 (diff)
downloadraul-bed446e569b815ebb81e8866579a8abcda77358a.tar.gz
raul-bed446e569b815ebb81e8866579a8abcda77358a.tar.bz2
raul-bed446e569b815ebb81e8866579a8abcda77358a.zip
Make boost dependency optional. Note Raul compiled with --cpp0x is NOT compatible with Raul compiled without it.
git-svn-id: http://svn.drobilla.net/lad/trunk/raul@3289 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--raul.pc.in2
-rw-r--r--raul/List.hpp5
-rw-r--r--raul/Maid.hpp8
-rw-r--r--raul/Noncopyable.hpp (renamed from raul/IntrusivePtr.hpp)27
-rw-r--r--raul/Process.hpp5
-rw-r--r--raul/RingBuffer.hpp4
-rw-r--r--raul/SRMWQueue.hpp5
-rw-r--r--raul/SRSWQueue.hpp5
-rw-r--r--raul/Semaphore.hpp4
-rw-r--r--raul/SharedPtr.hpp44
-rw-r--r--raul/Table.hpp5
-rw-r--r--raul/Thread.hpp4
-rw-r--r--raul/TimeSlice.hpp5
-rw-r--r--raul/WeakPtr.hpp10
-rw-r--r--wscript26
15 files changed, 82 insertions, 77 deletions
diff --git a/raul.pc.in b/raul.pc.in
index db1293b..bc2e2bd 100644
--- a/raul.pc.in
+++ b/raul.pc.in
@@ -7,4 +7,4 @@ Name: raul
Version: @RAUL_VERSION@
Description: A C++ convenience library for realtime audio applications
Libs: -L${libdir} -lraul @GLIB_LIBS@ @GTHREAD_LIBS@ @RAUL_PC_LIBS@
-Cflags: -I${includedir} @GLIB_CFLAGS@ @GTHREAD_CFLAGS@
+Cflags: -I${includedir} @GLIB_CFLAGS@ @GTHREAD_CFLAGS@ @RAUL_EXTRA_CXXFLAGS@
diff --git a/raul/List.hpp b/raul/List.hpp
index 4ef23a1..62f3f1c 100644
--- a/raul/List.hpp
+++ b/raul/List.hpp
@@ -21,11 +21,10 @@
#include <cstddef>
#include <cassert>
-#include <boost/utility.hpp>
-
#include "raul/AtomicInt.hpp"
#include "raul/AtomicPtr.hpp"
#include "raul/Deletable.hpp"
+#include "raul/Noncopyable.hpp"
namespace Raul {
@@ -37,7 +36,7 @@ namespace Raul {
* \ingroup raul
*/
template <typename T>
-class List : public Raul::Deletable, public boost::noncopyable
+class List : Deletable, Noncopyable
{
public:
diff --git a/raul/Maid.hpp b/raul/Maid.hpp
index 3eef6c9..a90bf48 100644
--- a/raul/Maid.hpp
+++ b/raul/Maid.hpp
@@ -18,11 +18,11 @@
#ifndef RAUL_MAID_HPP
#define RAUL_MAID_HPP
-#include <boost/utility.hpp>
-#include "raul/SharedPtr.hpp"
-#include "raul/SRSWQueue.hpp"
#include "raul/Deletable.hpp"
#include "raul/List.hpp"
+#include "raul/Noncopyable.hpp"
+#include "raul/SRSWQueue.hpp"
+#include "raul/SharedPtr.hpp"
namespace Raul {
@@ -42,7 +42,7 @@ namespace Raul {
*
* \ingroup raul
*/
-class Maid : boost::noncopyable
+class Maid : Noncopyable
{
public:
explicit Maid(size_t size);
diff --git a/raul/IntrusivePtr.hpp b/raul/Noncopyable.hpp
index 94ce07a..a81894d 100644
--- a/raul/IntrusivePtr.hpp
+++ b/raul/Noncopyable.hpp
@@ -1,12 +1,12 @@
-/* A "weak" pointer to a resource owned by a shared pointer.
- * Copyright 2007-2011 David Robillard <http://drobilla.net>
+/* This file is part of Raul.
+ * Copyright 2011 David Robillard <http://drobilla.net>
*
- * This 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.
*
- * This file 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.
*
@@ -15,12 +15,21 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef RAUL_INTRUSIVE_PTR_HPP
-#define RAUL_INTRUSIVE_PTR_HPP
+#ifndef RAUL_NONCOPYABLE_HPP
+#define RAUL_NONCOPYABLE_HPP
-#include <boost/intrusive_ptr.hpp>
+namespace Raul {
-#define IntrusivePtr boost::intrusive_ptr
+class Noncopyable {
+protected:
+ Noncopyable() {}
+ ~Noncopyable() {}
-#endif // RAUL_INTRUSIVE_PTR_HPP
+private:
+ Noncopyable(const Noncopyable&);
+ const Noncopyable& operator=(const Noncopyable&);
+};
+} // namespace Raul
+
+#endif // RAUL_NONCOPYABLE_HPP
diff --git a/raul/Process.hpp b/raul/Process.hpp
index d9ec5e0..21e4f33 100644
--- a/raul/Process.hpp
+++ b/raul/Process.hpp
@@ -25,8 +25,7 @@
#include <iostream>
#include <string>
-#include <boost/utility.hpp>
-
+#include "raul/Noncopyable.hpp"
#include "raul/log.hpp"
namespace Raul {
@@ -35,7 +34,7 @@ namespace Raul {
*
* \ingroup raul
*/
-class Process : boost::noncopyable
+class Process : Noncopyable
{
public:
diff --git a/raul/RingBuffer.hpp b/raul/RingBuffer.hpp
index bc17b02..8642514 100644
--- a/raul/RingBuffer.hpp
+++ b/raul/RingBuffer.hpp
@@ -25,7 +25,7 @@
#include <glib.h>
-#include <boost/utility.hpp>
+#include "raul/Noncopyable.hpp"
namespace Raul {
@@ -37,7 +37,7 @@ namespace Raul {
@ingroup raul
*/
-class RingBuffer : public boost::noncopyable {
+class RingBuffer : public Noncopyable {
public:
/**
Create a new RingBuffer.
diff --git a/raul/SRMWQueue.hpp b/raul/SRMWQueue.hpp
index 6680103..2534ba3 100644
--- a/raul/SRMWQueue.hpp
+++ b/raul/SRMWQueue.hpp
@@ -22,9 +22,8 @@
#include <cstdlib>
#include <cmath>
-#include <boost/utility.hpp>
-
#include "raul/AtomicInt.hpp"
+#include "raul/Noncopyable.hpp"
namespace Raul {
@@ -50,7 +49,7 @@ namespace Raul {
* \ingroup raul
*/
template <typename T>
-class SRMWQueue : boost::noncopyable
+class SRMWQueue : Noncopyable
{
public:
explicit SRMWQueue(size_t size);
diff --git a/raul/SRSWQueue.hpp b/raul/SRSWQueue.hpp
index 80758d2..ee7a053 100644
--- a/raul/SRSWQueue.hpp
+++ b/raul/SRSWQueue.hpp
@@ -20,9 +20,8 @@
#include <cassert>
-#include <boost/utility.hpp>
-
#include "raul/AtomicInt.hpp"
+#include "raul/Noncopyable.hpp"
namespace Raul {
@@ -39,7 +38,7 @@ namespace Raul {
* \ingroup raul
*/
template <typename T>
-class SRSWQueue : boost::noncopyable
+class SRSWQueue : Noncopyable
{
public:
/** @param size Size in number of elements */
diff --git a/raul/Semaphore.hpp b/raul/Semaphore.hpp
index 63738c2..7df1817 100644
--- a/raul/Semaphore.hpp
+++ b/raul/Semaphore.hpp
@@ -25,7 +25,7 @@
#include <semaphore.h>
#endif
-#include <boost/utility.hpp>
+#include "raul/Noncopyable.hpp"
namespace Raul {
@@ -33,7 +33,7 @@ namespace Raul {
*
* \ingroup raul
*/
-class Semaphore : boost::noncopyable {
+class Semaphore : Noncopyable {
public:
inline Semaphore(unsigned int initial) {
#ifdef __APPLE__
diff --git a/raul/SharedPtr.hpp b/raul/SharedPtr.hpp
index ef4fea8..6b241f8 100644
--- a/raul/SharedPtr.hpp
+++ b/raul/SharedPtr.hpp
@@ -18,39 +18,21 @@
#ifndef RAUL_SHARED_PTR_HPP
#define RAUL_SHARED_PTR_HPP
-#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
-#include <algorithm>
-#include <cassert>
-#include <cstddef>
-#include <iostream>
-#include <set>
-
-static std::set<void*> shared_ptr_counters;
-
-// Use debug hooks to ensure 2 shared_ptrs never point to the same thing
-namespace boost {
- inline void sp_scalar_constructor_hook(void* px, std::size_t size, void* pn) {
- assert(shared_ptr_counters.find(px) == shared_ptr_counters.end());
- shared_ptr_counters.push_back(px);
- }
-
- inline void sp_scalar_destructor_hook(void* px, std::size_t size, void* pn) {
- shared_ptr_counters.remove(px);
- }
-}
-#endif // BOOST_SP_ENABLE_DEBUG_HOOKS
-
-#include <boost/shared_ptr.hpp>
-
-#ifdef BOOST_AC_USE_PTHREADS
-#error "Boost is using mutexes for shared_ptr reference counting."
-#error "This is VERY slow. Please report your platform to d@drobilla.net"
-#endif
-
template <typename T> void NullDeleter(T* ptr) {}
-#define SharedPtr boost::shared_ptr
-#define PtrCast boost::dynamic_pointer_cast
+#ifdef RAUL_CPP0x
+# include <memory>
+# define SharedPtr std::shared_ptr
+# define PtrCast std::dynamic_pointer_cast
+#else
+# include <boost/shared_ptr.hpp>
+# ifdef BOOST_AC_USE_PTHREADS
+# error "Boost is using mutexes for shared_ptr reference counting."
+# error "This is VERY slow. Please report your platform to d@drobilla.net"
+# endif
+# define SharedPtr boost::shared_ptr
+# define PtrCast boost::dynamic_pointer_cast
+#endif
#endif // RAUL_SHARED_PTR_HPP
diff --git a/raul/Table.hpp b/raul/Table.hpp
index 55b42f8..dd5c1d7 100644
--- a/raul/Table.hpp
+++ b/raul/Table.hpp
@@ -22,8 +22,7 @@
#include <utility>
#include <vector>
-#include <boost/utility.hpp>
-
+#include "raul/Noncopyable.hpp"
#include "raul/SharedPtr.hpp"
//#define TABLE_SORT_DEBUG
@@ -38,7 +37,7 @@ namespace Raul {
* \ingroup raul
*/
template <typename K, typename T>
-class Table : public boost::noncopyable {
+class Table : public Noncopyable {
public:
Table<K, T>() : _entries() {}
Table<K, T>(size_t capacity) : _entries(capacity) {}
diff --git a/raul/Thread.hpp b/raul/Thread.hpp
index 0f5761d..b67531a 100644
--- a/raul/Thread.hpp
+++ b/raul/Thread.hpp
@@ -24,7 +24,7 @@
#include <pthread.h>
-#include <boost/utility.hpp>
+#include "raul/Noncopyable.hpp"
namespace Raul {
@@ -37,7 +37,7 @@ namespace Raul {
*
* \ingroup raul
*/
-class Thread : boost::noncopyable
+class Thread : Noncopyable
{
public:
virtual ~Thread() {
diff --git a/raul/TimeSlice.hpp b/raul/TimeSlice.hpp
index 5e7613e..f75f7fd 100644
--- a/raul/TimeSlice.hpp
+++ b/raul/TimeSlice.hpp
@@ -21,8 +21,7 @@
#include <cassert>
#include <cmath>
-#include <boost/utility.hpp>
-
+#include "raul/Noncopyable.hpp"
#include "raul/TimeStamp.hpp"
namespace Raul {
@@ -47,7 +46,7 @@ namespace Raul {
*
* \ingroup raul
*/
-class TimeSlice : public boost::noncopyable {
+class TimeSlice : public Noncopyable {
public:
TimeSlice(uint32_t rate, uint32_t ppqn, double bpm)
: _tick_rate(rate)
diff --git a/raul/WeakPtr.hpp b/raul/WeakPtr.hpp
index 031c995..001599c 100644
--- a/raul/WeakPtr.hpp
+++ b/raul/WeakPtr.hpp
@@ -18,9 +18,13 @@
#ifndef RAUL_WEAK_PTR_HPP
#define RAUL_WEAK_PTR_HPP
-#include <boost/weak_ptr.hpp>
-
-#define WeakPtr boost::weak_ptr
+#ifdef RAUL_CPP0x
+# include <memory>
+# define WeakPtr std::weak_ptr
+#else
+# include <boost/weak_ptr.hpp>
+# define WeakPtr boost::weak_ptr
+#endif
#endif // RAUL_WEAK_PTR_HPP
diff --git a/wscript b/wscript
index bcbfd1e..b8be77d 100644
--- a/wscript
+++ b/wscript
@@ -42,6 +42,8 @@ def options(opt):
help="Coloured console/log output")
opt.add_option('--log-debug', action='store_true', default=False, dest='log_debug',
help="Print debugging output")
+ opt.add_option('--cpp0x', action='store_true', default=False, dest='cpp0x',
+ help="Use C++0x smart pointers instead of boost")
def configure(conf):
autowaf.configure(conf)
@@ -64,12 +66,18 @@ def configure(conf):
if Options.options.log_debug:
autowaf.define(conf, 'RAUL_LOG_DEBUG', 1)
- conf.write_config_header('raul-config.h', remove=False)
- # Boost headers
- autowaf.check_header(conf, 'boost/shared_ptr.hpp', mandatory=True)
- autowaf.check_header(conf, 'boost/weak_ptr.hpp', mandatory=True)
- autowaf.check_header(conf, 'boost/utility.hpp', mandatory=True)
+ if Options.options.cpp0x:
+ conf.env.append_value('CXXFLAGS', [ '-std=c++0x' ])
+ autowaf.check_header(conf, 'memory', mandatory=True)
+ autowaf.define(conf, 'RAUL_CPP0x', 1)
+ autowaf.define(conf, 'RAUL_EXTRA_CXXFLAGS', '-std=c++0x')
+ else:
+ autowaf.check_header(conf, 'boost/shared_ptr.hpp', mandatory=True)
+ autowaf.check_header(conf, 'boost/weak_ptr.hpp', mandatory=True)
+ autowaf.define(conf, 'RAUL_EXTRA_CXXFLAGS', '')
+
+ conf.write_config_header('raul-config.h', remove=False)
autowaf.display_msg(conf, "Unit tests", str(conf.env['BUILD_TESTS']))
print('')
@@ -79,6 +87,7 @@ tests = '''
test/atomic_test
test/list_test
test/path_test
+ test/ptr_test
test/quantize_test
test/queue_test
test/ringbuffer_test
@@ -115,6 +124,10 @@ def build(bld):
if Options.platform == 'darwin':
framework = ' CoreServices '
+ def set_defines(obj):
+ if bld.env['RAUL_CPP0x']:
+ obj.defines = ['RAUL_CPP0x']
+
# Library
obj = bld(features = 'cxx cxxshlib')
obj.export_includes = ['.']
@@ -127,6 +140,7 @@ def build(bld):
obj.framework = framework
obj.install_path = '${LIBDIR}'
obj.vnum = RAUL_LIB_VERSION
+ set_defines(obj);
if bld.env['BUILD_TESTS']:
# Static library (for unit test code coverage)
@@ -139,6 +153,7 @@ def build(bld):
obj.framework = framework
obj.install_path = ''
obj.cxxflags = [ '-fprofile-arcs', '-ftest-coverage' ]
+ set_defines(obj);
# Unit tests
for i in tests.split():
@@ -152,6 +167,7 @@ def build(bld):
obj.install_path = ''
obj.cxxflags = [ '-fprofile-arcs', '-ftest-coverage' ]
obj.linkflags = ['-lgcov']
+ set_defines(obj);
# Documentation
autowaf.build_dox(bld, 'RAUL', RAUL_VERSION, top, out)