Imported Upstream version 16.3.2
[platform/upstream/libzypp.git] / zypp / pool / PoolTraits.h
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file       zypp/pool/PoolTraits.h
10  *
11 */
12 #ifndef ZYPP_POOL_POOLTRAITS_H
13 #define ZYPP_POOL_POOLTRAITS_H
14
15 #include <set>
16 #include <map>
17 #include <list>
18 #include <vector>
19
20 #include "zypp/base/Iterator.h"
21 #include "zypp/base/Hash.h"
22
23 #include "zypp/PoolItem.h"
24 #include "zypp/pool/ByIdent.h"
25 #include "zypp/sat/Pool.h"
26
27 ///////////////////////////////////////////////////////////////////
28 namespace zypp
29 { /////////////////////////////////////////////////////////////////
30
31   class PoolQuery;
32
33   ///////////////////////////////////////////////////////////////////
34   namespace pool
35   { /////////////////////////////////////////////////////////////////
36
37     class PoolImpl;
38
39     /** Pool internal filter skiping invalid/unwanted PoolItems. */
40     struct ByPoolItem
41     {
42       bool operator()( const PoolItem & pi ) const
43       { return bool(pi); }
44     };
45
46     /** In CXX0X std::_Select2nd does no longer derive from std::unary_function
47      */
48     template<typename TPair>
49     struct P_Select2nd : public std::unary_function<TPair, typename TPair::second_type>
50     {
51       typename TPair::second_type&
52       operator()(TPair& __x) const
53       { return __x.second; }
54
55       const typename TPair::second_type&
56       operator()(const TPair& __x) const
57       { return __x.second; }
58     };
59
60     ///////////////////////////////////////////////////////////////////
61     //
62     //  CLASS NAME : PoolTraits
63     //
64     /** */
65     struct PoolTraits
66     {
67     public:
68       typedef sat::detail::SolvableIdType               SolvableIdType;
69
70       /** pure items  */
71       typedef std::vector<PoolItem>                     ItemContainerT;
72       typedef ItemContainerT::const_iterator            item_iterator;
73       typedef filter_iterator<ByPoolItem,ItemContainerT::const_iterator>
74                                                         const_iterator;
75       typedef ItemContainerT::size_type                 size_type;
76
77       /** ident index */
78       typedef std::unordered_multimap<sat::detail::IdType, PoolItem>
79                                                         Id2ItemT;
80       typedef P_Select2nd<Id2ItemT::value_type>         Id2ItemValueSelector;
81       typedef transform_iterator<Id2ItemValueSelector, Id2ItemT::const_iterator>
82                                                         byIdent_iterator;
83
84       /** list of known Repositories */
85       typedef sat::Pool::RepositoryIterator             repository_iterator;
86
87       /** hard locks from etc/zypp/locks */
88       typedef std::list<PoolQuery>                      HardLockQueries;
89       typedef HardLockQueries::const_iterator           hardLockQueries_iterator;
90
91       typedef PoolImpl                   Impl;
92       typedef shared_ptr<PoolImpl>       Impl_Ptr;
93       typedef shared_ptr<const PoolImpl> Impl_constPtr;
94     };
95     ///////////////////////////////////////////////////////////////////
96
97     /////////////////////////////////////////////////////////////////
98   } // namespace pool
99   ///////////////////////////////////////////////////////////////////
100   /////////////////////////////////////////////////////////////////
101 } // namespace zypp
102 ///////////////////////////////////////////////////////////////////
103 #endif // ZYPP_POOL_POOLTRAITS_H