1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/target/TargetImpl.h
12 #ifndef ZYPP_TARGET_TARGETIMPL_H
13 #define ZYPP_TARGET_TARGETIMPL_H
17 #include "zypp/base/ReferenceCounted.h"
18 #include "zypp/base/NonCopyable.h"
19 #include "zypp/base/PtrTypes.h"
20 #include "zypp/ResStore.h"
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/target/store/PersistentStorage.h"
27 #include "zypp/solver/detail/Types.h"
29 ///////////////////////////////////////////////////////////////////
31 { /////////////////////////////////////////////////////////////////
32 ///////////////////////////////////////////////////////////////////
34 { /////////////////////////////////////////////////////////////////
36 DEFINE_PTR_TYPE(TargetImpl);
38 ///////////////////////////////////////////////////////////////////
40 // CLASS NAME : TargetImpl
42 /** Base class for concrete Target implementations.
44 * Constructed by \ref TargetFactory. Public access via \ref Target
47 class TargetImpl : public base::ReferenceCounted, private base::NonCopyable
49 friend std::ostream & operator<<( std::ostream & str, const TargetImpl & obj );
52 /** JUST FOR TESTSUITE */
53 /** Sort according to prereqs and media numbers */
54 void getResolvablesToInsDel ( const ResPool pool_r,
55 PoolItemList & dellist_r,
56 PoolItemList & instlist_r,
57 PoolItemList & srclist_r ) const;
62 TargetImpl(const Pathname & root_r = "/");
64 virtual ~TargetImpl();
66 /** Null implementation */
67 static TargetImpl_Ptr nullimpl();
71 /** All resolvables in the target. */
72 const ResStore & resolvables();
74 /** Commit changes in the pool
75 media = 0 means any/all medias
76 media > 0 means limit commits to this media */
77 int commit( ResPool pool_r, unsigned int medianr, PoolItemList & errors_r, PoolItemList & remaining_r, PoolItemList & srcremaining_r );
79 /** enables the storage target */
80 bool isStorageEnabled() const;
81 void enableStorage(const Pathname &root_r);
83 /** Commit ordered changes
84 return uncommitted ones (due to error) */
85 PoolItemList commit( const PoolItemList & items_r );
87 /** Overload to realize stream output. */
88 virtual std::ostream & dumpOn( std::ostream & str ) const
89 { return str << "TargetImpl"; }
91 /** The RPM database */
94 /** If the package is installed and provides the file
95 Needed to evaluate split provides during Resolver::Upgrade() */
96 bool providesFile (const std::string & path_str, const std::string & name_str) const;
98 /** Return the resolvable which provides path_str (rpm -qf)
99 return NULL if no resolvable provides this file */
100 ResObject::constPtr whoOwnsFile (const std::string & path_str) const;
103 /** All resolvables provided by the target. */
105 /** Path to the target */
109 #ifndef STORAGE_DISABLED
110 zypp::storage::PersistentStorage _storage;
113 /** Null implementation */
114 static TargetImpl_Ptr _nullimpl;
116 /** wrapper with callback around getPlainRpm */
117 Pathname getRpmFile(Package::constPtr package);
119 ///////////////////////////////////////////////////////////////////
121 /** \relates TargetImpl Stream output */
122 inline std::ostream & operator<<( std::ostream & str, const TargetImpl & obj )
123 { return obj.dumpOn( str ); }
125 /////////////////////////////////////////////////////////////////
126 } // namespace target
127 ///////////////////////////////////////////////////////////////////
128 /////////////////////////////////////////////////////////////////
130 ///////////////////////////////////////////////////////////////////
131 #endif // ZYPP_TARGET_TARGETIMPL_H