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/PtrTypes.h"
22 #include "zypp/ResStore.h"
23 #include "zypp/PoolItem.h"
25 #include "zypp/Pathname.h"
26 #include "zypp/media/MediaAccess.h"
27 #include "zypp/Target.h"
28 #include "zypp/target/rpm/RpmDb.h"
29 #include "zypp/target/store/PersistentStorage.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_Ref> PoolItemList;
58 /** set of pool items */
59 typedef std::set<PoolItem_Ref> PoolItemSet;
62 /** JUST FOR TESTSUITE */
63 /** Sort according to prereqs and media numbers */
64 void getResolvablesToInsDel ( const ResPool pool_r,
65 PoolItemList & dellist_r,
66 PoolItemList & instlist_r,
67 PoolItemList & srclist_r ) const;
72 TargetImpl(const Pathname & root_r = "/");
74 virtual ~TargetImpl();
76 /** Null implementation */
77 static TargetImpl_Ptr nullimpl();
81 /** All resolvables in the target. */
82 const ResStore & resolvables();
84 /** The root set for this target */
85 Pathname root() const;
87 /** Commit changes in the pool
88 media = 0 means any/all medias
89 media > 0 means limit commits to this media */
90 int commit( ResPool pool_r, unsigned int medianr, PoolItemList & errors_r, PoolItemList & remaining_r, PoolItemList & srcremaining_r, bool dry_run = false );
92 /** enables the storage target */
93 bool isStorageEnabled() const;
94 void enableStorage(const Pathname &root_r);
96 /** Commit ordered changes
97 return uncommitted ones (due to error) */
98 PoolItemList commit( const PoolItemList & items_r, bool dry_run = false );
100 /** Overload to realize stream output. */
101 virtual std::ostream & dumpOn( std::ostream & str ) const
102 { return str << "TargetImpl"; }
104 /** The RPM database */
107 /** If the package is installed and provides the file
108 Needed to evaluate split provides during Resolver::Upgrade() */
109 bool providesFile (const std::string & path_str, const std::string & name_str) const;
111 /** Return the resolvable which provides path_str (rpm -qf)
112 return NULL if no resolvable provides this file */
113 ResObject::constPtr whoOwnsFile (const std::string & path_str) const;
115 /** Set the log file for target */
116 bool setInstallationLogfile(const Pathname & path_r);
119 /** All resolvables provided by the target. */
121 /** Path to the target */
125 #ifndef STORAGE_DISABLED
126 zypp::storage::PersistentStorage _storage;
127 bool _storage_enabled;
130 /** Null implementation */
131 static TargetImpl_Ptr _nullimpl;
133 /** wrapper with callback around getPlainRpm */
134 Pathname getRpmFile(Package::constPtr package);
136 ///////////////////////////////////////////////////////////////////
138 /** \relates TargetImpl Stream output */
139 inline std::ostream & operator<<( std::ostream & str, const TargetImpl & obj )
140 { return obj.dumpOn( str ); }
142 /////////////////////////////////////////////////////////////////
143 } // namespace target
144 ///////////////////////////////////////////////////////////////////
145 /////////////////////////////////////////////////////////////////
147 ///////////////////////////////////////////////////////////////////
148 #endif // ZYPP_TARGET_TARGETIMPL_H