libzypp 17.37.10

Capabilities.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
12#ifndef ZYPP_SAT_CAPABILITIES_H
13#define ZYPP_SAT_CAPABILITIES_H
14
15#include <iosfwd>
16
17#include <zypp-core/base/DefaultIntegral>
18#include <zypp/sat/detail/PoolMember.h>
19#include <zypp/Capability.h>
20
22 namespace zypp
23{
24
26 //
27 // CLASS NAME : Capabilities
28 //
35 class ZYPP_API Capabilities
36 {
37 public:
38 typedef Capability value_type;
39 typedef unsigned size_type;
40
41 enum Mode { SKIP_TO_INTERNAL };
42
43 public:
45 Capabilities()
46 : _begin( 0 )
47 {}
48
50 explicit
51 Capabilities( const sat::detail::IdType * base_r )
52 : _begin( base_r )
53 {}
54
58 Capabilities( const sat::detail::IdType * base_r, sat::detail::IdType skip_r );
59
60 public:
62 bool empty() const
63 { return ! ( _begin && *_begin ); }
64
66 size_type size() const;
67
68 public:
69 class const_iterator;
70
72 const_iterator begin() const;
73
75 const_iterator end() const;
76
77 public:
79 bool contains( const Capability & lhs ) const;
80
82 bool matches( const Capability & lhs ) const;
83
84 private:
85 const sat::detail::IdType * _begin;
86 };
87
88
90 std::ostream & operator<<( std::ostream & str, const Capabilities & obj );
91
93 //
94 // CLASS NAME : Capabilities::const_iterator
95 //
98 class Capabilities::const_iterator : public boost::iterator_adaptor<
99 const_iterator // Derived
100 , const sat::detail::IdType * // Base
101 , const Capability // Value
102 , boost::forward_traversal_tag // CategoryOrTraversal
103 , const Capability // Reference
104 >
105 {
106 public:
107 const_iterator()
108 : const_iterator::iterator_adaptor_( 0 )
109 {}
110
111 explicit const_iterator( const sat::detail::IdType * _idx )
112 : const_iterator::iterator_adaptor_( _idx )
113 {
114 if ( base_reference() && sat::detail::isDepMarkerId( *base_reference() ) )
115 {
116 _tagged = true;
117 ++base_reference();
118 }
119 }
120
121 public:
139 bool tagged() const { return _tagged; }
140
141 private:
142 friend class boost::iterator_core_access;
143
144 reference dereference() const
145 { return ( base() ) ? Capability( *base() ) : Capability::Null; }
146
147 template <class OtherDerived, class OtherIterator, class V, class C, class R, class D>
148 bool equal( const boost::iterator_adaptor<OtherDerived, OtherIterator, V, C, R, D> & rhs ) const
149 { // NULL pointer is eqal pointer to Id 0
150 return ( base() == rhs.base() // includes both NULL...
151 || ( !rhs.base() && !*base() )
152 || ( !base() && !*rhs.base() ) );
153 }
154
155 void increment()
156 { // jump over libsolvs internal ids.
157 if ( sat::detail::isDepMarkerId( *(++base_reference()) ) )
158 {
159 _tagged = true;
160 ++base_reference();
161 }
162 }
163
164 private:
165 DefaultIntegral<bool,false> _tagged;
166 };
167
168
169 inline Capabilities::const_iterator Capabilities::begin() const
170 { return const_iterator( _begin ); }
171
172 inline Capabilities::const_iterator Capabilities::end() const
173 { return const_iterator( 0 ); }
174
175 inline bool Capabilities::contains( const Capability & lhs ) const
176 {
177 for ( const Capability & rhs : *this )
178 if ( lhs == rhs )
179 return true;
180 return false;
181 }
182
183 inline bool Capabilities::matches( const Capability & lhs ) const
184 {
185 for ( const Capability & rhs : *this )
186 if ( lhs.matches( rhs ) == CapMatch::yes )
187 return true;
188 return false;
189 }
190
191} // namespace zypp
193#endif // ZYPP_SAT_CAPABILITIES_H
Capability.h
PoolMember.h
zypp::CapMatch::yes
static const CapMatch yes
Definition CapMatch.h:52
zypp::Capabilities::const_iterator
Capabilities iterator.
Definition Capabilities.h:105
zypp::Capabilities::const_iterator::_tagged
DefaultIntegral< bool, false > _tagged
Definition Capabilities.h:165
zypp::Capabilities::const_iterator::increment
void increment()
Definition Capabilities.h:155
zypp::Capabilities::const_iterator::const_iterator
const_iterator()
Definition Capabilities.h:107
zypp::Capabilities::const_iterator::equal
bool equal(const boost::iterator_adaptor< OtherDerived, OtherIterator, V, C, R, D > &rhs) const
Definition Capabilities.h:148
zypp::Capabilities::const_iterator::dereference
reference dereference() const
Definition Capabilities.h:144
zypp::Capabilities::const_iterator::const_iterator
const_iterator(const sat::detail::IdType *_idx)
Definition Capabilities.h:111
zypp::Capabilities::const_iterator::iterator_core_access
friend class boost::iterator_core_access
Definition Capabilities.h:142
zypp::Capabilities::const_iterator::tagged
bool tagged() const
Return true if the Capability is tagged.
Definition Capabilities.h:139
zypp::Capabilities
Container of Capability (currently read only).
Definition Capabilities.h:36
zypp::Capabilities::value_type
Capability value_type
Definition Capabilities.h:38
zypp::Capabilities::Capabilities
Capabilities(const sat::detail::IdType *base_r)
Ctor from Id pointer (friend Solvable).
Definition Capabilities.h:51
zypp::Capabilities::contains
bool contains(const Capability &lhs) const
Return whether the set contains lhs (the Id)
Definition Capabilities.h:175
zypp::Capabilities::begin
const_iterator begin() const
Iterator pointing to the first Capability.
Definition Capabilities.h:169
zypp::Capabilities::matches
bool matches(const Capability &lhs) const
Return whether lhs matches at least one capability in set.
Definition Capabilities.h:183
zypp::Capabilities::end
const_iterator end() const
Iterator pointing behind the last Capability.
Definition Capabilities.h:172
zypp::Capabilities::size_type
unsigned size_type
Definition Capabilities.h:39
zypp::Capabilities::_begin
const sat::detail::IdType * _begin
Definition Capabilities.h:85
zypp::Capabilities::empty
bool empty() const
Whether the container is empty.
Definition Capabilities.h:62
zypp::Capabilities::Mode
Mode
Definition Capabilities.h:41
zypp::Capabilities::SKIP_TO_INTERNAL
@ SKIP_TO_INTERNAL
Definition Capabilities.h:41
zypp::Capabilities::Capabilities
Capabilities()
Default ctor.
Definition Capabilities.h:45
zypp::Capability
A sat capability.
Definition Capability.h:63
zypp::Capability::Null
static const Capability Null
No or Null Capability ( Id 0 ).
Definition Capability.h:147
zypp::Capability::matches
static CapMatch matches(const Capability &lhs, const Capability &rhs)
Definition Capability.h:186
zypp::DefaultIntegral
Integral type with defined initial value when default constructed.
Definition defaultintegral.h:42
str
String related utilities and Regular expression matching.
zypp::base
Definition Random.cc:7
zypp::sat::detail::IdType
int IdType
Generic Id type.
Definition PoolMember.h:104
zypp::sat::detail::isDepMarkerId
bool isDepMarkerId(IdType id_r)
Test for internal ids satlib includes in dependencies.
Definition PoolMember.h:119
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition Application.cc:20
zypp::operator<<
std::ostream & operator<<(std::ostream &str, const SerialNumber &obj)
Definition SerialNumber.cc:52
zypp::contains
bool contains(const Container &c, const Elem &elem)
Definition Algorithm.h:70
zypp::ZYPP_API
const Arch Arch_armv7hnl Arch_armv7nhl ZYPP_API
Definition Arch.h:247