1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/target/TargetImpl.h
12 #ifndef ZYPP_TARGET_TARGETIMPL_H
13 #define ZYPP_TARGET_TARGETIMPL_H
19 #include "zypp/base/ReferenceCounted.h"
20 #include "zypp/base/NonCopyable.h"
21 #include "zypp/base/DefaultFalseBool.h"
22 #include "zypp/base/PtrTypes.h"
23 #include "zypp/ResStore.h"
24 #include "zypp/PoolItem.h"
25 #include "zypp/ZYppCommit.h"
27 #include "zypp/Pathname.h"
28 #include "zypp/media/MediaAccess.h"
29 #include "zypp/Target.h"
30 #include "zypp/target/rpm/RpmDb.h"
31 #include "zypp/target/TargetException.h"
33 ///////////////////////////////////////////////////////////////////
35 { /////////////////////////////////////////////////////////////////
36 ///////////////////////////////////////////////////////////////////
38 { /////////////////////////////////////////////////////////////////
40 DEFINE_PTR_TYPE(TargetImpl);
42 ///////////////////////////////////////////////////////////////////
44 // CLASS NAME : TargetImpl
46 /** Base class for concrete Target implementations.
48 * Constructed by \ref TargetFactory. Public access via \ref Target
51 class TargetImpl : public base::ReferenceCounted, private base::NonCopyable
53 friend std::ostream & operator<<( std::ostream & str, const TargetImpl & obj );
56 /** list of pool items */
57 typedef std::list<PoolItem> PoolItemList;
59 /** set of pool items */
60 typedef std::set<PoolItem> PoolItemSet;
64 TargetImpl(const Pathname & root_r = "/");
66 virtual ~TargetImpl();
68 /** Null implementation */
69 static TargetImpl_Ptr nullimpl();
76 * load resolvables of certain kind in the internal store
77 * and return a iterator
78 * successive calls will be faster as resolvables are cached-
80 ResStore::resfilter_const_iterator byKindBegin( const ResObject::Kind & kind_r ) const;
81 ResStore::resfilter_const_iterator byKindEnd( const ResObject::Kind & kind_r ) const;
83 /** The root set for this target */
84 Pathname root() const;
86 /** Commit changes in the pool */
87 ZYppCommitResult commit( ResPool pool_r, const ZYppCommitPolicy & policy_r );
89 ZYPP_DEPRECATED int commit( ResPool pool_r, unsigned int medianr,
90 PoolItemList & errors_r,
91 PoolItemList & remaining_r,
92 PoolItemList & srcremaining_r,
93 bool dry_run = false )
95 ZYppCommitPolicy policy;
96 policy.restrictToMedia( medianr ).dryRun( dry_run );
97 ZYppCommitResult res = commit( pool_r, policy );
98 errors_r.swap( res._errors );
99 remaining_r.swap( res._remaining );
100 srcremaining_r.swap( res._srcremaining );
104 /** Commit ordered changes
105 * @param pool_r only needed for #160792
106 * @return uncommitted ones (due to error)
108 PoolItemList commit( const PoolItemList & items_r, const ZYppCommitPolicy & policy_r, const ResPool & pool_r );
110 /** Install a source package on the Target. */
111 void installSrcPackage( const SrcPackage_constPtr & srcPackage_r );
113 /** Overload to realize stream output. */
114 virtual std::ostream & dumpOn( std::ostream & str ) const
116 return str << "TargetImpl";
119 /** The RPM database */
122 /** If the package is installed and provides the file
123 Needed to evaluate split provides during Resolver::Upgrade() */
124 bool providesFile (const std::string & path_str, const std::string & name_str) const;
126 /** Return the resolvable which provides path_str (rpm -qf)
127 return NULL if no resolvable provides this file */
128 ResObject::constPtr whoOwnsFile (const std::string & path_str) const;
130 /** Set the log file for target */
131 bool setInstallationLogfile(const Pathname & path_r);
133 /** return the last modification date of the target */
134 Date timestamp() const;
137 * reload the target in future calls if
139 * note the loading can actually be delayed, but
140 * the next call to resolvables must reflect the
141 * status of the system.
146 /** All resolvables provided by the target. */
148 /** Path to the target */
153 /** Null implementation */
154 static TargetImpl_Ptr _nullimpl;
156 ///////////////////////////////////////////////////////////////////
158 /** \relates TargetImpl Stream output */
159 inline std::ostream & operator<<( std::ostream & str, const TargetImpl & obj )
161 return obj.dumpOn( str );
164 /////////////////////////////////////////////////////////////////
165 } // namespace target
166 ///////////////////////////////////////////////////////////////////
167 /////////////////////////////////////////////////////////////////
169 ///////////////////////////////////////////////////////////////////
170 #endif // ZYPP_TARGET_TARGETIMPL_H