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/DefaultFalseBool.h"
00022 #include "zypp/base/PtrTypes.h"
00023 #include "zypp/ResStore.h"
00024 #include "zypp/PoolItem.h"
00025 #include "zypp/ZYppCommit.h"
00026
00027 #include "zypp/Pathname.h"
00028 #include "zypp/media/MediaAccess.h"
00029 #include "zypp/Target.h"
00030 #include "zypp/target/rpm/RpmDb.h"
00031 #include "zypp/target/store/PersistentStorage.h"
00032 #include "zypp/target/TargetException.h"
00033
00035 namespace zypp
00036 {
00037
00038 namespace target
00039 {
00040
00041 DEFINE_PTR_TYPE(TargetImpl);
00042
00044
00045
00046
00052 class TargetImpl : public base::ReferenceCounted, private base::NonCopyable
00053 {
00054 friend std::ostream & operator<<( std::ostream & str, const TargetImpl & obj );
00055
00056 public:
00058 typedef std::list<PoolItem_Ref> PoolItemList;
00059
00061 typedef std::set<PoolItem_Ref> PoolItemSet;
00062
00063 public:
00066 void getResolvablesToInsDel ( const ResPool pool_r,
00067 PoolItemList & dellist_r,
00068 PoolItemList & instlist_r,
00069 PoolItemList & srclist_r ) const;
00070
00071
00072 public:
00074 TargetImpl(const Pathname & root_r = "/");
00076 virtual ~TargetImpl();
00077
00079 static TargetImpl_Ptr nullimpl();
00080
00081 public:
00082
00084 const ResStore & resolvables();
00085
00091 ResStore::resfilter_const_iterator byKindBegin( const ResObject::Kind & kind_r ) const;
00092 ResStore::resfilter_const_iterator byKindEnd( const ResObject::Kind & kind_r ) const;
00093
00095 Pathname root() const;
00096
00098 ZYppCommitResult commit( ResPool pool_r, const ZYppCommitPolicy & policy_r );
00099
00100 ZYPP_DEPRECATED int commit( ResPool pool_r, unsigned int medianr,
00101 PoolItemList & errors_r,
00102 PoolItemList & remaining_r,
00103 PoolItemList & srcremaining_r,
00104 bool dry_run = false )
00105 {
00106 ZYppCommitPolicy policy;
00107 policy.restrictToMedia( medianr ).dryRun( dry_run );
00108 ZYppCommitResult res = commit( pool_r, policy );
00109 errors_r.swap( res._errors );
00110 remaining_r.swap( res._remaining );
00111 srcremaining_r.swap( res._srcremaining );
00112 return res._result;
00113 }
00114
00116 bool isStorageEnabled() const;
00117 void enableStorage(const Pathname &root_r);
00118
00123 PoolItemList commit( const PoolItemList & items_r, const ZYppCommitPolicy & policy_r, const ResPool & pool_r );
00124
00126 virtual std::ostream & dumpOn( std::ostream & str ) const
00127 {
00128 return str << "TargetImpl";
00129 }
00130
00132 rpm::RpmDb & rpm();
00133
00136 bool providesFile (const std::string & path_str, const std::string & name_str) const;
00137
00140 ResObject::constPtr whoOwnsFile (const std::string & path_str) const;
00141
00143 bool setInstallationLogfile(const Pathname & path_r);
00144
00146 Date timestamp() const;
00147
00155 void reset();
00156
00157 protected:
00158 void loadKindResolvables( const Resolvable::Kind kind );
00160 ResStore _store;
00162 Pathname _root;
00164 rpm::RpmDb _rpm;
00165 #ifndef STORAGE_DISABLED
00166 zypp::storage::PersistentStorage _storage;
00167 bool _storage_enabled;
00168 std::map< const Resolvable::Kind, DefaultFalseBool> _resstore_loaded;
00169 #endif
00170 private:
00172 static TargetImpl_Ptr _nullimpl;
00173 };
00175
00177 inline std::ostream & operator<<( std::ostream & str, const TargetImpl & obj )
00178 {
00179 return obj.dumpOn( str );
00180 }
00181
00183 }
00186 }
00188 #endif // ZYPP_TARGET_TARGETIMPL_H