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 /** Sort according to prereqs and media numbers */
53 void getResolvablesToInsDel ( const ResPool pool_r,
54 PoolItemList & dellist_r,
55 PoolItemList & instlist_r,
56 PoolItemList & srclist_r );
61 TargetImpl(const Pathname & root_r = "/");
63 virtual ~TargetImpl();
65 /** Null implementation */
66 static TargetImpl_Ptr nullimpl();
70 /** All resolvables in the target. */
71 const ResStore & resolvables();
73 /** Commit changes in the pool
74 media = 0 means any/all medias
75 media > 0 means limit commits to this media */
76 void commit( ResPool pool_r, unsigned int medianr, PoolItemList & errors_r, PoolItemList & remaining_r, PoolItemList & srcremaining_r );
78 /** enables the storage target */
79 bool isStorageEnabled() const;
80 void enableStorage(const Pathname &root_r);
82 /** Commit ordered changes
83 return uncommitted ones (due to error) */
84 PoolItemList commit( const PoolItemList & items_r );
86 /** Overload to realize stream output. */
87 virtual std::ostream & dumpOn( std::ostream & str ) const
88 { return str << "TargetImpl"; }
90 /** The RPM database */
93 /** If the package is installed and provides the file
94 Needed to evaluate split provides during Resolver::Upgrade() */
95 bool providesFile (const std::string & path_str, const std::string & name_str) const;
97 /** Return the resolvable which provides path_str (rpm -qf)
98 return NULL if no resolvable provides this file */
99 ResObject::constPtr whoOwnsFile (const std::string & path_str) const;
102 /** All resolvables provided by the target. */
104 /** Path to the target */
108 #ifndef STORAGE_DISABLED
109 zypp::storage::PersistentStorage _storage;
112 /** Null implementation */
113 static TargetImpl_Ptr _nullimpl;
115 /** wrapper with callback around getPlainRpm */
116 Pathname getRpmFile(Package::constPtr package);
118 ///////////////////////////////////////////////////////////////////
120 /** \relates TargetImpl Stream output */
121 inline std::ostream & operator<<( std::ostream & str, const TargetImpl & obj )
122 { return obj.dumpOn( str ); }
124 /////////////////////////////////////////////////////////////////
125 } // namespace target
126 ///////////////////////////////////////////////////////////////////
127 /////////////////////////////////////////////////////////////////
129 ///////////////////////////////////////////////////////////////////
130 #endif // ZYPP_TARGET_TARGETIMPL_H