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"
31 #include "zypp/target/RequestedLocalesFile.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();
77 /** The root set for this target */
81 /** The directory to store things. */
83 { return _root / "/var/lib/zypp"; }
85 /** Commit changes in the pool */
86 ZYppCommitResult commit( ResPool pool_r, const ZYppCommitPolicy & policy_r );
88 ZYPP_DEPRECATED int commit( ResPool pool_r, unsigned int medianr,
89 PoolItemList & errors_r,
90 PoolItemList & remaining_r,
91 PoolItemList & srcremaining_r,
92 bool dry_run = false )
94 ZYppCommitPolicy policy;
95 policy.restrictToMedia( medianr ).dryRun( dry_run );
96 ZYppCommitResult res = commit( pool_r, policy );
97 errors_r.swap( res._errors );
98 remaining_r.swap( res._remaining );
99 srcremaining_r.swap( res._srcremaining );
103 /** Commit ordered changes
104 * @param pool_r only needed for #160792
105 * @return uncommitted ones (due to error)
107 PoolItemList commit( const PoolItemList & items_r, const ZYppCommitPolicy & policy_r, const ResPool & pool_r );
109 /** Install a source package on the Target. */
110 void installSrcPackage( const SrcPackage_constPtr & srcPackage_r );
112 /** Overload to realize stream output. */
113 virtual std::ostream & dumpOn( std::ostream & str ) const
115 return str << "TargetImpl";
118 /** The RPM database */
121 /** If the package is installed and provides the file
122 Needed to evaluate split provides during Resolver::Upgrade() */
123 bool providesFile (const std::string & path_str, const std::string & name_str) const;
125 /** Return name of package owning \a path_str
126 * or empty string if no installed package owns \a path_str. */
127 std::string whoOwnsFile (const std::string & path_str) const
128 { return _rpm.whoOwnsFile (path_str); }
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 /** Path to the target */
141 /** Requested Locales database */
142 RequestedLocalesFile _requestedLocalesFile;
144 /** Null implementation */
145 static TargetImpl_Ptr _nullimpl;
147 ///////////////////////////////////////////////////////////////////
149 /** \relates TargetImpl Stream output */
150 inline std::ostream & operator<<( std::ostream & str, const TargetImpl & obj )
152 return obj.dumpOn( str );
155 /////////////////////////////////////////////////////////////////
156 } // namespace target
157 ///////////////////////////////////////////////////////////////////
158 /////////////////////////////////////////////////////////////////
160 ///////////////////////////////////////////////////////////////////
161 #endif // ZYPP_TARGET_TARGETIMPL_H