From 33572912804c3248e206bec91f3b06c78bb0ea76 Mon Sep 17 00:00:00 2001 From: Michael Andres Date: Tue, 24 Jan 2006 09:58:30 +0000 Subject: [PATCH] - fixed ResPoolManager insert/erase to follow Impl pointer. --- zypp/ResPoolManager.cc | 9 --------- zypp/ResPoolManager.h | 36 ++++++++++-------------------------- zypp/pool/PoolImpl.cc | 6 ++++++ zypp/pool/PoolImpl.h | 16 ++++++++++------ zypp/pool/PoolTraits.h | 24 ++++++++++++++++++++++++ 5 files changed, 50 insertions(+), 41 deletions(-) diff --git a/zypp/ResPoolManager.cc b/zypp/ResPoolManager.cc index ccfda53..bc7ac33 100644 --- a/zypp/ResPoolManager.cc +++ b/zypp/ResPoolManager.cc @@ -28,8 +28,6 @@ namespace zypp // ResPoolManager::ResPoolManager() : _pimpl( new pool::PoolImpl ) - , _inserter( _pimpl->store() ) - , _deleter( _pimpl->store() ) {} /////////////////////////////////////////////////////////////////// @@ -49,13 +47,6 @@ namespace zypp void ResPoolManager::clear() { _pimpl->clear(); } -#warning IMPLEMENT IT - void ResPoolManager::Inserter::operator()( ResObject::constPtr ptr_r ) - { INT << "+++ " << *ptr_r << endl; } - - void ResPoolManager::Deleter::operator()( ResObject::constPtr ptr_r ) - { SEC << "--- " << *ptr_r << endl; } - /****************************************************************** ** ** FUNCTION NAME : operator<< diff --git a/zypp/ResPoolManager.h b/zypp/ResPoolManager.h index f184e62..a8e7bd7 100644 --- a/zypp/ResPoolManager.h +++ b/zypp/ResPoolManager.h @@ -48,20 +48,20 @@ namespace zypp public: /** */ void insert( ResObject::constPtr ptr_r ) - { _inserter( ptr_r ); } + { inserter()( ptr_r ); } /** */ template void insert( _InputIterator first_r, _InputIterator last_r ) - { std::for_each( first_r, last_r, _inserter ); } + { std::for_each( first_r, last_r, inserter() ); } /** */ void erase( ResObject::constPtr ptr_r ) - { _deleter( ptr_r ); } + { deleter()( ptr_r ); } /** */ void erase( iterator first_r, iterator last_r ) - { std::for_each( first_r, last_r, _deleter ); } + { std::for_each( first_r, last_r, deleter() ); } /** */ void clear(); @@ -70,34 +70,18 @@ namespace zypp /** */ typedef pool::PoolTraits::ContainerT ContainerT; typedef pool::PoolTraits::Impl Impl; - /** */ - struct Inserter - { - void operator()( ResObject::constPtr ptr_r ); - - Inserter( ContainerT & store_r ) - : _store( store_r ) - {} - ContainerT & _store; - }; - /** */ - struct Deleter - { - void operator()( ResObject::constPtr ptr_r ); - - Deleter( ContainerT & store_r ) - : _store( store_r ) - {} - ContainerT & _store; - }; + typedef pool::PoolTraits::Inserter Inserter; + typedef pool::PoolTraits::Deleter Deleter; private: /** Pointer to implementation */ RW_pointer _pimpl; /** */ - Inserter _inserter; + Inserter inserter() + { return Inserter( *_pimpl ); } /** */ - Deleter _deleter; + Deleter deleter() + { return Deleter( *_pimpl ); } }; /////////////////////////////////////////////////////////////////// diff --git a/zypp/pool/PoolImpl.cc b/zypp/pool/PoolImpl.cc index affd745..128815f 100644 --- a/zypp/pool/PoolImpl.cc +++ b/zypp/pool/PoolImpl.cc @@ -49,6 +49,12 @@ namespace zypp return str << "PoolImpl " << obj.size(); } + void PoolImplInserter::operator()( ResObject::constPtr ptr_r ) + { _poolImpl.store().insert( PoolImpl::Item( ptr_r ) ); } + + void PoolImplDeleter::operator()( ResObject::constPtr ptr_r ) + { _poolImpl.store().erase( PoolImpl::Item( ptr_r ) ); } + ///////////////////////////////////////////////////////////////// } // namespace pool /////////////////////////////////////////////////////////////////// diff --git a/zypp/pool/PoolImpl.h b/zypp/pool/PoolImpl.h index 633b5f4..67e6797 100644 --- a/zypp/pool/PoolImpl.h +++ b/zypp/pool/PoolImpl.h @@ -34,11 +34,13 @@ namespace zypp public: /** */ - typedef pool::PoolTraits::Item Item; - typedef pool::PoolTraits::ContainerT ContainerT; - typedef pool::PoolTraits::size_type size_type; - typedef pool::PoolTraits::iterator iterator; - typedef pool::PoolTraits::const_iterator const_iterator; + typedef PoolTraits::Item Item; + typedef PoolTraits::ContainerT ContainerT; + typedef PoolTraits::size_type size_type; + typedef PoolTraits::iterator iterator; + typedef PoolTraits::const_iterator const_iterator; + typedef PoolTraits::Inserter Inserter; + typedef PoolTraits::Deleter Deleter; public: /** Default ctor */ @@ -53,18 +55,21 @@ namespace zypp /** */ const ContainerT & store() const { return _store; } + /** */ bool empty() const { return _store.empty(); } /** */ size_type size() const { return _store.size(); } + /** */ iterator begin() { return _store.begin(); } /** */ const_iterator begin() const { return _store.begin(); } + /** */ iterator end() { return _store.end(); } @@ -76,7 +81,6 @@ namespace zypp void clear() { return _store.clear(); } - public: /** */ ContainerT _store; diff --git a/zypp/pool/PoolTraits.h b/zypp/pool/PoolTraits.h index 316db7d..808edc9 100644 --- a/zypp/pool/PoolTraits.h +++ b/zypp/pool/PoolTraits.h @@ -25,6 +25,28 @@ namespace zypp class PoolImpl; + /** */ + struct PoolImplInserter + { + void operator()( ResObject::constPtr ptr_r ); + + PoolImplInserter( PoolImpl & poolImpl_r ) + : _poolImpl( poolImpl_r ) + {} + PoolImpl & _poolImpl; + }; + + /** */ + struct PoolImplDeleter + { + void operator()( ResObject::constPtr ptr_r ); + + PoolImplDeleter( PoolImpl & poolImpl_r ) + : _poolImpl( poolImpl_r ) + {} + PoolImpl & _poolImpl; + }; + /////////////////////////////////////////////////////////////////// // // CLASS NAME : PoolTraits @@ -43,6 +65,8 @@ namespace zypp typedef PoolImpl Impl; typedef shared_ptr Impl_Ptr; typedef shared_ptr Impl_constPtr; + typedef PoolImplInserter Inserter; + typedef PoolImplDeleter Deleter; }; /////////////////////////////////////////////////////////////////// -- 2.7.4