e59cd12ee622f0b342a9e2e47b1a3acbbdc4f1e2
[platform/upstream/libzypp.git] / zypp / repo / DeltaCandidates.h
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9
10 #ifndef ZYPP_REPO_DELTACANDIDATES_H
11 #define ZYPP_REPO_DELTACANDIDATES_H
12
13 #include <iosfwd>
14 #include <list>
15
16 #include "zypp/base/PtrTypes.h"
17 #include "zypp/base/Function.h"
18 #include "zypp/repo/PackageDelta.h"
19 #include "zypp/Repository.h"
20 #include "zypp/Package.h"
21
22 ///////////////////////////////////////////////////////////////////
23 namespace zypp
24 { /////////////////////////////////////////////////////////////////
25   ///////////////////////////////////////////////////////////////////
26   namespace repo
27   { /////////////////////////////////////////////////////////////////
28
29     /**
30      * \short Candidate delta and patches for a package
31      *
32      * Basically a container that given N repositories,
33      * gets all patches and deltas from them for a given
34      * package.
35      */
36     class DeltaCandidates
37     {
38       friend std::ostream & operator<<( std::ostream & str, const DeltaCandidates & obj );
39
40     public:
41       /** Implementation  */
42       class Impl;
43
44     public:
45       DeltaCandidates();
46       /**
47        * \short Creates a candidate calculator
48        * \param repos Set of repositories providing patch and delta packages
49        */
50       DeltaCandidates( const std::list<Repository> & repos, const std::string & pkgname = "" );
51       /** Dtor */
52       ~DeltaCandidates();
53
54       std::list<packagedelta::DeltaRpm> deltaRpms(const Package::constPtr & package) const;
55
56     private:
57       /** Pointer to implementation */
58       RWCOW_pointer<Impl> _pimpl;
59     };
60     ///////////////////////////////////////////////////////////////////
61
62     /** \relates DeltaCandidates Stream output */
63     std::ostream & operator<<( std::ostream & str, const DeltaCandidates & obj );
64
65     ///////////////////////////////////////////////////////////////////
66
67     /** \relates DeltaCandidates Convenient construction.
68      * \todo templated ctor
69     */
70     template<class RepoIter>
71     inline DeltaCandidates makeDeltaCandidates( RepoIter begin_r, RepoIter end_r )
72     { return DeltaCandidates( std::list<Repository>( begin_r, end_r ) ); }
73
74     /** \relates DeltaCandidates Convenient construction.
75      * \todo templated ctor
76      */
77     template<class RepoContainer>
78     inline DeltaCandidates makeDeltaCandidates( const RepoContainer & cont_r )
79     { return makeDeltaCandidates( cont_r.begin(), cont_r.end() ); }
80
81
82     /////////////////////////////////////////////////////////////////
83   } // namespace repo
84   ///////////////////////////////////////////////////////////////////
85   /////////////////////////////////////////////////////////////////
86 } // namespace zypp
87 ///////////////////////////////////////////////////////////////////
88 #endif // ZYPP_REPO_DELTACANDIDATES_H