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();
74 /** The root set for this target */
75 Pathname root() const;
77 /** Commit changes in the pool */
78 ZYppCommitResult commit( ResPool pool_r, const ZYppCommitPolicy & policy_r );
80 ZYPP_DEPRECATED int commit( ResPool pool_r, unsigned int medianr,
81 PoolItemList & errors_r,
82 PoolItemList & remaining_r,
83 PoolItemList & srcremaining_r,
84 bool dry_run = false )
86 ZYppCommitPolicy policy;
87 policy.restrictToMedia( medianr ).dryRun( dry_run );
88 ZYppCommitResult res = commit( pool_r, policy );
89 errors_r.swap( res._errors );
90 remaining_r.swap( res._remaining );
91 srcremaining_r.swap( res._srcremaining );
95 /** Commit ordered changes
96 * @param pool_r only needed for #160792
97 * @return uncommitted ones (due to error)
99 PoolItemList commit( const PoolItemList & items_r, const ZYppCommitPolicy & policy_r, const ResPool & pool_r );
101 /** Install a source package on the Target. */
102 void installSrcPackage( const SrcPackage_constPtr & srcPackage_r );
104 /** Overload to realize stream output. */
105 virtual std::ostream & dumpOn( std::ostream & str ) const
107 return str << "TargetImpl";
110 /** The RPM database */
113 /** If the package is installed and provides the file
114 Needed to evaluate split provides during Resolver::Upgrade() */
115 bool providesFile (const std::string & path_str, const std::string & name_str) const;
117 /** Return name of package owning \a path_str
118 * or empty string if no installed package owns \a path_str. */
119 std::string whoOwnsFile (const std::string & path_str) const
120 { return _rpm.whoOwnsFile (path_str); }
122 /** Set the log file for target */
123 bool setInstallationLogfile(const Pathname & path_r);
125 /** return the last modification date of the target */
126 Date timestamp() const;
129 * reload the target in future calls if
131 * note the loading can actually be delayed, but
132 * the next call to resolvables must reflect the
133 * status of the system.
138 /** Path to the target */
143 /** Null implementation */
144 static TargetImpl_Ptr _nullimpl;
146 ///////////////////////////////////////////////////////////////////
148 /** \relates TargetImpl Stream output */
149 inline std::ostream & operator<<( std::ostream & str, const TargetImpl & obj )
151 return obj.dumpOn( str );
154 /////////////////////////////////////////////////////////////////
155 } // namespace target
156 ///////////////////////////////////////////////////////////////////
157 /////////////////////////////////////////////////////////////////
159 ///////////////////////////////////////////////////////////////////
160 #endif // ZYPP_TARGET_TARGETIMPL_H