00001
00002
00003
00004
00005
00006
00007
00008
00012 #ifndef ZYPP_TARGET_TARGETIMPL_H
00013 #define ZYPP_TARGET_TARGETIMPL_H
00014
00015 #include <iosfwd>
00016 #include <list>
00017 #include <set>
00018
00019 #include "zypp/base/ReferenceCounted.h"
00020 #include "zypp/base/NonCopyable.h"
00021 #include "zypp/base/PtrTypes.h"
00022 #include "zypp/ResStore.h"
00023 #include "zypp/PoolItem.h"
00024 #include "zypp/ZYppCommit.h"
00025
00026 #include "zypp/Pathname.h"
00027 #include "zypp/media/MediaAccess.h"
00028 #include "zypp/Target.h"
00029 #include "zypp/target/rpm/RpmDb.h"
00030 #include "zypp/target/store/PersistentStorage.h"
00031 #include "zypp/target/TargetException.h"
00032
00034 namespace zypp
00035 {
00036
00037 namespace target
00038 {
00039
00040 DEFINE_PTR_TYPE(TargetImpl);
00041
00043
00044
00045
00051 class TargetImpl : public base::ReferenceCounted, private base::NonCopyable
00052 {
00053 friend std::ostream & operator<<( std::ostream & str, const TargetImpl & obj );
00054
00055 public:
00057 typedef std::list<PoolItem_Ref> PoolItemList;
00058
00060 typedef std::set<PoolItem_Ref> PoolItemSet;
00061
00062 public:
00065 void getResolvablesToInsDel ( const ResPool pool_r,
00066 PoolItemList & dellist_r,
00067 PoolItemList & instlist_r,
00068 PoolItemList & srclist_r ) const;
00069
00070
00071 public:
00073 TargetImpl(const Pathname & root_r = "/");
00075 virtual ~TargetImpl();
00076
00078 static TargetImpl_Ptr nullimpl();
00079
00080 public:
00081
00083 const ResStore & resolvables();
00084
00086 Pathname root() const;
00087
00089 ZYppCommitResult commit( ResPool pool_r, const ZYppCommitPolicy & policy_r );
00090
00091 ZYPP_DEPRECATED int commit( ResPool pool_r, unsigned int medianr,
00092 PoolItemList & errors_r,
00093 PoolItemList & remaining_r,
00094 PoolItemList & srcremaining_r,
00095 bool dry_run = false )
00096 {
00097 ZYppCommitPolicy policy;
00098 policy.restrictToMedia( medianr ).dryRun( dry_run );
00099 ZYppCommitResult res = commit( pool_r, policy );
00100 errors_r.swap( res._errors );
00101 remaining_r.swap( res._remaining );
00102 srcremaining_r.swap( res._srcremaining );
00103 return res._result;
00104 }
00105
00107 bool isStorageEnabled() const;
00108 void enableStorage(const Pathname &root_r);
00109
00114 PoolItemList commit( const PoolItemList & items_r, const ZYppCommitPolicy & policy_r, const ResPool & pool_r );
00115
00117 virtual std::ostream & dumpOn( std::ostream & str ) const
00118 { return str << "TargetImpl"; }
00119
00121 rpm::RpmDb & rpm();
00122
00125 bool providesFile (const std::string & path_str, const std::string & name_str) const;
00126
00129 ResObject::constPtr whoOwnsFile (const std::string & path_str) const;
00130
00132 bool setInstallationLogfile(const Pathname & path_r);
00133
00134 protected:
00136 ResStore _store;
00138 Pathname _root;
00140 rpm::RpmDb _rpm;
00141 #ifndef STORAGE_DISABLED
00142 zypp::storage::PersistentStorage _storage;
00143 bool _storage_enabled;
00144 #endif
00145 private:
00147 static TargetImpl_Ptr _nullimpl;
00148 };
00150
00152 inline std::ostream & operator<<( std::ostream & str, const TargetImpl & obj )
00153 { return obj.dumpOn( str ); }
00154
00156 }
00159 }
00161 #endif // ZYPP_TARGET_TARGETIMPL_H