libzypp  11.13.5
ResPoolProxy.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
12 #ifndef ZYPP_RESPOOLPROXY_H
13 #define ZYPP_RESPOOLPROXY_H
14 
15 #include <iosfwd>
16 
17 #include "zypp/base/PtrTypes.h"
18 
19 #include "zypp/ResPool.h"
20 #include "zypp/ui/Selectable.h"
21 #include "zypp/ui/SelFilters.h"
22 
24 namespace zypp
25 {
26 
28  //
29  // CLASS NAME : ResPoolProxy
30  //
35  {
36  friend std::ostream & operator<<( std::ostream & str, const ResPoolProxy & obj );
37  friend std::ostream & dumpOn( std::ostream & str, const ResPoolProxy & obj );
38  typedef std::multimap<ResKind,ui::Selectable::Ptr> SelectablePool;
39 
40  public:
42  class Impl;
43 
46 
48 
49  public:
50 
58  ResPoolProxy();
59 
61  ~ResPoolProxy();
62 
63  public:
66  ui::Selectable::Ptr lookup( const pool::ByIdent & ident_r ) const;
67 
69  { return lookup( pool::ByIdent( ident_r ) ); }
70 
71  ui::Selectable::Ptr lookup( ResKind kind_r, const std::string & name_r ) const
72  { return lookup( pool::ByIdent( kind_r, name_r ) ); }
73 
74  ui::Selectable::Ptr lookup( const sat::Solvable & solv_r ) const
75  { return lookup( pool::ByIdent( solv_r ) ); }
76 
77  ui::Selectable::Ptr lookup( const ResObject::constPtr & resolvable_r ) const
78  { return resolvable_r ? lookup( resolvable_r->satSolvable() ) : ui::Selectable::Ptr(); }
79 
80  ui::Selectable::Ptr lookup( const PoolItem & pi_r ) const
81  { return lookup( pi_r.satSolvable() ); }
83 
84  public:
87  bool empty() const;
88  size_type size() const;
89  const_iterator begin() const;
90  const_iterator end() const;
92 
96  bool empty( const ResKind & kind_r ) const;
97 
98  template<class _Res>
99  bool empty() const
100  { return empty( ResTraits<_Res>::kind ); }
101 
103  size_type size( const ResKind & kind_r ) const;
104 
105  template<class _Res>
106  size_type size() const
107  { return size( ResTraits<_Res>::kind ); }
108 
109  const_iterator byKindBegin( const ResKind & kind_r ) const;
110 
111  template<class _Res>
113  { return byKindBegin( ResTraits<_Res>::kind ); }
114 
115 
116  const_iterator byKindEnd( const ResKind & kind_r ) const;
117 
118  template<class _Res>
120  { return byKindEnd( ResTraits<_Res>::kind ); }
122 
123  public:
128 
130 
133 
134  public:
138  bool hasInstalledObj( const ResKind & kind_r ) const
139  {
140  return( make_begin<ui::selfilter::ByHasInstalledObj>( kind_r )
141  != make_end<ui::selfilter::ByHasInstalledObj>( kind_r ) );
142  }
143 
144  template<class _Res>
145  bool hasInstalledObj() const
147 
148  public:
157  void saveState() const;
158 
159  void saveState( const ResKind & kind_r ) const;
160 
161  template<class _Res>
162  void saveState() const
163  { return saveState( ResTraits<_Res>::kind ); }
164 
165  void restoreState() const;
166 
167  void restoreState( const ResKind & kind_r ) const;
168 
169  template<class _Res>
170  void restoreState() const
171  { return restoreState( ResTraits<_Res>::kind ); }
172 
173  bool diffState() const;
174 
175  bool diffState( const ResKind & kind_r ) const;
176 
177  template<class _Res>
178  bool diffState() const
179  { return diffState( ResTraits<_Res>::kind ); }
181 
182  private:
183  template<class _Filter>
184  filter_iterator<_Filter,const_iterator>
185  make_begin( _Filter filter_r, const ResKind & kind_r ) const
186  {
187  return make_filter_iterator( filter_r,
188  byKindBegin(kind_r),
189  byKindEnd(kind_r) );
190  }
191  template<class _Filter>
192  filter_iterator<_Filter,const_iterator>
193  make_begin( const ResKind & kind_r ) const
194  {
195  return make_begin( _Filter(), kind_r );
196  }
197 
198 
199  template<class _Filter>
200  filter_iterator<_Filter,const_iterator>
201  make_end( _Filter filter_r, const ResKind & kind_r ) const
202  {
203  return make_filter_iterator( filter_r,
204  byKindEnd(kind_r),
205  byKindEnd(kind_r) );
206  }
207  template<class _Filter>
208  filter_iterator<_Filter,const_iterator>
209  make_end( const ResKind & kind_r ) const
210  {
211  return make_end( _Filter(), kind_r );
212  }
213 
214  private:
215  friend class pool::PoolImpl;
217  ResPoolProxy( ResPool pool_r, const pool::PoolImpl & poolImpl_r );
220  };
222 
224  std::ostream & operator<<( std::ostream & str, const ResPoolProxy & obj );
225 
227  std::ostream & dumpOn( std::ostream & str, const ResPoolProxy & obj );
228 
230 } // namespace zypp
232 #endif // ZYPP_RESPOOLPROXY_H