diff options
author | David Robillard <d@drobilla.net> | 2007-10-10 05:45:04 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2007-10-10 05:45:04 +0000 |
commit | d1e3c9f3e084b5bfd48949ab9421ac86c8aa0fc9 (patch) | |
tree | b89bfccf8415b47e8d9da2953945c33e03178416 /raul/Table.hpp | |
parent | c50bee51f5c5e6a43068d2fc4c9c76586fa9fb60 (diff) | |
download | raul-d1e3c9f3e084b5bfd48949ab9421ac86c8aa0fc9.tar.gz raul-d1e3c9f3e084b5bfd48949ab9421ac86c8aa0fc9.tar.bz2 raul-d1e3c9f3e084b5bfd48949ab9421ac86c8aa0fc9.zip |
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
Diffstat (limited to 'raul/Table.hpp')
-rw-r--r-- | raul/Table.hpp | 22 |
1 files changed, 12 insertions, 10 deletions
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 <vector> #include <algorithm> +#include <boost/utility.hpp> +#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 <typename K, typename T> -class Table { +class Table : public boost::noncopyable { public: Table<K, T>() : _entries() {} Table<K, T>(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<K,T>& t, size_t i) : _table(t), _index(i) {} - inline const std::pair<const K, T> operator*() const { return _table._entries[_index]; } - inline const std::pair<const K, T>* operator->() const { return (std::pair<const K, T>*)&_table._entries[_index]; } + const_iterator(const Table<K,T>& t, size_t i) : _table(&t), _index(i) {} + inline const std::pair<const K, T> operator*() const { return _table->_entries[_index]; } + inline const std::pair<const K, T>* operator->() const { return (std::pair<const K, T>*)&_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<K,T>; - const Table<K,T>& _table; + const Table<K,T>* _table; size_t _index; }; struct iterator { - iterator(Table<K,T>& t, size_t i) : _table(t), _index(i) {} - inline std::pair<K, T>& operator*() const { return (std::pair<K, T>&)_table._entries[_index]; } - inline std::pair<K, T>* operator->() const { return (std::pair<K, T>*)&_table._entries[_index]; } + iterator(Table<K,T>& t, size_t i) : _table(&t), _index(i) {} + inline std::pair<K, T>& operator*() const { return (std::pair<K, T>&)_table->_entries[_index]; } + inline std::pair<K, T>* operator->() const { return (std::pair<K, T>*)&_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<K,T>; - Table<K,T>& _table; + Table<K,T>* _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<K, T> yank(iterator start, iterator end); + SharedPtr< Table<K, T> > yank(iterator start, iterator end); std::pair<iterator, bool> cram(const Table<K, T>& range); |