From 7681735177fa7e381137aadef48963608d0aa0a8 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Tue, 29 Jan 2008 15:45:29 +0000 Subject: Provide public read-access to IListNode pointers, so frame handlers can use then to find the next frame. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@616396 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/IList.h | 7 ++++++- cpp/src/tests/IList.cpp | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'cpp/src') diff --git a/cpp/src/qpid/IList.h b/cpp/src/qpid/IList.h index c0c8b503f0..4593b9a5e1 100644 --- a/cpp/src/qpid/IList.h +++ b/cpp/src/qpid/IList.h @@ -57,6 +57,8 @@ template class IListNode : public virtual RefCounted { } friend class IList; public: + typedef IList IListType; + IListNode(IListNode* p=0) : prev(p), next(p) {} T* getNext() { return next ? next->self() : 0; } T* getPrev() { return prev ? prev->self() : 0; } @@ -97,7 +99,7 @@ template class IList { public: IList() {} - ~IList() { clear(); } + ~IList() { clear(); anchor.erase(); } typedef size_t size_type; typedef T value_type; /// pointer type is an intrusive_ptr @@ -120,6 +122,7 @@ template class IList { /// Note: takes a non-const reference, unlike standard containers. void insert(iterator pos, reference x) { x.Node::insert(pos.ptr); } + void insert(iterator pos, pointer x) { x->Node::insert(pos.ptr); } void erase(iterator pos) { pos.ptr->erase(); } void swap(IList &x) { anchor.swap(x.anchor); } @@ -128,12 +131,14 @@ template class IList { void pop_back() { assert(!empty()); erase(last()); } /// Note: takes a non-const reference, unlike standard containers. void push_back(reference x) { insert(end(), x); } + void push_back(pointer x) { insert(end(), x); } reference front() { assert(!empty()); return *begin(); } const_reference front() const { assert(!empty()); return *begin(); } void pop_front() { assert(!empty()); erase(begin()); } /// Note: takes a non-const reference, unlike standard containers. void push_front(reference x) { insert(begin(), x); } + void push_front(pointer x) { insert(begin(), x); } bool empty() const { return begin() == end(); } void clear() { while (!empty()) { pop_front(); } } diff --git a/cpp/src/tests/IList.cpp b/cpp/src/tests/IList.cpp index f5d7cd344e..392ef4823d 100644 --- a/cpp/src/tests/IList.cpp +++ b/cpp/src/tests/IList.cpp @@ -152,6 +152,10 @@ BOOST_FIXTURE_TEST_CASE(TestIterator, Fixture) { } +BOOST_AUTO_TEST_CASE(testEmptyDtor) { + TestList l; +} + BOOST_FIXTURE_TEST_CASE(testOwnership, Fixture) { { TestList l2; -- cgit v1.2.1