From d1e3c9f3e084b5bfd48949ab9421ac86c8aa0fc9 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 10 Oct 2007 05:45:04 +0000 Subject: Fix recursive patch problems (all objects recursively appearing as direct child of root). Use slightly more human friendly names for blank nodes in patch files. Fix memory management semantics of engine side objects (fix crash on subpatch delete). Make Raul::Table a boost::noncopyable; related changes trickled down from that. git-svn-id: http://svn.drobilla.net/lad/raul@865 a436a847-0d15-0410-975c-d299462d15a1 --- raul/Table.hpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'raul/Table.hpp') diff --git a/raul/Table.hpp b/raul/Table.hpp index a7f7c39..40386e5 100644 --- a/raul/Table.hpp +++ b/raul/Table.hpp @@ -20,6 +20,8 @@ #include #include +#include +#include "SharedPtr.hpp" //#define TABLE_SORT_DEBUG @@ -33,7 +35,7 @@ namespace Raul { * data being in a single chunk of memory, cache optimized, etc. */ template -class Table { +class Table : public boost::noncopyable { public: Table() : _entries() {} Table(size_t capacity) : _entries(capacity) {} @@ -43,9 +45,9 @@ public: void reserve(size_t n) { _entries.reserve(n); } struct const_iterator { - const_iterator(const Table& t, size_t i) : _table(t), _index(i) {} - inline const std::pair operator*() const { return _table._entries[_index]; } - inline const std::pair* operator->() const { return (std::pair*)&_table._entries[_index]; } + const_iterator(const Table& t, size_t i) : _table(&t), _index(i) {} + inline const std::pair operator*() const { return _table->_entries[_index]; } + inline const std::pair* operator->() const { return (std::pair*)&_table->_entries[_index]; } inline const_iterator& operator++() { ++_index; return *this; } inline const_iterator& operator--() { --_index; return *this; } inline bool operator==(const const_iterator& i) const { return _index == i._index; } @@ -53,14 +55,14 @@ public: void operator=(const const_iterator& i) { _table = i._table; _index = i._index; } private: friend class Table; - const Table& _table; + const Table* _table; size_t _index; }; struct iterator { - iterator(Table& t, size_t i) : _table(t), _index(i) {} - inline std::pair& operator*() const { return (std::pair&)_table._entries[_index]; } - inline std::pair* operator->() const { return (std::pair*)&_table._entries[_index]; } + iterator(Table& t, size_t i) : _table(&t), _index(i) {} + inline std::pair& operator*() const { return (std::pair&)_table->_entries[_index]; } + inline std::pair* operator->() const { return (std::pair*)&_table->_entries[_index]; } inline iterator& operator++() { ++_index; return *this; } inline iterator& operator--() { --_index; return *this; } inline bool operator==(const iterator& i) const { return _index == i._index; } @@ -69,7 +71,7 @@ public: iterator& operator=(const iterator& i) { _table = i._table; _index = i._index; return *this; } private: friend class Table; - Table& _table; + Table* _table; size_t _index; }; @@ -82,7 +84,7 @@ public: void erase(iterator start, iterator end); void erase_by_index(size_t start, size_t end); - Table yank(iterator start, iterator end); + SharedPtr< Table > yank(iterator start, iterator end); std::pair cram(const Table& range); -- cgit v1.2.1