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 
00038     typedef std::set<ui::Selectable::Ptr>             SelectableIndex;
00039     typedef std::map<ResObject::Kind,SelectableIndex> SelectablePool;
00040 
00041   public:
00043     class Impl;
00044 
00045     typedef SelectableIndex::iterator       iterator;
00046     typedef SelectableIndex::const_iterator const_iterator;
00047     typedef SelectableIndex::size_type      size_type;
00048 
00049   public:
00051     ResPoolProxy();
00053     ResPoolProxy( ResPool_Ref pool_r );
00055     ~ResPoolProxy();
00056 
00057   public:
00058 
00060     bool empty( const ResObject::Kind & kind_r ) const;
00061 
00062     template<class _Res>
00063       bool empty() const
00064       { return empty( ResTraits<_Res>::kind ); }
00065 
00067     size_type size( const ResObject::Kind & kind_r ) const;
00068 
00069     template<class _Res>
00070       size_type size() const
00071       { return size( ResTraits<_Res>::kind ); }
00072 
00075     const_iterator byKindBegin( const ResObject::Kind & kind_r ) const;
00076 
00077     template<class _Res>
00078       const_iterator byKindBegin() const
00079       { return byKindBegin( ResTraits<_Res>::kind ); }
00080 
00081 
00082     const_iterator byKindEnd( const ResObject::Kind & kind_r ) const;
00083 
00084     template<class _Res>
00085       const_iterator byKindEnd() const
00086       { return byKindEnd( ResTraits<_Res>::kind ); }
00088 
00089   public:
00093     bool hasInstalledObj( const ResObject::Kind & kind_r ) const
00094     {
00095       return(    make_begin<ui::selfilter::ByHasInstalledObj>( kind_r )
00096               != make_end<ui::selfilter::ByHasInstalledObj>( kind_r ) );
00097     }
00098 
00099     template<class _Res>
00100       bool hasInstalledObj() const
00101       { return hasInstalledObj( ResTraits<_Res>::kind ); }
00102 
00103   public:
00112     void saveState() const;
00113 
00114     void saveState( const ResObject::Kind & kind_r ) const;
00115 
00116     template<class _Res>
00117       void saveState() const
00118       { return saveState( ResTraits<_Res>::kind ); }
00119 
00120     void restoreState() const;
00121 
00122     void restoreState( const ResObject::Kind & kind_r ) const;
00123 
00124     template<class _Res>
00125       void restoreState() const
00126       { return restoreState( ResTraits<_Res>::kind ); }
00127 
00128     bool diffState() const;
00129 
00130     bool diffState( const ResObject::Kind & kind_r ) const;
00131 
00132     template<class _Res>
00133       bool diffState() const
00134       { return diffState( ResTraits<_Res>::kind ); }
00136 
00137   private:
00138     template<class _Filter>
00139       filter_iterator<_Filter,const_iterator>
00140       make_begin( _Filter filter_r, const ResObject::Kind & kind_r ) const
00141       {
00142         return make_filter_iterator( filter_r,
00143                                      byKindBegin(kind_r),
00144                                      byKindEnd(kind_r) );
00145       }
00146     template<class _Filter>
00147       filter_iterator<_Filter,const_iterator>
00148       make_begin( const ResObject::Kind & kind_r ) const
00149       {
00150         return make_begin( _Filter(), kind_r );
00151       }
00152 
00153 
00154     template<class _Filter>
00155       filter_iterator<_Filter,const_iterator>
00156       make_end( _Filter filter_r, const ResObject::Kind & kind_r ) const
00157       {
00158         return make_filter_iterator( filter_r,
00159                                      byKindEnd(kind_r),
00160                                      byKindEnd(kind_r) );
00161       }
00162     template<class _Filter>
00163       filter_iterator<_Filter,const_iterator>
00164       make_end( const ResObject::Kind & kind_r ) const
00165       {
00166         return make_end( _Filter(), kind_r );
00167       }
00168 
00169 
00171     RW_pointer<Impl> _pimpl;
00172   };
00174 
00176   std::ostream & operator<<( std::ostream & str, const ResPoolProxy & obj );
00177 
00179 } // namespace zypp
00181 #endif // ZYPP_RESPOOLPROXY_H

Generated on Thu Jul 6 00:07:22 2006 for zypp by  doxygen 1.4.6