libzypp 17.31.6
SolvIterMixin.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
12#ifndef ZYPP_SAT_SOLVITERMIXIN_H
13#define ZYPP_SAT_SOLVITERMIXIN_H
14
15#include <iosfwd>
16
17#include <zypp/base/PtrTypes.h>
18#include <zypp/base/Iterator.h>
19#include <zypp/base/Hash.h>
20
21#include <zypp/sat/Solvable.h>
22#include <zypp/PoolItem.h>
23#include <zypp/ui/Selectable.h>
24
26namespace zypp
27{
28
30 namespace sat
31 {
32
33 class Solvable;
34 //class asSolvable; // transform functor
35
36 namespace solvitermixin_detail
37 {
44 {
45 bool operator()( const Solvable & solv_r ) const;
46
47 typedef std::unordered_set<unsigned> Uset;
49 : _uset( new Uset )
50 {}
51 shared_ptr<Uset> _uset;
52 };
53
54
55 } // namespace solvitermixin_detail
56
57
59 //
60 // CLASS NAME : SolvIterMixin<Derived,DerivedSolvable_iterator>
61 //
115 template <class Derived,class DerivedSolvable_iterator>
117 {
118 public:
119 typedef size_t size_type;
120
121 public:
128 bool empty() const
129 { return( self().begin() == self().end() ); }
130
133 { size_type s = 0; for_( it, self().begin(), self().end() ) ++s; return s;}
134
136 template<class TSolv>
137 bool contains( const TSolv & solv_r ) const
138 {
139 Solvable solv( asSolvable()( solv_r ) );
140 for_( it, self().begin(), self().end() )
141 if ( *it == solv )
142 return true;
143 return false;
144 }
146
147 public:
150 typedef DerivedSolvable_iterator Solvable_iterator;
152 { return self().begin(); }
154 { return self().end(); }
156 { return makeIterable( solvableBegin(), solvableEnd() ); }
158
161 typedef transform_iterator<asPoolItem,Solvable_iterator> PoolItem_iterator;
163 { return make_transform_iterator( solvableBegin(), asPoolItem() ); }
165 { return make_transform_iterator( solvableEnd(), asPoolItem() ); }
167 { return makeIterable( poolItemBegin(), poolItemEnd() ); }
169
170 private:
171 typedef filter_iterator<solvitermixin_detail::UnifyByIdent,Solvable_iterator> UnifiedSolvable_iterator;
172 public:
175 typedef transform_iterator<ui::asSelectable,UnifiedSolvable_iterator> Selectable_iterator;
177 { return make_transform_iterator( unifiedSolvableBegin(), ui::asSelectable() ); }
179 { return make_transform_iterator( unifiedSolvableEnd(), ui::asSelectable() ); }
181 { return makeIterable( selectableBegin(), selectableEnd() ); }
183
184 private:
188 { return make_filter_iterator( solvitermixin_detail::UnifyByIdent(), solvableBegin(), solvableEnd() ); }
190 { return make_filter_iterator( solvitermixin_detail::UnifyByIdent(), solvableEnd(), solvableEnd() ); }
192 { return makeIterable( unifiedSolvableBegin(), unifiedSolvableEnd() ); }
194 private:
195 const Derived & self() const
196 { return *static_cast<const Derived*>( this ); }
197 protected:
201 void operator=(const SolvIterMixin &) {}
202 };
204
206 } // namespace sat
209} // namespace zypp
211#endif // ZYPP_SAT_SOLVITERMIXIN_H
Base class providing common iterator types based on a Solvable iterator.
transform_iterator< asPoolItem, Solvable_iterator > PoolItem_iterator
Solvable_iterator solvableBegin() const
SolvIterMixin(const SolvIterMixin &)
Selectable_iterator selectableBegin() const
void operator=(const SolvIterMixin &)
Iterable< Solvable_iterator > solvable() const
filter_iterator< solvitermixin_detail::UnifyByIdent, Solvable_iterator > UnifiedSolvable_iterator
DerivedSolvable_iterator Solvable_iterator
bool contains(const TSolv &solv_r) const
Whether collection contains a specific Solvable.
transform_iterator< ui::asSelectable, UnifiedSolvable_iterator > Selectable_iterator
Iterable< UnifiedSolvable_iterator > unifiedSolvable() const
PoolItem_iterator poolItemEnd() const
Selectable_iterator selectableEnd() const
Iterable< PoolItem_iterator > poolItem() const
Solvable_iterator solvableEnd() const
PoolItem_iterator poolItemBegin() const
const Derived & self() const
bool empty() const
Whether the collection is epmty.
UnifiedSolvable_iterator unifiedSolvableBegin() const
Iterable< Selectable_iterator > selectable() const
UnifiedSolvable_iterator unifiedSolvableEnd() const
size_type size() const
Size of the collection.
A Solvable object within the sat Pool.
Definition: Solvable.h:54
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2
Solvable to PoolItem transform functor.
Definition: PoolItem.h:205
To Solvable transform functor.
Definition: Solvable.h:562
std::unordered_set< unsigned > Uset
Definition: SolvIterMixin.h:47
bool operator()(const Solvable &solv_r) const
Solvable to Selectable transform functor.
Definition: Selectable.h:580
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
Definition: Easy.h:28