Fixed compilation errors with GCC 4.3 by adding missing includes
[platform/upstream/libzypp.git] / zypp / ResPoolManager.h
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file       zypp/ResPoolManager.h
10  *
11 */
12 #ifndef ZYPP_RESPOOLMANAGER_H
13 #define ZYPP_RESPOOLMANAGER_H
14
15 #include <iosfwd>
16
17 #include "zypp/ResPool.h"
18 #include "zypp/ResPoolProxy.h"
19 #include "zypp/ResStore.h"
20
21 ///////////////////////////////////////////////////////////////////
22 namespace zypp
23 { /////////////////////////////////////////////////////////////////
24
25   ///////////////////////////////////////////////////////////////////
26   //
27   //    CLASS NAME : ResPoolManager
28   //
29   /** Manage a ResObject pool. */
30   class ResPoolManager
31   {
32     friend std::ostream & operator<<( std::ostream & str, const ResPoolManager & obj );
33
34   public:
35     /** */
36     typedef pool::PoolTraits::Item           Item;
37     typedef pool::PoolTraits::size_type      size_type;
38     typedef pool::PoolTraits::iterator       iterator;
39     typedef pool::PoolTraits::const_iterator const_iterator;
40
41   public:
42     /** Default ctor */
43     ResPoolManager();
44     /** Dtor */
45     ~ResPoolManager();
46
47     ResPool accessor() const
48     { return ResPool( _pimpl.getPtr() ); }
49
50     /** \todo Speedup by using a data mamaber invaidated only
51      * whenever the pool content changes */
52     ResPoolProxy proxy() const;
53
54   public:
55     /**  */
56     void insert( ResObject::constPtr ptr_r, bool installed = false )
57     { inserter(installed)( ptr_r ); }
58
59     void insert( const ResStore & store_r, bool installed = false )
60     { insert( store_r.begin(), store_r.end(), installed ); }
61
62     /**  */
63     template <class _InputIterator>
64       void insert( _InputIterator first_r, _InputIterator last_r, bool installed = false )
65       { std::for_each( first_r, last_r, inserter(installed) ); }
66
67     /**  */
68     void erase( ResObject::constPtr ptr_r )
69     { deleter()( ptr_r ); }
70
71     /** unsafe
72     void erase( iterator first_r, iterator last_r )
73     { std::for_each( first_r, last_r, deleter() ); }
74     */
75
76     /**  */
77     void clear();
78
79   private:
80     /**  */
81     typedef pool::PoolTraits::ItemContainerT  ContainerT;
82     typedef pool::PoolTraits::Impl        Impl;
83     typedef pool::PoolTraits::Inserter    Inserter;
84     typedef pool::PoolTraits::Deleter     Deleter;
85
86   private:
87     /** Pointer to implementation */
88     RW_pointer<pool::PoolTraits::Impl> _pimpl;
89     /**  */
90     Inserter inserter( bool installed )
91     { return Inserter( *_pimpl, installed ); }
92     /**  */
93     Deleter deleter()
94     { return Deleter( *_pimpl ); }
95   };
96   ///////////////////////////////////////////////////////////////////
97
98   /** \relates ResPoolManager Stream output */
99   std::ostream & operator<<( std::ostream & str, const ResPoolManager & obj );
100
101   /////////////////////////////////////////////////////////////////
102 } // namespace zypp
103 ///////////////////////////////////////////////////////////////////
104 #endif // ZYPP_RESPOOLMANAGER_H