libzypp  10.5.0
CommitPackageCacheImpl.h
Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                          ____ _   __ __ ___                          |
00003 |                         |__  / \ / / . \ . \                         |
00004 |                           / / \ V /|  _/  _/                         |
00005 |                          / /__ | | | | | |                           |
00006 |                         /_____||_| |_| |_|                           |
00007 |                                                                      |
00008 \---------------------------------------------------------------------*/
00012 #ifndef ZYPP_TARGET_COMMITPACKAGECACHEIMPL_H
00013 #define ZYPP_TARGET_COMMITPACKAGECACHEIMPL_H
00014 
00015 #include <iosfwd>
00016 
00017 #include "zypp/base/Logger.h"
00018 #include "zypp/base/Exception.h"
00019 
00020 #include "zypp/target/CommitPackageCache.h"
00021 
00023 namespace zypp
00024 { 
00025 
00026   namespace target
00027   { 
00028 
00030     //
00031     //  CLASS NAME : CommitPackageCache::Impl
00032     //
00039     class CommitPackageCache::Impl
00040     {
00041     public:
00042       typedef CommitPackageCache::PackageProvider  PackageProvider;
00043 
00044     public:
00045       Impl( const PackageProvider & packageProvider_r )
00046       : _packageProvider( packageProvider_r )
00047       {}
00048 
00049       virtual ~Impl()
00050       {}
00051 
00052     public:
00056       virtual ManagedFile get( const PoolItem & citem_r )
00057       {
00058         return sourceProvidePackage( citem_r );
00059       }
00060 
00061       void setCommitList( std::vector<sat::Solvable> commitList_r )
00062       { _commitList = commitList_r; }
00063 
00064     protected:
00066       virtual ManagedFile sourceProvidePackage( const PoolItem & pi ) const
00067       {
00068         if ( ! _packageProvider )
00069           {
00070             ZYPP_THROW( Exception("No package provider configured.") );
00071           }
00072 
00073         ManagedFile ret( _packageProvider( pi ) );
00074         if ( ret.value().empty() )
00075           {
00076             ZYPP_THROW( Exception("Package provider failed.") );
00077           }
00078 
00079         return ret;
00080       }
00081 
00082     protected:
00083       std::vector<sat::Solvable> _commitList;
00084 
00085     private:
00086       PackageProvider _packageProvider;
00087     };
00089 
00091     inline std::ostream & operator<<( std::ostream & str, const CommitPackageCache::Impl & obj )
00092     {
00093       return str << "CommitPackageCache::Impl";
00094     }
00095 
00097   } // namespace target
00100 } // namespace zypp
00102 #endif // ZYPP_TARGET_COMMITPACKAGECACHEIMPL_H