libzypp: zypp/sat/SolvableSet.h Source File

libzypp 17.38.11

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-core/base/PtrTypes.h>
18#include <zypp-core/base/Hash.h>
19#include <zypp/sat/Solvable.h>
20#include <zypp/sat/SolvIterMixin.h>
21
23namespace zypp
24{
26 namespace sat
27 {
28
30 //
31 // CLASS NAME : SolvableSet
32 //
35 class SolvableSet : public SolvIterMixin<SolvableSet,std::unordered_set<Solvable>::const_iterator>
36 {
37 friend std::ostream & operator<<( std::ostream & str, const SolvableSet & obj );
38
39 public:
40 using Container = std::unordered_set<Solvable>;
41 using value_type = Container::value_type;
42 using size_type = Container::size_type;
43 using const_iterator = Solvable_iterator; // from SolvIterMixin
44
45 public:
47 SolvableSet()
48 : _pimpl( new Container )
49 {}
50
52 template<class TInputIterator>
53 SolvableSet( TInputIterator begin_r, TInputIterator 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 TSolv>
68 bool contains( const TSolv & solv_r ) const
69 { return( get().count( asSolvable()( solv_r ) ) ); }
70
72 const_iterator begin() const
73 { return _pimpl->begin(); }
74
76 const_iterator end() const
77 { return _pimpl->end(); }
78
79 public:
81 void clear()
82 { get().clear(); }
83
87 template<class TSolv>
88 bool insert( const TSolv & solv_r )
89 { return get().insert( asSolvable()( solv_r ) ).second; }
90
92 template<class TIterator>
93 void insert( TIterator begin_r, TIterator end_r )
94 { for_( it, begin_r, end_r ) insert( *it ); }
95
96 public:
98 Container & get()
99 { return *_pimpl; }
100
102 const Container & get() const
103 { return *_pimpl; }
104
105 private:
107 RWCOW_pointer<Container> _pimpl;
108 };
109
110
112 std::ostream & operator<<( std::ostream & str, const SolvableSet & obj ) ZYPP_API;
113
115 } // namespace sat
118} // namespace zypp
120#endif // ZYPP_SAT_SOLVABLESET_H
for_
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
Definition Easy.h:27
Hash.h
PtrTypes.h
SolvIterMixin.h
Solvable.h
zypp::sat::SolvIterMixin< SolvableSet, std::unordered_set< Solvable >::const_iterator >::Solvable_iterator
std::unordered_set< Solvable >::const_iterator Solvable_iterator
Definition SolvIterMixin.h:164
zypp::sat::SolvIterMixin< SolvableSet, std::unordered_set< Solvable >::const_iterator >::SolvIterMixin
SolvIterMixin()
Definition SolvIterMixin.h:212
zypp::sat::SolvableSet
Solvable set wrapper to allow adding additional convenience iterators.
Definition SolvableSet.h:36
zypp::sat::SolvableSet::get
Container & get()
The set.
Definition SolvableSet.h:98
zypp::sat::SolvableSet::_pimpl
RWCOW_pointer< Container > _pimpl
Pointer to implementation.
Definition SolvableSet.h:107
zypp::sat::SolvableSet::get
const Container & get() const
The set.
Definition SolvableSet.h:102
zypp::sat::SolvableSet::value_type
Container::value_type value_type
Definition SolvableSet.h:41
zypp::sat::SolvableSet::clear
void clear()
Clear the container.
Definition SolvableSet.h:81
zypp::sat::SolvableSet::empty
bool empty() const
Whether the set is epmty.
Definition SolvableSet.h:59
zypp::sat::SolvableSet::size_type
Container::size_type size_type
Definition SolvableSet.h:42
zypp::sat::SolvableSet::size
size_type size() const
Size of the set.
Definition SolvableSet.h:63
zypp::sat::SolvableSet::insert
bool insert(const TSolv &solv_r)
Insert a Solvable.
Definition SolvableSet.h:88
zypp::sat::SolvableSet::Container
std::unordered_set< Solvable > Container
Definition SolvableSet.h:40
zypp::sat::SolvableSet::end
const_iterator end() const
Iterator pointing behind the last Solvable.
Definition SolvableSet.h:76
zypp::sat::SolvableSet::operator<<
friend std::ostream & operator<<(std::ostream &str, const SolvableSet &obj)
relates: SolvableSet Stream output
Definition SolvableSet.cc:31
zypp::sat::SolvableSet::contains
bool contains(const TSolv &solv_r) const
Definition SolvableSet.h:68
zypp::sat::SolvableSet::insert
void insert(TIterator begin_r, TIterator end_r)
Insert a range of Solvables.
Definition SolvableSet.h:93
zypp::sat::SolvableSet::SolvableSet
SolvableSet()
Default ctor.
Definition SolvableSet.h:47
zypp::sat::SolvableSet::begin
const_iterator begin() const
Iterator pointing to the first Solvable.
Definition SolvableSet.h:72
zypp::sat::SolvableSet::SolvableSet
SolvableSet(TInputIterator begin_r, TInputIterator end_r)
Ctor building a set from a range.
Definition SolvableSet.h:53
zypp::sat::SolvableSet::const_iterator
Solvable_iterator const_iterator
Definition SolvableSet.h:43
str
String related utilities and Regular expression matching.
zypp::sat
Libsolv interface
zypp::sat::operator<<
std::ostream & operator<<(std::ostream &str, const FileConflicts &obj)
relates: FileConflicts Stream output
Definition FileConflicts.cc:109
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition CodePitfalls.doc:2
zypp::ZYPP_API
const Arch Arch_empty ZYPP_API
relates: Arch This is an empty Arch represented by an empty string.
Definition Arch.h:173
zypp::RWCOW_pointer
RW_pointer supporting 'copy on write' functionality.
Definition PtrTypes.h:469
zypp::sat::asSolvable
To Solvable transform functor.
Definition Solvable.h:598