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"
31 ///////////////////////////////////////////////////////////////////
33 { /////////////////////////////////////////////////////////////////
34 ///////////////////////////////////////////////////////////////////
36 { /////////////////////////////////////////////////////////////////
38 DEFINE_PTR_TYPE(TargetImpl);
40 ///////////////////////////////////////////////////////////////////
42 // CLASS NAME : TargetImpl
44 /** Base class for concrete Target implementations.
46 * Constructed by \ref TargetFactory. Public access via \ref Target
49 class TargetImpl : public base::ReferenceCounted, private base::NonCopyable
51 friend std::ostream & operator<<( std::ostream & str, const TargetImpl & obj );
54 /** list of pool items */
55 typedef std::list<PoolItem_Ref> PoolItemList;
57 /** set of pool items */
58 typedef std::set<PoolItem_Ref> PoolItemSet;
61 /** JUST FOR TESTSUITE */
62 /** Sort according to prereqs and media numbers */
63 void getResolvablesToInsDel ( const ResPool pool_r,
64 PoolItemList & dellist_r,
65 PoolItemList & instlist_r,
66 PoolItemList & srclist_r ) const;
71 TargetImpl(const Pathname & root_r = "/");
73 virtual ~TargetImpl();
75 /** Null implementation */
76 static TargetImpl_Ptr nullimpl();
80 /** All resolvables in the target. */
81 const ResStore & resolvables();
83 /** The root set for this target */
84 Pathname root() const;
86 /** Commit changes in the pool
87 media = 0 means any/all medias
88 media > 0 means limit commits to this media */
89 int commit( ResPool pool_r, unsigned int medianr, PoolItemList & errors_r, PoolItemList & remaining_r, PoolItemList & srcremaining_r );
91 /** enables the storage target */
92 bool isStorageEnabled() const;
93 void enableStorage(const Pathname &root_r);
95 /** Commit ordered changes
96 return uncommitted ones (due to error) */
97 PoolItemList commit( const PoolItemList & items_r );
99 /** Overload to realize stream output. */
100 virtual std::ostream & dumpOn( std::ostream & str ) const
101 { return str << "TargetImpl"; }
103 /** The RPM database */
106 /** If the package is installed and provides the file
107 Needed to evaluate split provides during Resolver::Upgrade() */
108 bool providesFile (const std::string & path_str, const std::string & name_str) const;
110 /** Return the resolvable which provides path_str (rpm -qf)
111 return NULL if no resolvable provides this file */
112 ResObject::constPtr whoOwnsFile (const std::string & path_str) const;
114 /** Set the log file for target */
115 bool setInstallationLogfile(const Pathname & path_r);
118 /** All resolvables provided by the target. */
120 /** Path to the target */
124 #ifndef STORAGE_DISABLED
125 zypp::storage::PersistentStorage _storage;
126 bool _storage_enabled;
129 /** Null implementation */
130 static TargetImpl_Ptr _nullimpl;
132 /** wrapper with callback around getPlainRpm */
133 Pathname getRpmFile(Package::constPtr package);
135 ///////////////////////////////////////////////////////////////////
137 /** \relates TargetImpl Stream output */
138 inline std::ostream & operator<<( std::ostream & str, const TargetImpl & obj )
139 { return obj.dumpOn( str ); }
141 /////////////////////////////////////////////////////////////////
142 } // namespace target
143 ///////////////////////////////////////////////////////////////////
144 /////////////////////////////////////////////////////////////////
146 ///////////////////////////////////////////////////////////////////
147 #endif // ZYPP_TARGET_TARGETIMPL_H