resolvable download callback
[platform/upstream/libzypp.git] / zypp / target / TargetImpl.h
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file       zypp/target/TargetImpl.h
10  *
11 */
12 #ifndef ZYPP_TARGET_TARGETIMPL_H
13 #define ZYPP_TARGET_TARGETIMPL_H
14
15 #include <iosfwd>
16
17 #include "zypp/base/ReferenceCounted.h"
18 #include "zypp/base/NonCopyable.h"
19 #include "zypp/base/PtrTypes.h"
20 #include "zypp/ResStore.h"
21
22 #include "zypp/Pathname.h"
23 #include "zypp/media/MediaAccess.h"
24 #include "zypp/Target.h"
25 #include "zypp/target/rpm/RpmDb.h"
26 #include "zypp/solver/detail/Types.h"
27
28 ///////////////////////////////////////////////////////////////////
29 namespace zypp
30 { /////////////////////////////////////////////////////////////////
31   ///////////////////////////////////////////////////////////////////
32   namespace target
33   { /////////////////////////////////////////////////////////////////
34
35     DEFINE_PTR_TYPE(TargetImpl);
36
37     ///////////////////////////////////////////////////////////////////
38     //
39     //  CLASS NAME : TargetImpl
40     //
41     /** Base class for concrete Target implementations.
42      *
43      * Constructed by \ref TargetFactory. Public access via \ref Target
44      * interface.
45     */
46     class TargetImpl : public base::ReferenceCounted, private base::NonCopyable
47     {
48       friend std::ostream & operator<<( std::ostream & str, const TargetImpl & obj );
49
50     public:
51       /** Ctor. */
52       TargetImpl(const Pathname & root_r = "/");
53       /** Dtor. */
54       virtual ~TargetImpl();
55
56       /** Null implementation */
57       static TargetImpl_Ptr nullimpl();
58
59     public:
60
61       /** All resolvables in the target. */
62       const ResStore & resolvables();
63
64       /** Sort according to prereqs and media numbers */
65       void getResolvablesToInsDel ( ResPool pool_r,
66                                     PoolItemList & dellist_r,
67                                     PoolItemList & instlist_r,
68                                     PoolItemList & srclist_r );
69
70       /** Commit changes in the pool */
71 #warning Add support for multiple medias - eg. limit only to CD1
72       void commit(ResPool pool_r);
73
74       /** Commit ordered changes */
75       void commit(const PoolItemList & items_r);
76
77       /** Overload to realize stream output. */
78       virtual std::ostream & dumpOn( std::ostream & str ) const
79       { return str << "TargetImpl"; }
80
81       /** The RPM database */
82       rpm::RpmDb & rpm();
83
84       /** If the package is installed and provides the file
85           Needed to evaluate split provides during Resolver::Upgrade() */
86       bool providesFile (const std::string & path_str, const std::string & name_str) const;
87
88       /** Return the resolvable which provides path_str (rpm -qf)
89           return NULL if no resolvable provides this file  */
90       ResObject::constPtr whoOwnsFile (const std::string & path_str) const;
91
92     protected:
93       /** All resolvables provided by the target. */
94       ResStore _store;
95       /** Path to the target */
96       Pathname _root;
97       /** RPM database */
98       rpm::RpmDb _rpm;
99     private:
100       /** Null implementation */
101       static TargetImpl_Ptr _nullimpl;
102       
103       /** wrapper with callback around getPlainRpm */
104       Pathname getRpmFile(Package::constPtr package);
105     };
106     ///////////////////////////////////////////////////////////////////
107
108     /** \relates TargetImpl Stream output */
109     inline std::ostream & operator<<( std::ostream & str, const TargetImpl & obj )
110     { return obj.dumpOn( str ); }
111
112     /////////////////////////////////////////////////////////////////
113   } // namespace target
114   ///////////////////////////////////////////////////////////////////
115   /////////////////////////////////////////////////////////////////
116 } // namespace zypp
117 ///////////////////////////////////////////////////////////////////
118 #endif // ZYPP_TARGET_TARGETIMPL_H