libzypp
17.14.0
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
PoolItem.cc
Go to the documentation of this file.
1
/*---------------------------------------------------------------------\
2
| ____ _ __ __ ___ |
3
| |__ / \ / / . \ . \ |
4
| / / \ V /| _/ _/ |
5
| / /__ | | | | | | |
6
| /_____||_| |_| |_| |
7
| |
8
\---------------------------------------------------------------------*/
12
#include <iostream>
13
#include "
zypp/base/Logger.h
"
14
#include "
zypp/base/DefaultIntegral.h
"
15
16
#include "
zypp/PoolItem.h
"
17
#include "
zypp/ResPool.h
"
18
#include "
zypp/Package.h
"
19
#include "
zypp/VendorAttr.h
"
20
21
using
std::endl;
22
24
namespace
zypp
25
{
26
28
//
29
// CLASS NAME : PoolItem::Impl
30
//
37
struct
PoolItem::Impl
38
{
39
public
:
40
Impl
() {}
41
42
Impl
(
ResObject::constPtr
res_r,
43
const
ResStatus
& status_r )
44
:
_status
( status_r )
45
,
_resolvable
( res_r )
46
{}
47
48
ResStatus
&
status
()
const
49
{
return
_buddy
> 0 ?
PoolItem
(
buddy
()).status() :
_status
; }
50
51
sat::Solvable
buddy
()
const
52
{
53
if
( !
_buddy
)
54
return
sat::Solvable::noSolvable
;
55
if
(
_buddy
< 0 )
56
return
sat::Solvable
( -
_buddy
);
57
return
sat::Solvable
(
_buddy
);
58
}
59
60
void
setBuddy
(
const
sat::Solvable
& solv_r );
61
62
ResObject::constPtr
resolvable
()
const
63
{
return
_resolvable
; }
64
65
ResStatus
&
statusReset
()
const
66
{
67
_status
.
setLock
(
false
,
zypp::ResStatus::USER
);
68
_status
.
resetTransact
(
zypp::ResStatus::USER
);
69
return
_status
;
70
}
71
72
public
:
73
bool
isUndetermined
()
const
74
{
75
return
status
().
isUndetermined
();
76
}
77
78
bool
isRelevant
()
const
79
{
80
return
!
status
().
isNonRelevant
();
81
}
82
83
bool
isSatisfied
()
const
84
{
85
return
status
().
isSatisfied
();
86
}
87
88
bool
isBroken
()
const
89
{
90
return
status
().
isBroken
();
91
}
92
93
bool
isNeeded
()
const
94
{
95
return
status
().
isToBeInstalled
() || (
isBroken
() && !
status
().
isLocked
() );
96
}
97
98
bool
isUnwanted
()
const
99
{
100
return
isBroken
() &&
status
().
isLocked
();
101
}
102
103
private
:
104
mutable
ResStatus
_status
;
105
ResObject::constPtr
_resolvable
;
106
DefaultIntegral<sat::detail::IdType,sat::detail::noId>
_buddy
;
107
112
public
:
113
void
saveState
()
const
114
{
_savedStatus
=
status
(); }
115
void
restoreState
()
const
116
{
status
() =
_savedStatus
; }
117
bool
sameState
()
const
118
{
119
if
(
status
() ==
_savedStatus
)
120
return
true
;
121
// some bits changed...
122
if
(
status
().getTransactValue() !=
_savedStatus
.
getTransactValue
()
123
&& ( !
status
().
isBySolver
()
// ignore solver state changes
124
// removing a user lock also goes to bySolver
125
||
_savedStatus
.
getTransactValue
() ==
ResStatus::LOCKED
) )
126
return
false
;
127
if
(
status
().
isLicenceConfirmed
() !=
_savedStatus
.
isLicenceConfirmed
() )
128
return
false
;
129
return
true
;
130
}
131
private
:
132
mutable
ResStatus
_savedStatus
;
134
135
public
:
137
static
shared_ptr<Impl>
nullimpl
()
138
{
139
static
shared_ptr<Impl> _nullimpl(
new
Impl
);
140
return
_nullimpl;
141
}
142
};
144
146
inline
std::ostream &
operator<<
( std::ostream & str,
const
PoolItem::Impl
& obj )
147
{
148
str << obj.
status
();
149
if
(obj.
resolvable
())
150
str << *obj.
resolvable
();
151
else
152
str <<
"(NULL)"
;
153
return
str;
154
}
155
156
inline
void
PoolItem::Impl::setBuddy
(
const
sat::Solvable
& solv_r )
157
{
158
PoolItem
myBuddy( solv_r );
159
if
( myBuddy )
160
{
161
if
( myBuddy.
_pimpl
->_buddy )
162
{
163
ERR
<< *
this
<<
" would be buddy2 in "
<< myBuddy << endl;
164
return
;
165
}
166
myBuddy.
_pimpl
->_buddy = -
resolvable
()->satSolvable().id();
167
_buddy
= myBuddy.
satSolvable
().
id
();
168
DBG
<< *
this
<<
" has buddy "
<< myBuddy << endl;
169
}
170
}
171
173
// class PoolItem
175
176
PoolItem::PoolItem
()
177
:
_pimpl
(
Impl
::nullimpl() )
178
{}
179
180
PoolItem::PoolItem
(
const
sat::Solvable
& solvable_r )
181
: _pimpl(
ResPool
::instance().find( solvable_r )._pimpl )
182
{}
183
184
PoolItem::PoolItem
(
const
ResObject::constPtr
& resolvable_r )
185
: _pimpl(
ResPool
::instance().find( resolvable_r )._pimpl )
186
{}
187
188
PoolItem::PoolItem
(
Impl
* implptr_r )
189
: _pimpl( implptr_r )
190
{}
191
192
PoolItem
PoolItem::makePoolItem
(
const
sat::Solvable
& solvable_r )
193
{
194
return
PoolItem
(
new
Impl
(
makeResObject
( solvable_r ), solvable_r.
isSystem
() ) );
195
}
196
197
PoolItem::~PoolItem
()
198
{}
199
200
ResPool
PoolItem::pool
()
const
201
{
return
ResPool::instance
(); }
202
203
204
ResStatus
&
PoolItem::status
()
const
{
return
_pimpl
->
status
(); }
205
ResStatus
&
PoolItem::statusReset
()
const
{
return
_pimpl
->
statusReset
(); }
206
sat::Solvable
PoolItem::buddy
()
const
{
return
_pimpl
->
buddy
(); }
207
void
PoolItem::setBuddy
(
const
sat::Solvable
& solv_r ) {
_pimpl
->
setBuddy
( solv_r ); }
208
bool
PoolItem::isUndetermined
()
const
{
return
_pimpl
->
isUndetermined
(); }
209
bool
PoolItem::isRelevant
()
const
{
return
_pimpl
->
isRelevant
(); }
210
bool
PoolItem::isSatisfied
()
const
{
return
_pimpl
->
isSatisfied
(); }
211
bool
PoolItem::isBroken
()
const
{
return
_pimpl
->
isBroken
(); }
212
bool
PoolItem::isNeeded
()
const
{
return
_pimpl
->
isNeeded
(); }
213
bool
PoolItem::isUnwanted
()
const
{
return
_pimpl
->
isUnwanted
(); }
214
void
PoolItem::saveState
()
const
{
_pimpl
->
saveState
(); }
215
void
PoolItem::restoreState
()
const
{
_pimpl
->
restoreState
(); }
216
bool
PoolItem::sameState
()
const
{
return
_pimpl
->
sameState
(); }
217
ResObject::constPtr
PoolItem::resolvable
()
const
{
return
_pimpl
->
resolvable
(); }
218
219
220
std::ostream &
operator<<
( std::ostream & str,
const
PoolItem
& obj )
221
{
return
str << *obj.
_pimpl
; }
222
223
}
// namespace zypp
zypp
PoolItem.cc
Generated by
1.8.2