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/PoolItem.h"
24 #include "zypp/ZYppCommit.h"
26 #include "zypp/Pathname.h"
27 #include "zypp/media/MediaAccess.h"
28 #include "zypp/Target.h"
29 #include "zypp/target/rpm/RpmDb.h"
30 #include "zypp/target/TargetException.h"
32 ///////////////////////////////////////////////////////////////////
34 { /////////////////////////////////////////////////////////////////
35 ///////////////////////////////////////////////////////////////////
37 { /////////////////////////////////////////////////////////////////
39 DEFINE_PTR_TYPE(TargetImpl);
41 ///////////////////////////////////////////////////////////////////
43 // CLASS NAME : TargetImpl
45 /** Base class for concrete Target implementations.
47 * Constructed by \ref TargetFactory. Public access via \ref Target
50 class TargetImpl : public base::ReferenceCounted, private base::NonCopyable
52 friend std::ostream & operator<<( std::ostream & str, const TargetImpl & obj );
55 /** list of pool items */
56 typedef std::list<PoolItem> PoolItemList;
58 /** set of pool items */
59 typedef std::set<PoolItem> PoolItemSet;
63 TargetImpl(const Pathname & root_r = "/");
65 virtual ~TargetImpl();
67 /** Null implementation */
68 static TargetImpl_Ptr nullimpl();
76 /** The root set for this target */
77 Pathname root() const;
79 /** Commit changes in the pool */
80 ZYppCommitResult commit( ResPool pool_r, const ZYppCommitPolicy & policy_r );
82 ZYPP_DEPRECATED int commit( ResPool pool_r, unsigned int medianr,
83 PoolItemList & errors_r,
84 PoolItemList & remaining_r,
85 PoolItemList & srcremaining_r,
86 bool dry_run = false )
88 ZYppCommitPolicy policy;
89 policy.restrictToMedia( medianr ).dryRun( dry_run );
90 ZYppCommitResult res = commit( pool_r, policy );
91 errors_r.swap( res._errors );
92 remaining_r.swap( res._remaining );
93 srcremaining_r.swap( res._srcremaining );
97 /** Commit ordered changes
98 * @param pool_r only needed for #160792
99 * @return uncommitted ones (due to error)
101 PoolItemList commit( const PoolItemList & items_r, const ZYppCommitPolicy & policy_r, const ResPool & pool_r );
103 /** Install a source package on the Target. */
104 void installSrcPackage( const SrcPackage_constPtr & srcPackage_r );
106 /** Overload to realize stream output. */
107 virtual std::ostream & dumpOn( std::ostream & str ) const
109 return str << "TargetImpl";
112 /** The RPM database */
115 /** If the package is installed and provides the file
116 Needed to evaluate split provides during Resolver::Upgrade() */
117 bool providesFile (const std::string & path_str, const std::string & name_str) const;
119 /** Return name of package owning \a path_str
120 * or empty string if no installed package owns \a path_str. */
121 std::string whoOwnsFile (const std::string & path_str) const
122 { return _rpm.whoOwnsFile (path_str); }
124 /** Set the log file for target */
125 bool setInstallationLogfile(const Pathname & path_r);
127 /** return the last modification date of the target */
128 Date timestamp() const;
131 * reload the target in future calls if
133 * note the loading can actually be delayed, but
134 * the next call to resolvables must reflect the
135 * status of the system.
140 /** Path to the target */
145 /** Null implementation */
146 static TargetImpl_Ptr _nullimpl;
148 ///////////////////////////////////////////////////////////////////
150 /** \relates TargetImpl Stream output */
151 inline std::ostream & operator<<( std::ostream & str, const TargetImpl & obj )
153 return obj.dumpOn( str );
156 /////////////////////////////////////////////////////////////////
157 } // namespace target
158 ///////////////////////////////////////////////////////////////////
159 /////////////////////////////////////////////////////////////////
161 ///////////////////////////////////////////////////////////////////
162 #endif // ZYPP_TARGET_TARGETIMPL_H