libzypp 17.37.10

WhatProvides.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
12#ifndef ZYPP_SAT_WHATPROVIDES_H
13#define ZYPP_SAT_WHATPROVIDES_H
14
15#include <iosfwd>
16#include <vector>
17
18#include <zypp/base/PtrTypes.h>
19#include <zypp/sat/detail/PoolMember.h>
20#include <zypp/sat/Solvable.h>
21#include <zypp/sat/SolvIterMixin.h>
22
24 namespace zypp
25{
27 namespace sat
28 {
29
30 namespace detail
31 {
32 class WhatProvidesIterator;
33 }
34
36 //
37 // CLASS NAME : WhatProvides
38 //
87 class ZYPP_API WhatProvides : public SolvIterMixin<WhatProvides,detail::WhatProvidesIterator>,
88 protected detail::PoolMember
89 {
90 public:
91 using value_type = Solvable;
92 using size_type = unsigned int;
93
94 public:
96 WhatProvides();
97
99 explicit
100 WhatProvides( Capability cap_r );
101
103 explicit
104 WhatProvides( Capabilities caps_r );
105
107 explicit
108 WhatProvides( const CapabilitySet & caps_r );
109
110 public:
112 bool empty() const;
113
115 size_type size() const;
116
117 public:
118 using const_iterator = detail::WhatProvidesIterator;
119
121 const_iterator begin() const;
122
124 const_iterator end() const;
125
126 private:
127 class Impl;
128 RW_pointer<Impl> _pimpl;
129 };
130
131
133 std::ostream & operator<<( std::ostream & str, const WhatProvides & obj );
134
137 class ZYPP_API AllPTFs : public WhatProvides
138 {
139 public:
140 AllPTFs() : WhatProvides( Capability(Solvable::ptfMasterToken.id()) ) {};
141 };
142
143 namespace detail
144 {
146 //
147 // CLASS NAME : WhatProvides::const_iterator
148 //
154 class WhatProvidesIterator : public boost::iterator_adaptor<
155 WhatProvidesIterator // Derived
156 , const detail::IdType * // Base
157 , const Solvable // Value
158 , boost::forward_traversal_tag // CategoryOrTraversal
159 , const Solvable // Reference
160 >
161 {
162 friend std::ostream & operator<<( std::ostream & str, const WhatProvidesIterator & obj );
163 public:
164 WhatProvidesIterator()
165 : iterator_adaptor_( 0 ), _baseRef( 0 ), _offset( 0 )
166 {}
167
171 explicit WhatProvidesIterator( const detail::IdType *const base_r, unsigned offset_r = 0 )
172 : iterator_adaptor_( base_r ), _baseRef( base_r ? &base_reference() : 0 ), _offset( offset_r )
173 {}
174
178 explicit WhatProvidesIterator( const detail::IdType *const* baseRef_r, unsigned offset_r )
179 : iterator_adaptor_( 0 ), _baseRef( baseRef_r ), _offset( offset_r )
180 {}
181
183 WhatProvidesIterator( const WhatProvidesIterator & rhs )
184 : iterator_adaptor_( rhs.base_reference() )
185 , _baseRef( base_reference() ? &base_reference() : rhs._baseRef )
186 , _offset( rhs._offset )
187 {}
188
190 WhatProvidesIterator & operator=( const WhatProvidesIterator & rhs )
191 {
192 if ( this != &rhs ) // no self assign
193 {
194 base_reference() = rhs.base_reference();
195 _baseRef = ( base_reference() ? &base_reference() : rhs._baseRef );
196 _offset = rhs._offset;
197 }
198 return *this;
199 }
200
201 private:
202 friend class boost::iterator_core_access;
203
204 reference dereference() const
205 { return Solvable( getId() ); }
206#if 0
207 template <class OtherDerived, class OtherIterator, class V, class C, class R, class D>
208 bool equal( const boost::iterator_adaptor<OtherDerived, OtherIterator, V, C, R, D> & rhs ) const
209#endif
210 bool equal( const WhatProvidesIterator & rhs ) const
211 {
212 if ( ! ( getId() || rhs.getId() ) )
213 return true; // both @end
214 if ( _offset != rhs._offset )
215 return false;
216 if ( base_reference() )
217 return( base_reference() == rhs.base_reference() );
218 return( _baseRef == rhs._baseRef );
219 }
220
221 void increment()
222 { ++_offset; }
223
224 detail::IdType getId() const
225 { return _baseRef ? (*_baseRef)[_offset] : detail::noId; }
226
227 private:
228 const detail::IdType *const* _baseRef;
229 unsigned _offset;
230 };
231
232 }
233
234 inline WhatProvides::const_iterator WhatProvides::end() const
235 { return const_iterator(); }
236
238 } // namespace sat
241} // namespace zypp
243#endif // ZYPP_SAT_WHATPROVIDES_H
PoolMember.h
SolvIterMixin.h
Solvable.h
zypp::Capabilities
Container of Capability (currently read only).
Definition Capabilities.h:36
zypp::Capability
A sat capability.
Definition Capability.h:63
zypp::sat::AllPTFs::AllPTFs
AllPTFs()
Definition WhatProvides.h:140
zypp::sat::SolvIterMixin< WhatProvides, detail::WhatProvidesIterator >::SolvIterMixin
SolvIterMixin()
Definition SolvIterMixin.h:198
zypp::sat::Solvable
A Solvable object within the sat Pool.
Definition Solvable.h:54
zypp::sat::WhatProvides::Impl
WhatProvides implementation date.
Definition WhatProvides.cc:42
zypp::sat::WhatProvides
Container of Solvable providing a Capability (read only).
Definition WhatProvides.h:89
zypp::sat::WhatProvides::_pimpl
RW_pointer< Impl > _pimpl
Definition WhatProvides.h:128
zypp::sat::WhatProvides::end
const_iterator end() const
Iterator pointing behind the last Solvable.
Definition WhatProvides.h:234
zypp::sat::WhatProvides::empty
bool empty() const
Whether the container is empty.
Definition WhatProvides.cc:129
zypp::sat::WhatProvides::value_type
Solvable value_type
Definition WhatProvides.h:91
zypp::sat::WhatProvides::const_iterator
detail::WhatProvidesIterator const_iterator
Definition WhatProvides.h:118
zypp::sat::WhatProvides::size_type
unsigned int size_type
Definition WhatProvides.h:92
zypp::sat::WhatProvides::WhatProvides
WhatProvides()
Default ctor.
Definition WhatProvides.cc:94
zypp::sat::WhatProvides::begin
const_iterator begin() const
Iterator pointing to the first Solvable.
Definition WhatProvides.cc:145
zypp::sat::WhatProvides::size
size_type size() const
Number of solvables inside.
Definition WhatProvides.cc:134
zypp::sat::detail::WhatProvidesIterator
WhatProvides iterator.
Definition WhatProvides.h:161
zypp::sat::detail::WhatProvidesIterator::WhatProvidesIterator
WhatProvidesIterator()
Definition WhatProvides.h:164
zypp::sat::detail::WhatProvidesIterator::operator<<
friend std::ostream & operator<<(std::ostream &str, const WhatProvidesIterator &obj)
Definition WhatProvides.cc:171
zypp::sat::detail::WhatProvidesIterator::_baseRef
const detail::IdType *const * _baseRef
Definition WhatProvides.h:228
zypp::sat::detail::WhatProvidesIterator::_offset
unsigned _offset
Definition WhatProvides.h:229
zypp::sat::detail::WhatProvidesIterator::WhatProvidesIterator
WhatProvidesIterator(const WhatProvidesIterator &rhs)
Copy-ctor required to keep _baseRef adjusted.
Definition WhatProvides.h:183
zypp::sat::detail::WhatProvidesIterator::WhatProvidesIterator
WhatProvidesIterator(const detail::IdType *const base_r, unsigned offset_r=0)
Ctor with pointer to 1st elemment of an array.
Definition WhatProvides.h:171
zypp::sat::detail::WhatProvidesIterator::increment
void increment()
Definition WhatProvides.h:221
zypp::sat::detail::WhatProvidesIterator::WhatProvidesIterator
WhatProvidesIterator(const detail::IdType *const *baseRef_r, unsigned offset_r)
Ctor with pointer to pointer to 1st elemment of an array.
Definition WhatProvides.h:178
zypp::sat::detail::WhatProvidesIterator::iterator_core_access
friend class boost::iterator_core_access
Definition WhatProvides.h:202
zypp::sat::detail::WhatProvidesIterator::equal
bool equal(const WhatProvidesIterator &rhs) const
Definition WhatProvides.h:210
zypp::sat::detail::WhatProvidesIterator::getId
detail::IdType getId() const
Definition WhatProvides.h:224
zypp::sat::detail::WhatProvidesIterator::operator=
WhatProvidesIterator & operator=(const WhatProvidesIterator &rhs)
Assignment operator required to keep _baseRef adjusted.
Definition WhatProvides.h:190
zypp::sat::detail::WhatProvidesIterator::dereference
reference dereference() const
Definition WhatProvides.h:204
str
String related utilities and Regular expression matching.
zypp::sat::detail
Definition PoolImpl.cc:72
zypp::sat::detail::noId
static const IdType noId(0)
zypp::sat::detail::IdType
int IdType
Generic Id type.
Definition PoolMember.h:104
zypp::sat
Definition Resolver.h:28
zypp::sat::operator<<
std::ostream & operator<<(std::ostream &str, const FileConflicts &obj)
Definition FileConflicts.cc:109
zypp::solver::detail
Definition PoolImpl.h:110
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition Application.cc:20
zypp::CapabilitySet
std::unordered_set< Capability > CapabilitySet
Definition Capability.h:35
zypp::ZYPP_API
const Arch Arch_armv7hnl Arch_armv7nhl ZYPP_API
Definition Arch.h:247
zypp::RW_pointer
Wrapper for const correct access via Smart pointer types.
Definition PtrTypes.h:293
zypp::sat::detail::PoolMember
Backlink to the associated PoolImpl.
Definition PoolMember.h:89
PtrTypes.h