libzypp
17.14.0
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
Selectable.h
Go to the documentation of this file.
1
/*---------------------------------------------------------------------\
2
| ____ _ __ __ ___ |
3
| |__ / \ / / . \ . \ |
4
| / / \ V /| _/ _/ |
5
| / /__ | | | | | | |
6
| /_____||_| |_| |_| |
7
| |
8
\---------------------------------------------------------------------*/
12
#ifndef ZYPP_UI_SELECTABLE_H
13
#define ZYPP_UI_SELECTABLE_H
14
15
#include <iosfwd>
16
17
#include "
zypp/base/ReferenceCounted.h
"
18
#include "
zypp/base/NonCopyable.h
"
19
#include "
zypp/base/PtrTypes.h
"
20
#include "
zypp/base/Iterator.h
"
21
22
#include "
zypp/ui/SelectableTraits.h
"
23
#include "
zypp/ui/Status.h
"
24
26
namespace
zypp
27
{
28
30
namespace
ui
31
{
32
33
DEFINE_PTR_TYPE
(Selectable);
34
36
//
37
// CLASS NAME : Selectable
38
//
51
class
Selectable
:
public
base::ReferenceCounted
,
private
base::NonCopyable
52
{
53
friend
std::ostream &
operator<<
( std::ostream & str,
const
Selectable
& obj );
54
friend
std::ostream &
dumpOn
( std::ostream & str,
const
Selectable
& obj );
55
56
public
:
57
typedef
intrusive_ptr<Selectable>
Ptr
;
58
typedef
intrusive_ptr<const Selectable>
constPtr
;
59
61
typedef
SelectableTraits::available_iterator
available_iterator
;
62
typedef
SelectableTraits::available_size_type
available_size_type
;
63
64
typedef
SelectableTraits::installed_iterator
installed_iterator
;
65
typedef
SelectableTraits::installed_size_type
installed_size_type
;
66
67
typedef
SelectableTraits::picklist_iterator
picklist_iterator
;
68
typedef
SelectableTraits::picklist_size_type
picklist_size_type
;
69
70
public
:
81
static
Ptr
get
(
const
pool::ByIdent
& ident_r );
82
84
static
Ptr
get
(
IdString
ident_r )
85
{
return
get
(
pool::ByIdent
( ident_r ) ); }
86
88
static
Ptr
get
(
ResKind
kind_r,
const
std::string & name_r )
89
{
return
get
(
pool::ByIdent
( kind_r, name_r ) ); }
90
92
static
Ptr
get
(
const
std::string & name_r )
93
{
return
get
(
pool::ByIdent
(
ResKind::package
, name_r ) ); }
94
96
static
Ptr
get
(
const
sat::Solvable
& solv_r )
97
{
return
get
(
pool::ByIdent
( solv_r ) ); }
98
100
static
Ptr
get
(
const
ResObject::constPtr
& resolvable_r )
101
{
return
resolvable_r ?
get
( resolvable_r->satSolvable() ) :
Ptr
(); }
102
104
static
Ptr
get
(
const
PoolItem
& pi_r )
105
{
return
get
( pi_r.satSolvable() ); }
107
108
public
:
114
IdString
ident
()
const
;
115
117
ResKind
kind
()
const
;
118
120
const
std::string &
name
()
const
;
121
123
PoolItem
installedObj
()
const
;
124
129
PoolItem
candidateObj
()
const
;
130
136
PoolItem
candidateObjFrom
(
Repository
repo_r )
const
;
137
144
PoolItem
updateCandidateObj
()
const
;
145
151
PoolItem
highestAvailableVersionObj
()
const
;
152
154
bool
identIsAutoInstalled
()
const
;
155
160
bool
identicalAvailable
(
const
PoolItem
& rhs )
const
;
161
166
bool
identicalInstalled
(
const
PoolItem
& rhs )
const
;
167
171
bool
identicalInstalledCandidate
()
const
172
{
return
identicalInstalled
(
candidateObj
() ); }
173
177
bool
identicalInstalledUpdateCandidate
()
const
178
{
return
identicalInstalled
(
updateCandidateObj
() ); }
179
184
PoolItem
identicalAvailableObj
(
const
PoolItem
& rhs )
const
;
185
190
PoolItem
identicalInstalledObj
(
const
PoolItem
& rhs )
const
;
191
198
template
<
class
TRes>
199
typename
ResTraits<TRes>::constPtrType
installedAsKind
()
const
200
{
return
asKind<TRes>(
candidateObj
() ); }
201
208
template
<
class
TRes>
209
typename
ResTraits<TRes>::constPtrType
candidateAsKind
()
const
210
{
return
asKind<TRes>(
candidateObj
() ); }
211
220
PoolItem
setCandidate
(
const
PoolItem
& newCandidate_r,
ResStatus::TransactByValue
causer_r =
ResStatus::USER
);
222
PoolItem
setCandidate
(
ResObject::constPtr
newCandidate_r,
ResStatus::TransactByValue
causer_r =
ResStatus::USER
);
223
230
bool
setOnSystem
(
const
PoolItem
& newCandidate_r,
ResStatus::TransactByValue
causer_r =
ResStatus::USER
);
231
237
PoolItem
theObj
()
const
;
238
240
245
bool
availableEmpty
()
const
;
246
available_size_type
availableSize
()
const
;
247
available_iterator
availableBegin
()
const
;
248
available_iterator
availableEnd
()
const
;
249
inline
Iterable<available_iterator>
available
()
const
250
{
return
makeIterable(
availableBegin
(),
availableEnd
() ); }
252
254
259
bool
installedEmpty
()
const
;
260
installed_size_type
installedSize
()
const
;
261
installed_iterator
installedBegin
()
const
;
262
installed_iterator
installedEnd
()
const
;
263
inline
Iterable<installed_iterator>
installed
()
const
264
{
return
makeIterable(
installedBegin
(),
installedEnd
() ); }
266
268
274
bool
picklistEmpty
()
const
;
275
picklist_size_type
picklistSize
()
const
;
276
picklist_iterator
picklistBegin
()
const
;
277
picklist_iterator
picklistEnd
()
const
;
278
inline
Iterable<picklist_iterator>
picklist
()
const
279
{
return
makeIterable(
picklistBegin
(),
picklistEnd
() ); }
280
282
static
constexpr
const
picklist_size_type
picklistNoPos
=
picklist_size_type
(-1);
283
288
picklist_size_type
picklistPos
(
const
PoolItem
& pi_r )
const
;
289
291
picklist_size_type
picklistPos
(
const
sat::Solvable
& solv_r )
const
;
293
295
296
public
:
301
bool
hasObject
()
const
302
{
return
(!
installedEmpty
()) ||
candidateObj
(); }
303
305
bool
hasInstalledObj
()
const
306
{
return
!
installedEmpty
(); }
307
309
bool
hasCandidateObj
()
const
310
{
return
bool
(
candidateObj
()); }
311
313
bool
hasBothObjects
()
const
314
{
return
(!
installedEmpty
()) &&
candidateObj
(); }
315
317
bool
hasInstalledObjOnly
()
const
318
{
return
(!
installedEmpty
()) && !
candidateObj
(); }
319
321
bool
hasCandidateObjOnly
()
const
322
{
return
(
installedEmpty
() ) &&
candidateObj
(); }
324
329
bool
isUnmaintained
()
const
;
330
342
bool
multiversionInstall
()
const
;
343
346
bool
pickInstall
(
const
PoolItem
& pi_r,
ResStatus::TransactByValue
causer_r =
ResStatus::USER
,
bool
yesno_r =
true
);
347
350
bool
pickNoInstall
(
const
PoolItem
& pi_r,
ResStatus::TransactByValue
causer_r =
ResStatus::USER
)
351
{
return
pickInstall
( pi_r, causer_r,
false
); }
352
355
bool
pickDelete
(
const
PoolItem
& pi_r,
ResStatus::TransactByValue
causer_r =
ResStatus::USER
,
bool
yesno_r =
true
);
356
359
bool
pickNoDelete
(
const
PoolItem
& pi_r,
ResStatus::TransactByValue
causer_r =
ResStatus::USER
)
360
{
return
pickDelete
( pi_r, causer_r,
false
); }
361
385
Status
pickStatus
(
const
PoolItem
& pi_r )
const
;
386
388
bool
setPickStatus
(
const
PoolItem
& pi_r,
Status
state_r,
ResStatus::TransactByValue
causer_r =
ResStatus::USER
);
390
400
bool
isUndetermined
()
const
;
401
405
bool
isRelevant
()
const
;
406
408
bool
isSatisfied
()
const
;
409
411
bool
isBroken
()
const
;
412
418
bool
isNeeded
()
const
;
419
421
bool
isUnwanted
()
const
;
423
424
public
:
428
enum
Fate
{
429
TO_DELETE
= -1,
430
UNMODIFIED
= 0,
431
TO_INSTALL
= 1
432
};
434
Fate
fate
()
const
;
435
437
bool
unmodified
()
const
438
{
return
fate
() ==
UNMODIFIED
; }
439
446
bool
locked
()
const
447
{
Status
st(
status
() );
return
( st ==
S_Protected
|| st ==
S_Taboo
); }
448
454
bool
hasLocks
()
const
;
455
457
bool
toModify
()
const
458
{
return
fate
() !=
UNMODIFIED
; }
459
461
bool
toDelete
()
const
462
{
return
fate
() ==
TO_DELETE
; }
463
465
bool
toInstall
()
const
466
{
return
fate
() ==
TO_INSTALL
; }
467
469
bool
onSystem
()
const
470
{
return
( (
hasInstalledObj
() && !
toDelete
() )
471
||(
hasCandidateObj
() &&
toInstall
() ) ); }
472
474
bool
offSystem
()
const
475
{
return
!
onSystem
(); }
476
478
bool
setFate
(
Fate
fate_r,
ResStatus::TransactByValue
causer_r =
ResStatus::USER
);
479
481
bool
setToInstall
(
ResStatus::TransactByValue
causer_r =
ResStatus::USER
)
482
{
return
setFate
(
TO_INSTALL
, causer_r ); }
483
485
bool
setInstalled
(
ResStatus::TransactByValue
causer_r =
ResStatus::USER
);
486
488
bool
setUpToDate
(
ResStatus::TransactByValue
causer_r =
ResStatus::USER
);
489
491
bool
setToDelete
(
ResStatus::TransactByValue
causer_r =
ResStatus::USER
)
492
{
return
setFate
(
TO_DELETE
, causer_r ); }
493
495
bool
setDeleted
(
ResStatus::TransactByValue
causer_r =
ResStatus::USER
);
496
498
bool
unset
(
ResStatus::TransactByValue
causer_r =
ResStatus::USER
)
499
{
return
setFate
(
UNMODIFIED
, causer_r ); }
501
502
public
:
511
Status
status
()
const
;
512
517
bool
setStatus
(
Status
state_r,
ResStatus::TransactByValue
causer_r =
ResStatus::USER
);
518
520
ResStatus::TransactByValue
modifiedBy
()
const
;
521
523
bool
hasLicenceConfirmed
()
const
;
524
526
void
setLicenceConfirmed
(
bool
val_r =
true
);
528
529
public
:
531
struct
Impl
;
532
typedef
shared_ptr<Impl>
Impl_Ptr
;
534
Selectable
(
Impl_Ptr
pimpl_r );
535
private
:
537
~Selectable
();
538
private
:
540
RW_pointer<Impl>
_pimpl
;
541
};
543
545
std::ostream &
operator<<
( std::ostream & str,
const
Selectable
& obj );
546
548
std::ostream &
dumpOn
( std::ostream & str,
const
Selectable
& obj );
549
554
struct
asSelectable
555
{
556
typedef
Selectable_Ptr
result_type
;
557
558
Selectable_Ptr
operator()
(
const
sat::Solvable
& solv_r )
const
;
559
560
Selectable_Ptr
operator()
(
const
PoolItem
& pi_r )
const
561
{
return
operator()
( pi_r.
satSolvable
() ); }
562
};
563
565
}
// namespace ui
568
}
// namespace zypp
570
#endif // ZYPP_UI_SELECTABLE_H
zypp
ui
Selectable.h
Generated by
1.8.2