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"
32 #include "zypp/target/SoftLocksFile.h"
34 ///////////////////////////////////////////////////////////////////
36 { /////////////////////////////////////////////////////////////////
37 ///////////////////////////////////////////////////////////////////
39 { /////////////////////////////////////////////////////////////////
41 DEFINE_PTR_TYPE(TargetImpl);
43 ///////////////////////////////////////////////////////////////////
45 // CLASS NAME : TargetImpl
47 /** Base class for concrete Target implementations.
49 * Constructed by \ref TargetFactory. Public access via \ref Target
52 class TargetImpl : public base::ReferenceCounted, private base::NonCopyable
54 friend std::ostream & operator<<( std::ostream & str, const TargetImpl & obj );
57 /** list of pool items */
58 typedef std::list<PoolItem> PoolItemList;
60 /** set of pool items */
61 typedef std::set<PoolItem> PoolItemSet;
65 TargetImpl(const Pathname & root_r = "/", bool doRebuild_r = false );
67 virtual ~TargetImpl();
69 /** Null implementation */
70 static TargetImpl_Ptr nullimpl();
82 /** The root set for this target */
86 /** The directory to store things. */
88 { return _root / "/var/lib/zypp"; }
90 /** Commit changes in the pool */
91 ZYppCommitResult commit( ResPool pool_r, const ZYppCommitPolicy & policy_r );
93 ZYPP_DEPRECATED int commit( ResPool pool_r, unsigned int medianr,
94 PoolItemList & errors_r,
95 PoolItemList & remaining_r,
96 PoolItemList & srcremaining_r,
97 bool dry_run = false )
99 ZYppCommitPolicy policy;
100 policy.restrictToMedia( medianr ).dryRun( dry_run );
101 ZYppCommitResult res = commit( pool_r, policy );
102 errors_r.swap( res._errors );
103 remaining_r.swap( res._remaining );
104 srcremaining_r.swap( res._srcremaining );
108 /** Commit ordered changes
109 * @param pool_r only needed for #160792
110 * @return uncommitted ones (due to error)
112 PoolItemList commit( const PoolItemList & items_r, const ZYppCommitPolicy & policy_r, const ResPool & pool_r );
114 /** Install a source package on the Target. */
115 void installSrcPackage( const SrcPackage_constPtr & srcPackage_r );
117 /** Overload to realize stream output. */
118 virtual std::ostream & dumpOn( std::ostream & str ) const
120 return str << "TargetImpl";
123 /** The RPM database */
126 /** If the package is installed and provides the file
127 Needed to evaluate split provides during Resolver::Upgrade() */
128 bool providesFile (const std::string & path_str, const std::string & name_str) const;
130 /** Return name of package owning \a path_str
131 * or empty string if no installed package owns \a path_str. */
132 std::string whoOwnsFile (const std::string & path_str) const
133 { return _rpm.whoOwnsFile (path_str); }
135 /** Set the log file for target */
136 bool setInstallationLogfile(const Pathname & path_r);
138 /** return the last modification date of the target */
139 Date timestamp() const;
141 /** The targets distribution release string.
143 * openSUSE 10.3 (i586)
146 std::string release() const;
149 /** Path to the target */
153 /** Requested Locales database */
154 RequestedLocalesFile _requestedLocalesFile;
155 /** Soft-locks database */
156 SoftLocksFile _softLocksFile;
158 /** Null implementation */
159 static TargetImpl_Ptr _nullimpl;
161 ///////////////////////////////////////////////////////////////////
163 /** \relates TargetImpl Stream output */
164 inline std::ostream & operator<<( std::ostream & str, const TargetImpl & obj )
166 return obj.dumpOn( str );
169 /////////////////////////////////////////////////////////////////
170 } // namespace target
171 ///////////////////////////////////////////////////////////////////
172 /////////////////////////////////////////////////////////////////
174 ///////////////////////////////////////////////////////////////////
175 #endif // ZYPP_TARGET_TARGETIMPL_H