start implementing eraseInstalled() (unfinished)
[platform/upstream/libzypp.git] / zypp / ResPool.cc
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file       zypp/ResPool.cc
10  *
11 */
12 #include <iostream>
13 //#include "zypp/base/Logger.h"
14
15 #include "zypp/ResPool.h"
16 #include "zypp/pool/PoolImpl.h"
17
18 using std::endl;
19
20 ///////////////////////////////////////////////////////////////////
21 namespace zypp
22 { /////////////////////////////////////////////////////////////////
23
24   namespace
25   {
26     /** the empty pool used by ResPool::ResPool() */
27     pool::PoolTraits::Impl_constPtr noPool()
28     {
29       static pool::PoolTraits::Impl_constPtr _noPool( new pool::PoolImpl );
30       return _noPool;
31     }
32   }
33
34   ///////////////////////////////////////////////////////////////////
35   //
36   //    METHOD NAME : ResPool::ResPool
37   //    METHOD TYPE : Ctor
38   //
39   ResPool::ResPool()
40   : _pimpl( noPool() )
41   {}
42
43   ///////////////////////////////////////////////////////////////////
44   //
45   //    METHOD NAME : ResPool::ResPool
46   //    METHOD TYPE : Ctor
47   //
48   ResPool::ResPool( pool::PoolTraits::Impl_constPtr impl_r )
49   : _pimpl( impl_r )
50   {}
51
52   ///////////////////////////////////////////////////////////////////
53   //
54   //    METHOD NAME : ResPool::~ResPool
55   //    METHOD TYPE : Dtor
56   //
57   ResPool::~ResPool()
58   {}
59
60   ///////////////////////////////////////////////////////////////////
61   //
62   // Forward to impementation:
63   //
64   ///////////////////////////////////////////////////////////////////
65
66   bool ResPool::empty() const
67   { return _pimpl->empty(); }
68
69   ResPool::size_type ResPool::size() const
70   { return _pimpl->size(); }
71
72   ResPool::const_iterator ResPool::begin() const
73   { return _pimpl->begin(); }
74
75   ResPool::const_iterator ResPool::end() const
76   { return _pimpl->end(); }
77
78   ResPool::byName_iterator ResPool::byNameBegin( const std::string & name_r ) const
79   { return make_filter_iterator( ByName( name_r ), _pimpl->_namehash.begin( name_r ), _pimpl->_namehash.end( name_r ) ); }
80
81   ResPool::byName_iterator ResPool::byNameEnd( const std::string & name_r ) const
82   { return make_filter_iterator( ByName( name_r ), _pimpl->_namehash.end( name_r ), _pimpl->_namehash.end( name_r ) ); }
83
84   ResPool::byCapabilityIndex_iterator ResPool::byCapabilityIndexBegin( const std::string & index_r, Dep depType_r ) const
85   { return make_filter_iterator( ByCapabilityIndex(), _pimpl->_caphash.begin( index_r, depType_r ), _pimpl->_caphash.end( index_r, depType_r ) ); }
86
87   ResPool::byCapabilityIndex_iterator ResPool::byCapabilityIndexEnd( const std::string & index_r, Dep depType_r ) const
88   { return make_filter_iterator( ByCapabilityIndex(), _pimpl->_caphash.end( index_r, depType_r ), _pimpl->_caphash.end( index_r, depType_r ) ); }
89
90   void ResPool::eraseInstalled()
91   { // doesnotwork (const_pointer_cast<pool::PoolTraits::Impl_constPtr>(_pimpl))->eraseInstalled();
92     return; }
93
94   /******************************************************************
95   **
96   **    FUNCTION NAME : operator<<
97   **    FUNCTION TYPE : std::ostream &
98   */
99   std::ostream & operator<<( std::ostream & str, const ResPool & obj )
100   {
101     return str << *obj._pimpl;
102   }
103
104   /////////////////////////////////////////////////////////////////
105 } // namespace zypp
106 ///////////////////////////////////////////////////////////////////