libzypp  10.5.0
ResPoolProxy.h
Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                          ____ _   __ __ ___                          |
00003 |                         |__  / \ / / . \ . \                         |
00004 |                           / / \ V /|  _/  _/                         |
00005 |                          / /__ | | | | | |                           |
00006 |                         /_____||_| |_| |_|                           |
00007 |                                                                      |
00008 \---------------------------------------------------------------------*/
00012 #ifndef ZYPP_RESPOOLPROXY_H
00013 #define ZYPP_RESPOOLPROXY_H
00014 
00015 #include <iosfwd>
00016 
00017 #include "zypp/base/PtrTypes.h"
00018 
00019 #include "zypp/ResPool.h"
00020 #include "zypp/ui/Selectable.h"
00021 #include "zypp/ui/SelFilters.h"
00022 
00024 namespace zypp
00025 { 
00026 
00028   //
00029   //    CLASS NAME : ResPoolProxy
00030   //
00034   class ResPoolProxy
00035   {
00036     friend std::ostream & operator<<( std::ostream & str, const ResPoolProxy & obj );
00037     friend std::ostream & dumpOn( std::ostream & str, const ResPoolProxy & obj );
00038     typedef std::multimap<ResKind,ui::Selectable::Ptr> SelectablePool;
00039 
00040   public:
00042     class Impl;
00043 
00044     typedef MapKVIteratorTraits<SelectablePool>::Value_const_iterator const_iterator;
00045     typedef SelectablePool::size_type size_type;
00046 
00047     typedef ResPool::repository_iterator    repository_iterator;
00048 
00049   public:
00050 
00058     ResPoolProxy();
00059 
00061     ~ResPoolProxy();
00062 
00063   public:
00066     ui::Selectable::Ptr lookup( const pool::ByIdent & ident_r ) const;
00067 
00068     ui::Selectable::Ptr lookup( IdString ident_r ) const
00069     { return lookup( pool::ByIdent( ident_r ) ); }
00070 
00071     ui::Selectable::Ptr lookup( ResKind kind_r, const std::string & name_r ) const
00072     { return lookup( pool::ByIdent( kind_r, name_r ) ); }
00073 
00074     ui::Selectable::Ptr lookup( const sat::Solvable & solv_r ) const
00075     { return lookup( pool::ByIdent( solv_r ) ); }
00076 
00077     ui::Selectable::Ptr lookup( const ResObject::constPtr & resolvable_r ) const
00078     { return resolvable_r ? lookup( resolvable_r->satSolvable() ) : ui::Selectable::Ptr(); }
00079 
00080     ui::Selectable::Ptr lookup( const PoolItem & pi_r ) const
00081     { return lookup( pi_r.satSolvable() ); }
00083 
00084   public:
00087     bool empty() const;
00088     size_type size() const;
00089     const_iterator begin() const;
00090     const_iterator end() const;
00092 
00096     bool empty( const ResKind & kind_r ) const;
00097 
00098     template<class _Res>
00099       bool empty() const
00100       { return empty( ResTraits<_Res>::kind ); }
00101 
00103     size_type size( const ResKind & kind_r ) const;
00104 
00105     template<class _Res>
00106       size_type size() const
00107       { return size( ResTraits<_Res>::kind ); }
00108 
00109     const_iterator byKindBegin( const ResKind & kind_r ) const;
00110 
00111     template<class _Res>
00112       const_iterator byKindBegin() const
00113       { return byKindBegin( ResTraits<_Res>::kind ); }
00114 
00115 
00116     const_iterator byKindEnd( const ResKind & kind_r ) const;
00117 
00118     template<class _Res>
00119       const_iterator byKindEnd() const
00120       { return byKindEnd( ResTraits<_Res>::kind ); }
00122 
00123  public:
00127    size_type knownRepositoriesSize() const;
00128 
00129    repository_iterator knownRepositoriesBegin() const;
00130 
00131    repository_iterator knownRepositoriesEnd() const;
00133 
00134   public:
00138     bool hasInstalledObj( const ResKind & kind_r ) const
00139     {
00140       return(    make_begin<ui::selfilter::ByHasInstalledObj>( kind_r )
00141               != make_end<ui::selfilter::ByHasInstalledObj>( kind_r ) );
00142     }
00143 
00144     template<class _Res>
00145       bool hasInstalledObj() const
00146       { return hasInstalledObj( ResTraits<_Res>::kind ); }
00147 
00148   public:
00157     void saveState() const;
00158 
00159     void saveState( const ResKind & kind_r ) const;
00160 
00161     template<class _Res>
00162       void saveState() const
00163       { return saveState( ResTraits<_Res>::kind ); }
00164 
00165     void restoreState() const;
00166 
00167     void restoreState( const ResKind & kind_r ) const;
00168 
00169     template<class _Res>
00170       void restoreState() const
00171       { return restoreState( ResTraits<_Res>::kind ); }
00172 
00173     bool diffState() const;
00174 
00175     bool diffState( const ResKind & kind_r ) const;
00176 
00177     template<class _Res>
00178       bool diffState() const
00179       { return diffState( ResTraits<_Res>::kind ); }
00181 
00182   private:
00183     template<class _Filter>
00184       filter_iterator<_Filter,const_iterator>
00185       make_begin( _Filter filter_r, const ResKind & kind_r ) const
00186       {
00187         return make_filter_iterator( filter_r,
00188                                      byKindBegin(kind_r),
00189                                      byKindEnd(kind_r) );
00190       }
00191     template<class _Filter>
00192       filter_iterator<_Filter,const_iterator>
00193       make_begin( const ResKind & kind_r ) const
00194       {
00195         return make_begin( _Filter(), kind_r );
00196       }
00197 
00198 
00199     template<class _Filter>
00200       filter_iterator<_Filter,const_iterator>
00201       make_end( _Filter filter_r, const ResKind & kind_r ) const
00202       {
00203         return make_filter_iterator( filter_r,
00204                                      byKindEnd(kind_r),
00205                                      byKindEnd(kind_r) );
00206       }
00207     template<class _Filter>
00208       filter_iterator<_Filter,const_iterator>
00209       make_end( const ResKind & kind_r ) const
00210       {
00211         return make_end( _Filter(), kind_r );
00212       }
00213 
00214   private:
00215     friend class pool::PoolImpl;
00217     ResPoolProxy( ResPool pool_r, const pool::PoolImpl & poolImpl_r );
00219     RW_pointer<Impl> _pimpl;
00220   };
00222 
00224   std::ostream & operator<<( std::ostream & str, const ResPoolProxy & obj );
00225 
00227   std::ostream & dumpOn( std::ostream & str, const ResPoolProxy & obj );
00228 
00230 } // namespace zypp
00232 #endif // ZYPP_RESPOOLPROXY_H