libzypp  13.10.6
SolvableSet.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
12 #ifndef ZYPP_SAT_SOLVABLESET_H
13 #define ZYPP_SAT_SOLVABLESET_H
14 
15 #include <iosfwd>
16 
17 #include "zypp/base/PtrTypes.h"
18 #include "zypp/base/Tr1hash.h"
19 #include "zypp/sat/Solvable.h"
20 #include "zypp/sat/SolvIterMixin.h"
21 
23 namespace zypp
24 {
25  namespace sat
27  {
28 
30  //
31  // CLASS NAME : SolvableSet
32  //
35  class SolvableSet : public SolvIterMixin<SolvableSet,std::tr1::unordered_set<Solvable>::const_iterator>
36  {
37  friend std::ostream & operator<<( std::ostream & str, const SolvableSet & obj );
38 
39  public:
40  typedef std::tr1::unordered_set<Solvable> Container;
41  typedef Container::value_type value_type;
43  typedef Solvable_iterator const_iterator; // from SolvIterMixin
44 
45  public:
48  : _pimpl( new Container )
49  {}
50 
52  template<class _InputIterator>
53  SolvableSet( _InputIterator begin_r, _InputIterator end_r )
54  : _pimpl( new Container( begin_r, end_r ) )
55  {}
56 
57  public:
59  bool empty() const
60  { return _pimpl->empty(); }
61 
63  size_type size() const
64  { return _pimpl->size(); }
65 
67  template<class _Solv>
68  bool contains( const _Solv & solv_r ) const
69  { return( get().find( asSolvable()( solv_r ) ) != end() ); }
70 
73  { return _pimpl->begin(); }
74 
77  { return _pimpl->end(); }
78 
79  public:
80 
84  template<class _Solv>
85  bool insert( const _Solv & solv_r )
86  { return get().insert( asSolvable()( solv_r ) ).second; }
87 
88  public:
90  Container & get()
91  { return *_pimpl; }
92 
94  const Container & get() const
95  { return *_pimpl; }
96 
97  private:
100  };
102 
104  std::ostream & operator<<( std::ostream & str, const SolvableSet & obj );
105 
107  } // namespace sat
110 } // namespace zypp
112 #endif // ZYPP_SAT_SOLVABLESET_H
std::ostream & operator<<(std::ostream &str, const LocaleSupport &obj)
SolvableSet()
Default ctor.
Definition: SolvableSet.h:47
SolvableSet(_InputIterator begin_r, _InputIterator end_r)
Ctor building a set from a range.
Definition: SolvableSet.h:53
RWCOW_pointer< Container > _pimpl
Pointer to implementation.
Definition: SolvableSet.h:99
bool contains(const _Solv &solv_r) const
Definition: SolvableSet.h:68
const_iterator begin() const
Iterator pointing to the first Solvable.
Definition: SolvableSet.h:72
size_type size() const
Size of the set.
Definition: SolvableSet.h:63
const_iterator end() const
Iterator pointing behind the last Solvable.
Definition: SolvableSet.h:76
Base class providing common iterator types based on a Solvable iterator.
Container::value_type value_type
Definition: SolvableSet.h:41
bool empty() const
Whether the set is epmty.
Definition: SolvableSet.h:59
std::tr1::unordered_set< Solvable > Container
Definition: SolvableSet.h:40
bool insert(const _Solv &solv_r)
Insert a Solvable.
Definition: SolvableSet.h:85
SolvableIdType size_type
Definition: PoolMember.h:99
Solvable_iterator const_iterator
Definition: SolvableSet.h:43
Container::size_type size_type
Definition: SolvableSet.h:42
To Solvable transform functor.
Definition: Solvable.h:398
friend std::ostream & operator<<(std::ostream &str, const SolvableSet &obj)
Definition: SolvableSet.cc:31
Solvable set wrapper to allow adding additioanal convenience iterators.
Definition: SolvableSet.h:35