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::const_iterator   const_iterator;
00043       typedef CommitPackageCache::PackageProvider  PackageProvider;
00044 
00045     public:
00046       Impl( const PackageProvider & packageProvider_r )
00047       : _packageProvider( packageProvider_r )
00048       {}
00049 
00050       virtual ~Impl()
00051       {}
00052 
00053     public:
00057       virtual ManagedFile get( const_iterator citem_r )
00058       {
00059         return sourceProvidePackage( *citem_r );
00060       }
00061 
00062     protected:
00064       ManagedFile sourceProvidePackage( const PoolItem & pi ) const
00065       {
00066         if ( ! _packageProvider )
00067           {
00068             ZYPP_THROW( Exception("No package provider configured.") );
00069           }
00070 
00071         ManagedFile ret( _packageProvider( pi ) );
00072         if ( ret.value().empty() )
00073           {
00074             ZYPP_THROW( Exception("Package provider failed.") );
00075           }
00076 
00077         return ret;
00078       }
00079 
00080     private:
00081       PackageProvider _packageProvider;
00082     };
00084 
00086     inline std::ostream & operator<<( std::ostream & str, const CommitPackageCache::Impl & obj )
00087     {
00088       return str << "CommitPackageCache::Impl";
00089     }
00090 
00092   } // namespace target
00095 } // namespace zypp
00097 #endif // ZYPP_TARGET_COMMITPACKAGECACHEIMPL_H

doxygen