1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/Target.h
17 #include "zypp/base/ReferenceCounted.h"
18 #include "zypp/base/NonCopyable.h"
19 #include "zypp/base/PtrTypes.h"
20 #include "zypp/base/Deprecated.h"
22 #include "zypp/ResStore.h"
23 #include "zypp/Pathname.h"
24 #include "zypp/ResPool.h"
26 ///////////////////////////////////////////////////////////////////
28 { /////////////////////////////////////////////////////////////////
41 DEFINE_PTR_TYPE(Target);
43 ///////////////////////////////////////////////////////////////////
45 // CLASS NAME : Target
49 class Target : public base::ReferenceCounted, public base::NonCopyable
52 typedef target::TargetImpl Impl;
53 typedef intrusive_ptr<Impl> Impl_Ptr;
54 typedef std::list<PoolItem_Ref> PoolItemList;
58 /** All resolvables provided by the target. */
59 const ResStore & resolvables();
61 /** Null implementation */
62 static Target_Ptr nullimpl();
64 /** Refference to the RPM database */
65 target::rpm::RpmDb & rpmDb();
67 /** Commit changes in the pool
68 * \param medianr 0 = all/any media
69 * > 0 means only the given media number
70 * return number of successfully committed resolvables
72 * \todo Interface to commit should be ZYpp::commit( medianr ). This call
73 * should be removed from the targets public interface, as soon as ZYpp::Impl
74 * is able to call Target::Impl.
76 int commit( ResPool pool_r, int medianr,
77 PoolItemList & errors_r,
78 PoolItemList & remaining_r,
79 PoolItemList & srcremaining_r,
80 bool dry_run = false ) ZYPP_DEPRECATED;
82 /** If the package is installed and provides the file
83 Needed to evaluate split provides during Resolver::Upgrade() */
84 bool providesFile (const std::string & name_str, const std::string & path_str) const;
86 ResObject::constPtr whoOwnsFile (const std::string & path_str) const;
88 /** JUST FOR TESTSUITE */
89 /** Sort according to prereqs and media numbers
90 * \todo provide it as standalone algorithm
92 void getResolvablesToInsDel ( const ResPool pool_r,
93 PoolItemList & dellist_r,
94 PoolItemList & instlist_r,
95 PoolItemList & srclist_r ) const;
97 #ifndef STORAGE_DISABLED
98 /** enables the storage target */
99 bool isStorageEnabled() const;
100 void enableStorage(const Pathname &root_r);
103 /** Set the log file for target */
104 bool setInstallationLogfile(const Pathname & path_r);
106 /** Return the root set for this target */
107 Pathname root() const;
112 Target( const Pathname & root = "/" );
115 Target( const Impl_Ptr & impl_r );
118 friend std::ostream & operator<<( std::ostream & str, const Target & obj );
119 /** Stream output. */
120 std::ostream & dumpOn( std::ostream & str ) const;
123 /** Direct access to Impl. */
124 friend class zypp_detail::ZYppImpl;
126 /** Pointer to implementation */
127 RW_pointer<Impl,rw_pointer::Intrusive<Impl> > _pimpl;
129 static Target_Ptr _nullimpl;
131 ///////////////////////////////////////////////////////////////////
133 /** \relates Target Stream output. */
134 inline std::ostream & operator<<( std::ostream & str, const Target & obj )
135 { return obj.dumpOn( str ); }
138 /////////////////////////////////////////////////////////////////
140 ///////////////////////////////////////////////////////////////////
141 #endif // ZYPP_TARGET_H