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:
00065 TargetImpl(const Pathname & root_r = "/");
00067 virtual ~TargetImpl();
00068
00070 static TargetImpl_Ptr nullimpl();
00071
00072 public:
00073
00075 const ResStore & resolvables();
00076
00082 ResStore::resfilter_const_iterator byKindBegin( const ResObject::Kind & kind_r ) const;
00083 ResStore::resfilter_const_iterator byKindEnd( const ResObject::Kind & kind_r ) const;
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 void installSrcPackage( const SrcPackage_constPtr & srcPackage_r );
00118
00120 virtual std::ostream & dumpOn( std::ostream & str ) const
00121 {
00122 return str << "TargetImpl";
00123 }
00124
00126 rpm::RpmDb & rpm();
00127
00130 bool providesFile (const std::string & path_str, const std::string & name_str) const;
00131
00134 ResObject::constPtr whoOwnsFile (const std::string & path_str) const;
00135
00137 bool setInstallationLogfile(const Pathname & path_r);
00138
00140 Date timestamp() const;
00141
00149 void reset();
00150
00151 protected:
00152 void loadKindResolvables( const Resolvable::Kind kind );
00154 ResStore _store;
00156 Pathname _root;
00158 rpm::RpmDb _rpm;
00159 #ifndef STORAGE_DISABLED
00160 zypp::storage::PersistentStorage _storage;
00161 bool _storage_enabled;
00162 std::map< const Resolvable::Kind, DefaultFalseBool> _resstore_loaded;
00163 #endif
00164 private:
00166 static TargetImpl_Ptr _nullimpl;
00167 };
00169
00171 inline std::ostream & operator<<( std::ostream & str, const TargetImpl & obj )
00172 {
00173 return obj.dumpOn( str );
00174 }
00175
00177 }
00180 }
00182 #endif // ZYPP_TARGET_TARGETIMPL_H