libzypp
17.14.0
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
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/base/DefaultIntegral.h
"
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
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
matches
(
const
Capability
& lhs )
const
;
80
81
private
:
82
const
sat::detail::IdType
*
_begin
;
83
};
85
87
std::ostream &
operator<<
( std::ostream & str,
const
Capabilities
& obj );
88
90
//
91
// CLASS NAME : Capabilities::const_iterator
92
//
95
class
Capabilities::const_iterator
:
public
boost::iterator_adaptor<
96
const_iterator
// Derived
97
, const sat::detail::IdType *
// Base
98
, const Capability
// Value
99
, boost::forward_traversal_tag
// CategoryOrTraversal
100
, const Capability
// Reference
101
>
102
{
103
public
:
104
const_iterator
()
105
:
const_iterator
::iterator_adaptor_( 0 )
106
{}
107
108
explicit
const_iterator
(
const
sat::detail::IdType
* _idx )
109
:
const_iterator
::iterator_adaptor_( _idx )
110
{
111
if
( base_reference() &&
sat::detail::isDepMarkerId
( *base_reference() ) )
112
{
113
_tagged
=
true
;
114
++base_reference();
115
}
116
}
117
118
public
:
136
bool
tagged
()
const
{
return
_tagged
; }
137
138
private
:
139
friend
class
boost::iterator_core_access
;
140
141
reference
dereference
()
const
142
{
return
( base() ) ?
Capability
( *base() ) :
Capability::Null
; }
143
144
template
<
class
OtherDerived,
class
OtherIterator,
class
V,
class
C,
class
R,
class
D>
145
bool
equal
(
const
boost::iterator_adaptor<OtherDerived, OtherIterator, V, C, R, D> & rhs )
const
146
{
// NULL pointer is eqal pointer to Id 0
147
return
( base() == rhs.base()
// includes both NULL...
148
|| ( !rhs.base() && !*base() )
149
|| ( !base() && !*rhs.base() ) );
150
}
151
152
void
increment
()
153
{
// jump over libsolvs internal ids.
154
if
(
sat::detail::isDepMarkerId
( *(++base_reference()) ) )
155
{
156
_tagged
=
true
;
157
++base_reference();
158
}
159
}
160
161
private
:
162
DefaultIntegral<bool,false>
_tagged
;
163
};
165
166
inline
Capabilities::const_iterator
Capabilities::begin
()
const
167
{
return
const_iterator
(
_begin
); }
168
169
inline
Capabilities::const_iterator
Capabilities::end
()
const
170
{
return
const_iterator
( 0 ); }
171
172
inline
bool
Capabilities::matches
(
const
Capability
& lhs )
const
173
{
174
for
(
const
Capability
& rhs : *
this
)
175
if
( lhs.
matches
( rhs ) ==
CapMatch::yes
)
176
return
true
;
177
return
false
;
178
}
180
}
// namespace zypp
182
#endif // ZYPP_SAT_CAPABILITIES_H
zypp
Capabilities.h
Generated by
1.8.2